diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-04-11 22:20:26 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-04-11 22:20:26 -0700 |
commit | 3c780d99cbf733eca31c81798b2e00bd73d484a7 (patch) | |
tree | da624203a109707575604ddf2a0fe62c5858d21f /tools/run_tests | |
parent | 86dd47d355b93ba136fc5a0eaa6f2de0ad0e9b75 (diff) | |
parent | 2f0519e9be3a280483a93d297811882e1e4232b0 (diff) |
Merge pull request #6134 from jtattermusch/migrate_nunit3
Migrate C# to NUnit 3.2
Diffstat (limited to 'tools/run_tests')
-rw-r--r-- | tools/run_tests/post_tests_csharp.bat | 25 | ||||
-rwxr-xr-x | tools/run_tests/post_tests_csharp.sh (renamed from tools/run_tests/run_csharp.sh) | 24 | ||||
-rw-r--r-- | tools/run_tests/run_csharp.bat | 27 | ||||
-rwxr-xr-x | tools/run_tests/run_tests.py | 72 |
4 files changed, 74 insertions, 74 deletions
diff --git a/tools/run_tests/post_tests_csharp.bat b/tools/run_tests/post_tests_csharp.bat new file mode 100644 index 0000000000..7851b9137a --- /dev/null +++ b/tools/run_tests/post_tests_csharp.bat @@ -0,0 +1,25 @@ +@rem Runs C# tests for given assembly from command line. The Grpc.sln solution needs to be built before running the tests. + +setlocal + +if not "%CONFIG%" == "gcov" ( + goto :EOF +) + +@rem enter src/csharp directory +cd /d %~dp0\..\..\src\csharp + +@rem Generate code coverage report +@rem TODO(jtattermusch): currently the report list is hardcoded +packages\ReportGenerator.2.4.4.0\tools\ReportGenerator.exe -reports:"coverage_csharp_*.xml" -targetdir:"..\..\reports\csharp_coverage" -reporttypes:"Html;TextSummary" || goto :error + +@rem Generate the index.html file +echo ^<html^>^<head^>^</head^>^<body^>^<a href='csharp_coverage/index.htm'^>csharp coverage^</a^>^<br/^>^</body^>^</html^> >..\..\reports\index.html + +endlocal + +goto :EOF + +:error +echo Failed! +exit /b %errorlevel% diff --git a/tools/run_tests/run_csharp.sh b/tools/run_tests/post_tests_csharp.sh index dad44c4e4f..bb6f5c6e18 100755 --- a/tools/run_tests/run_csharp.sh +++ b/tools/run_tests/post_tests_csharp.sh @@ -30,23 +30,15 @@ set -ex -CONFIG=${CONFIG:-opt} -NUNIT_CONSOLE="mono packages/NUnit.Runners.2.6.4/tools/nunit-console.exe" +if [ "$CONFIG" != "gcov" ] ; then exit ; fi # change to gRPC repo root cd $(dirname $0)/../.. -(cd src/csharp; $NUNIT_CONSOLE $@) - -if [ "$CONFIG" = "gcov" ] -then - # Generate the csharp extension coverage report - gcov objs/gcov/src/csharp/ext/*.o - lcov --base-directory . --directory . -c -o coverage.info - lcov -e coverage.info '**/src/csharp/ext/*' -o coverage.info - genhtml -o reports/csharp_ext_coverage --num-spaces 2 \ - -t 'gRPC C# native extension test coverage' coverage.info \ - --rc genhtml_hi_limit=95 --rc genhtml_med_limit=80 --no-prefix -fi - - +# Generate the csharp extension coverage report +gcov objs/gcov/src/csharp/ext/*.o +lcov --base-directory . --directory . -c -o coverage.info +lcov -e coverage.info '**/src/csharp/ext/*' -o coverage.info +genhtml -o reports/csharp_ext_coverage --num-spaces 2 \ + -t 'gRPC C# native extension test coverage' coverage.info \ + --rc genhtml_hi_limit=95 --rc genhtml_med_limit=80 --no-prefix diff --git a/tools/run_tests/run_csharp.bat b/tools/run_tests/run_csharp.bat deleted file mode 100644 index 29c879e23b..0000000000 --- a/tools/run_tests/run_csharp.bat +++ /dev/null @@ -1,27 +0,0 @@ -@rem Runs C# tests for given assembly from command line. The Grpc.sln solution needs to be built before running the tests. - -setlocal - -@rem enter src/csharp directory -cd /d %~dp0\..\..\src\csharp - -if not "%CONFIG%" == "gcov" ( - packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe %* || goto :error -) else ( - @rem Run all tests with code coverage - - packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"packages\NUnit.Runners.2.6.4\tools\nunit-console-x86.exe" -targetdir:"." -targetargs:"%*" -filter:"+[Grpc.Core]*" -register:user -output:coverage_results.xml || goto :error - - packages\ReportGenerator.2.4.4.0\tools\ReportGenerator.exe -reports:"coverage_results.xml" -targetdir:"..\..\reports\csharp_coverage" -reporttypes:"Html;TextSummary" || goto :error - - @rem Generate the index.html file - echo ^<html^>^<head^>^</head^>^<body^>^<a href='csharp_coverage/index.htm'^>csharp coverage^</a^>^<br/^>^</body^>^</html^> >..\..\reports\index.html -) - -endlocal - -goto :EOF - -:error -echo Failed! -exit /b %errorlevel% diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index dfac94660b..9dff686bbf 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -486,41 +486,48 @@ class CSharpLanguage(object): def test_specs(self): with open('src/csharp/tests.json') as f: - tests_json = json.load(f) - assemblies = tests_json['assemblies'] - tests = tests_json['tests'] + tests_by_assembly = json.load(f) msbuild_config = _MSBUILD_CONFIG[self.config.build_config] - assembly_files = ['%s/bin/%s/%s.dll' % (a, msbuild_config, a) - for a in assemblies] - - extra_args = ['-labels'] + assembly_files - + nunit_args = ['--labels=All', + '--noresult', + '--workers=1'] if self.platform == 'windows': - script_name = 'tools\\run_tests\\run_csharp.bat' - extra_args += ['-domain=None'] + runtime_cmd = [] else: - script_name = 'tools/run_tests/run_csharp.sh' - - if self.config.build_config == 'gcov': - # On Windows, we only collect C# code coverage. - # On Linux, we only collect coverage for native extension. - # For code coverage all tests need to run as one suite. - return [self.config.job_spec([script_name] + extra_args, None, - shortname='csharp.coverage', - environ=_FORCE_ENVIRON_FOR_WRAPPERS)] - else: - specs = [] - for test in tests: - cmdline = [script_name, '-run=%s' % test] + extra_args - if self.platform == 'windows': - # use different output directory for each test to prevent - # TestResult.xml clash between parallel test runs. - cmdline += ['-work=test-result/%s' % uuid.uuid4()] - specs.append(self.config.job_spec(cmdline, None, - shortname='csharp.%s' % test, + runtime_cmd = ['mono'] + + specs = [] + for assembly in tests_by_assembly.iterkeys(): + assembly_file = 'src/csharp/%s/bin/%s/%s.exe' % (assembly, msbuild_config, assembly) + if self.config.build_config != 'gcov' or self.platform != 'windows': + # normally, run each test as a separate process + for test in tests_by_assembly[assembly]: + cmdline = runtime_cmd + [assembly_file, '--test=%s' % test] + nunit_args + specs.append(self.config.job_spec(cmdline, + None, + shortname='csharp.%s' % test, + environ=_FORCE_ENVIRON_FOR_WRAPPERS)) + else: + # For C# test coverage, run all tests from the same assembly at once + # using OpenCover.Console (only works on Windows). + cmdline = ['src\\csharp\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe', + '-target:%s' % assembly_file, + '-targetdir:src\\csharp', + '-targetargs:%s' % ' '.join(nunit_args), + '-filter:+[Grpc.Core]*', + '-register:user', + '-output:src\\csharp\\coverage_csharp_%s.xml' % assembly] + + # set really high cpu_cost to make sure instances of OpenCover.Console run exclusively + # to prevent problems with registering the profiler. + run_exclusive = 1000000 + specs.append(self.config.job_spec(cmdline, + None, + shortname='csharp.coverage.%s' % assembly, + cpu_cost=run_exclusive, environ=_FORCE_ENVIRON_FOR_WRAPPERS)) - return specs + return specs def pre_build_steps(self): if self.platform == 'windows': @@ -543,7 +550,10 @@ class CSharpLanguage(object): return [['tools/run_tests/build_csharp.sh']] def post_tests_steps(self): - return [] + if self.platform == 'windows': + return [['tools\\run_tests\\post_tests_csharp.bat']] + else: + return [['tools/run_tests/post_tests_csharp.sh']] def makefile_name(self): return 'Makefile' |