From dea2eb95be116a9ffcf210a7161f01b3bffd1035 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 16 Oct 2017 08:51:19 -0500 Subject: [PATCH] [tests] migrate nunit-console commands to MSBuild The end goal here is to easily enable running tests on Windows. To enable this, a new `build-tools/scripts/RunNUnitTests.targets` file is needed. The `Makefile` will invoke this file so we aren't duplicating anything. We will continue with this approach in xamarin/xamarin-android, so running unit tests is simpler on Windows there, too. Usage (Windows): Run all tests: `msbuild build-tools/scripts/RunNUnitTests.targets` Filter based on the `--run` switch: `msbuild build-tools/scripts/RunNUnitTests.targets /p:Run=Java.Interop` Run tests on specific assemblies: `msbuild build-tools\scripts\RunNUnitTests.targets /p:TestAssembly="bin\TestDebug\Java.Interop.Tools.JavaCallableWrappers-Tests.dll;bin\TestDebug\LogcatParse-Tests.dll"` Usage (macOS/linux): `make` commands should remain unchanged. Existing environment variables should continue to work such as `RUNTIME`, `RUN`, `CONFIGURATION`, etc. --- Makefile | 6 +----- build-tools/scripts/RunNUnitTests.targets | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 build-tools/scripts/RunNUnitTests.targets diff --git a/Makefile b/Makefile index 889d3bfff..925c704bc 100644 --- a/Makefile +++ b/Makefile @@ -139,11 +139,7 @@ shell: define RUN_TEST MONO_TRACE_LISTENER=Console.Out \ JAVA_INTEROP_GREF_LOG=g-$(basename $(notdir $(1))).txt $(if $(2),JAVA_INTEROP_LREF_LOG=l-$(basename $(notdir $(1))).txt,) \ - $(RUNTIME) $$MONO_OPTIONS --runtime=v4.0.0 \ - $(NUNIT_CONSOLE) $(NUNIT_EXTRA) $(1) \ - $(if $(RUN),-run:$(RUN)) \ - -xml=TestResult-$(basename $(notdir $(1))).xml \ - -output=bin/Test$(CONFIGURATION)/TestOutput-$(basename $(notdir $(1))).txt ; + $(MSBUILD) $(MSBUILD_FLAGS) build-tools/scripts/RunNUnitTests.targets /p:TestAssembly=$(1) ; endef run-tests: $(TESTS) bin/Test$(CONFIGURATION)/$(JAVA_INTEROP_LIB) diff --git a/build-tools/scripts/RunNUnitTests.targets b/build-tools/scripts/RunNUnitTests.targets new file mode 100644 index 000000000..5eb67c90a --- /dev/null +++ b/build-tools/scripts/RunNUnitTests.targets @@ -0,0 +1,22 @@ + + + + Debug + <_TopDir>$(MSBuildThisFileDirectory)..\.. + <_Runtime Condition=" '$(RUNTIME)' != '' ">$(RUNTIME) + <_Runtime Condition=" '$(RUNTIME)' == '' And '$(OS)' != 'Windows_NT' ">mono + <_NUnit>$(_Runtime) packages\NUnit.Runners.2.6.3\tools\nunit-console.exe + <_Run Condition=" '$(RUN)' != '' ">--run="$(RUN)" + + + <_TestAssembly Include="$(_TopDir)\bin\Test$(Configuration)\*-*Tests.dll" Condition=" '$(TestAssembly)' == '' " /> + <_TestAssembly Include="$(TestAssembly)" Condition=" '$(TestAssembly)' != '' " /> + + + + + \ No newline at end of file