Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugh Bellamy <hughbellars@gmail.com>2016-05-17 22:40:43 +0300
committerHugh Bellamy <hughbellars@gmail.com>2016-06-28 19:31:34 +0300
commit097f48becf8b4c645ede2c65ff2b8face98a4ee5 (patch)
treefe21530dff5bde98db5fd3c0e488c42f377f11be /Documentation
parentef95b87c558f495b30a435c00202628f6096b6f2 (diff)
Add instructions for running code coverage with locally built mscorlib
Fixes #8381
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/building/code-coverage.md19
-rw-r--r--Documentation/building/facade-code-coverage.bat67
2 files changed, 86 insertions, 0 deletions
diff --git a/Documentation/building/code-coverage.md b/Documentation/building/code-coverage.md
index 4d9467241c..34dc06b575 100644
--- a/Documentation/building/code-coverage.md
+++ b/Documentation/building/code-coverage.md
@@ -60,3 +60,22 @@ The results for this one library will then also show up in the aforementioned in
And then once the run completes:
..\..\..\bin\tests\coverage\index.htm
+
+## Code coverage with mscorlib code
+
+Some of the libraries for which contracts and tests live in the corefx repo are actually implemented in the core runtime library in another repo, e.g. the implementation that backs the System.Runtime contract is in System.Private.Corlib.dll in either the coreclr or corert repo. To run coverage reports for these projects, you need to build mscorlib locally from the coreclr repo.
+
+The following steps can be used manually to produce a coverage report, but a customizable batch file can be found [here](facade-code-coverage.bat). Changing the parameters in the first couple of lines lets you run a coverage report easily for any facade project.
+
+1. Build the local test project (`msbuild /T:Build`)
+3. Build coreclr locally in Debug or Release (`build.cmd all Debug skiptests`)
+2. Navigate to the built test directory in the corefx bin (e.g. `bin/tests/AnyOS.AnyCPU.Debug/System.Runtime/netcoreapp1.0` for `System.Runtime`
+4. Delete `coreclr.dll`, `mscorlib.dll` and `mscorlib.ni.dll` from that directory
+5. Copy all files in the coreclr bin directory to the test directory
+6. Run an OpenCover command with `xunit.console.netcore.exe`. For example:
+
+ <corefx-root>/packages/OpenCover/<opencover-version>/tools/OpenCover.Console.exe -filter:"+[*]* -[*.Tests]* -[xunit.*]*" -excludebyfile:"*\Common\src\System\SR.*" -nodefaultfilters -excludebyattribute:*.ExcludeFromCodeCoverage* -skipautoprops -hideskipped:All -threshold:1 -returntargetcode -register:user -targetdir:<path-to corefx-bin> -target:CoreRun.exe -output:coverage.xml -targetargs:"xunit.console.netcore.exe System.Runtime.Tests -xml testResults.xml -notrait Benchmark=true -notrait category=OuterLoop -notrait category=failing -notrait category=nonwindowstests"
+
+7. Run a ReportGenerator command with the generated `coverage.xml` file. For example:
+
+ <corefx-root>/packages/ReportGenerator/<opencover-version>/tools/ReportGenerator.exe -reporttypes:Html;Badges -reports:coverage.xml
diff --git a/Documentation/building/facade-code-coverage.bat b/Documentation/building/facade-code-coverage.bat
new file mode 100644
index 0000000000..465a338cda
--- /dev/null
+++ b/Documentation/building/facade-code-coverage.bat
@@ -0,0 +1,67 @@
+@echo off
+:: Example settings for System.Runtime
+SET project=System.Runtime
+SET msbuildargs=/T:Build
+SET testsubdir=AnyOS.AnyCPU.Debug
+SET filter="+[*]* -[*.Tests]* -[*]System.Collections.* -[*]System.Diagnostics.* -[*]System.Globalization.* -[*]System.IO.* -[*]System.Reflection.* -[*]System.Resources.* -[*]System.Runtime.* -[*]System.Security.* -[*]System.StubHelpers.* -[*]System.Threading.* -[*]Microsoft.* -[*]Windows.* -[*]System.App* -[*]System.Text.Decoder* -[*]System.Text.Encoder* -[*]System.Text.*Encoding -[*]System.Text.Internal* -[xunit.*]*"
+
+:: Update this when OpenCover or ReportGenerator are updated
+SET opencoverversion=4.6.519
+SET reportgeneratorversion=2.4.3
+
+:: Assumes that the corefx and coreclr repo folders are in the same parent folder
+SET root=C:\Users\Hugh\Documents\Github
+
+SET corefx=%root%\corefx
+SET coreclr=%root%\coreclr
+
+SET packages=%corefx%\packages
+SET opencover=%packages%\OpenCover\%opencoverversion%\tools\OpenCover.Console.exe
+SET reportgenerator=%packages%\ReportGenerator\%reportgeneratorversion%\tools\ReportGenerator.exe
+
+SET targetdir=%corefx%\bin\tests\%testsubdir%\%project%.Tests\netcoreapp1.0
+
+SET resultsfile=testresults.xml
+SET coveragefile=coverage.xml
+
+SET coveragedir=coverage
+
+SET originalfolder=%cd%
+SET sourcefolder=%corefx%\src\%project%\tests
+
+SET coreclrbuild=%coreclr%\bin\Product\Windows_NT.x64.Debug
+
+:: Build the library
+cd %sourcefolder%
+msbuild %msbuildargs%
+cd %originalfolder%
+
+:: Delete old files (see #8381 for why)
+del %targetdir%\coreclr.dll
+del %targetdir%\mscorlib.dll
+del %targetdir%\mscorlib.ni.dll
+
+:: Copy over our local build files
+For %%a in (
+%coreclrbuild%\mscorlib.dll
+%coreclrbuild%\PDB\mscorlib.pdb
+%coreclrbuild%\coreclr.dll
+%coreclrbuild%\PDB\coreclr.pdb
+%coreclrbuild%\CoreRun.exe
+%coreclrbuild%\CoreConsole.exe
+%coreclrbuild%\clretwrc.dll
+%coreclrbuild%\clrjit.dll
+%coreclrbuild%\dbgshim.dll
+%coreclrbuild%\mscordaccore.dll
+%coreclrbuild%\mscordbi.dll
+%coreclrbuild%\mscorrc.debug.dll
+%coreclrbuild%\mscorrc.dll
+%coreclrbuild%\sos.dll
+) do copy /b/v/y "%%~a" "%targetdir%\"
+
+:: Now, run the actual tests and generate a coverage report
+SET corerunargs=xunit.console.netcore.exe %project%.Tests.dll -xml %resultsfile% -notrait category=OuterLoop -notrait category=failing -notrait category=nonwindowstests
+
+%opencover% -filter:%filter% -excludebyfile:"*\Common\src\System\SR.*" -nodefaultfilters -excludebyattribute:*.ExcludeFromCodeCoverage* -skipautoprops -hideskipped:All -threshold:1 -returntargetcode -register:user -targetdir:%targetdir% -target:CoreRun.exe -output:%coveragefile% -targetargs:"%corerunargs%"
+
+%reportgenerator% -targetdir:%coveragedir% -reporttypes:Html;Badges -reports:%coveragefile% -verbosity:Error \ No newline at end of file