From 57323096ebe5f104e14c063adf96f0816c7eec70 Mon Sep 17 00:00:00 2001 From: Sven Boemer Date: Thu, 19 Jul 2018 13:44:16 -0700 Subject: [PATCH] Build xunit wrappers the same way on windows and unix (dotnet/coreclr#18695) * Initial change to allow build wrappers and runtest.py * Build xunit wrappers on unix The generated wrapper needs to target netcoreapp on unix. I had to exclude assets from the xunit package and introduce a dependency on the private corefx bits, to resolve a dependency conflict in which the generated wrapper was depending on an older System.Runtime.dll than the helper library. I also disabled binclash logging, because the wrapper build binplaces the helper library to the same location multiple times. I couldn't find a simple way to disable binclash logging for the wrapper build only, since that requires passing an empty switch to run.exe, and bash word splitting makes this nontrivial from build-test. * Correctly generate TestEnv xplat Note that this will still require changes to the test wrapper to actually source the TestEnv on unix * Build xunit wrappers using SDK * Target netcoreapp2.0 in xunit wrappers This way, the wrappers can build even if the 2.1 SDK isn't installed on the machine. * Restore to packages directory for xunit wrappers * Move common properties out to dir.common.props When building wrappers using the SDK, we need some basic properties (like the build os/arch/config, and the output directories) to be set. I factored out properties used by both the old test build and the new SDK-project test build. At first I tried using Directory.Build.props (which is automatically imported by the SDK), but our test build already imports SDK targets in various places, so this was resulting in duplicate imports. Instead, I used dir.common.props, and made the imports explicit. * Remove desktop-specific test wrapper csproj * Pass build os/arch/type and logsdir to msbuild from runtest.py * Remove xunit wrapper helper library from traversal build * Fix parameter passing in build-test.sh Use bash arrays to pass parameters for the build command. This makes it possible to pass arguments with spaces to build_Tests_internal. We use this to disable binclashlogging selectively (for the xunit wrapper build only). * Clean up factored .props files * Undo runtest.sh changes * Use latest xunit console runner everywhere * Remove extra StaticDependency on xunit.runner.console * Eliminate tests/src/dir.common.props, and rename dir.sdkbuild.props tests/src/dir.common.props was only used for the desktop-specific xunit wrapper helper library. There's no need for it any more, so its properties have been moved into tests/src/dir.props. dir.sdkbuild.props has been renamed to dir.common.props, since it contains properties used by SDK projects and buildtools projects. This change also re-enables the test build. * Reintroduce dir.sdkbuild.props as a place for SDK-only props With this, some properties shared by SDK projects can go in a global location. The TargetFramework is shared by all SDK projects in the test tree. This change also uses a property for the xunit package directory that contains the xunit.console.dll we copy to core_root. * Add xml namespace to dir.common.props This fixes a failure in the windows build. * Satisfy xunit analyzer * Satisfy xunit analyzer again * Use SDK msbuild to build wrappers On windows, the use of run.exe, config.json, and msbuild.cmd uses msbuild.exe on the path. This change will build wrappers using the local SDK via "dotnet msbuild", bypassing run.exe. Run.exe will go away entirely with the move from buildtools to arcade, so other build invocatios should follow suit. * Remove Microsoft.CSharp.Core.targets workaround UseBuildTools used to be true all the time. Now that we are building wrappers on core, UseBuildTools becomes false. However, the rest of the runtest.proj expects to build using buildtools, so we keep UseBuildTools true until we switch to arcade. The CSharpCoreTargetsPath was imported when running on core only. This used to happen only on unix, but now it also happens when building runtest.proj for the xunit wrappers on windows. On unix, this targets file was a symlink to itself to work around some buildtools logic that expected the file to exist. This workaround no longer appears necessary, and on windows, this was never used in the first place, so this change removes it. * Remove UseRoslynCompilers prop and unify roslyn import UseRoslynCompilers was introduced in buildtools by https://github.com/dotnet/buildtools/pull/947, with different behaviors on windows/unix. It was removed by https://github.com/dotnet/buildtools/pull/1974, so we can unify our roslyn imports now. * Don't copy xunit dlls to corefx test host The corefx tests run on specific versions of xunit dlls, defined in CoreFX.depproj. We want to use these versions in the test host, not those in CORE_ROOT, so exclude these from being copied to the test host directory. This fixes the failing corefx tests. * Don't pass run.exe arguments through build-test.cmd in test pipeline These arguments get passed along to the xunit wrapper build as unprocessed build args. They need to work for "dotnet msbuild" (used for the wrapper build) as well as for run.exe. * Fix parameter passing of priority arg in build-test.cmd UnprocessedBuildArgs should contain arguments in the format expected by msbuild, not by run.exe. * Fix parameter passing of unprocessed args in build-test.cmd The "--" syntax is used by run.exe to pass everything following to msbuild directly. It should not be a part of unprocessed args. * Pass TargetsWindowsArg to wrapper build in build-test.cmd Helix builds tests on windows and runs them on unix using the xunit wrappers. When cross-building the wrappers like this, TargetsWindows is set to false by the test build pipeline. This variable ensures that the wrapper uses correct directory separators when invoking the test .sh file. * Pass BuildTestsAgainstPackages arg to exclude unix tests Helix builds xunit wrappers on windows, and runs them on unix. The BuildTestsAgainstPackages should currently be set to true in the windows wrapper build to properly filter the .cmd files based on exclusions in issues.targets. Commit migrated from https://github.com/dotnet/coreclr/commit/f5f9a3456abcfdea5d886fededaa0265c80281ed --- src/coreclr/build-test.cmd | 36 +- src/coreclr/build-test.sh | 71 ++-- .../tests/Dotnet-CoreClr-Trusted-BuildTests.json | 2 +- src/coreclr/dependencies.props | 7 +- src/coreclr/dir.common.props | 36 ++ src/coreclr/dir.props | 14 +- src/coreclr/run.sh | 2 +- src/coreclr/tests/build.proj | 1 - src/coreclr/tests/dir.common.props | 28 ++ src/coreclr/tests/dir.props | 5 +- src/coreclr/tests/dir.sdkbuild.props | 14 + src/coreclr/tests/helixprep.proj | 10 +- src/coreclr/tests/override.targets | 4 - src/coreclr/tests/runtest.proj | 81 ++-- src/coreclr/tests/runtest.py | 441 +++++++++++++++++++++ src/coreclr/tests/scripts/scripts.csproj | 4 +- .../Coreclr.TestWrapper/Coreclr.TestWrapper.csproj | 38 +- .../Desktop.Coreclr.TestWrapper.csproj | 45 --- .../tests/src/Common/external/external.depproj | 21 +- .../Performance/CodeQuality/Layout/SearchLoops.cs | 4 +- .../CodeQuality/SIMD/SeekUnroll/SeekUnroll.cs | 2 +- .../benchmark+roslyn/benchmark+roslyn.csproj | 4 +- .../benchmark+serialize/benchmark+serialize.csproj | 4 +- .../src/JIT/config/benchmark/benchmark.csproj | 4 +- .../TestWrappersConfig/TestWrappersConfig.csproj | 38 -- src/coreclr/tests/src/dir.common.props | 63 --- src/coreclr/tests/src/dir.props | 51 ++- src/coreclr/tests/src/dirs.proj | 3 +- .../tests/src/performance/performance.csproj | 4 +- src/coreclr/tests/tests.targets | 30 +- src/coreclr/tests/xunitwrapper.targets | 61 --- 31 files changed, 721 insertions(+), 407 deletions(-) create mode 100644 src/coreclr/dir.common.props create mode 100644 src/coreclr/tests/dir.common.props create mode 100644 src/coreclr/tests/dir.sdkbuild.props create mode 100755 src/coreclr/tests/runtest.py delete mode 100644 src/coreclr/tests/src/Common/Desktop.Coreclr.TestWrapper/Desktop.Coreclr.TestWrapper.csproj delete mode 100644 src/coreclr/tests/src/TestWrappersConfig/TestWrappersConfig.csproj delete mode 100644 src/coreclr/tests/src/dir.common.props delete mode 100644 src/coreclr/tests/xunitwrapper.targets diff --git a/src/coreclr/build-test.cmd b/src/coreclr/build-test.cmd index d125b5d..31c5ad3 100644 --- a/src/coreclr/build-test.cmd +++ b/src/coreclr/build-test.cmd @@ -46,6 +46,7 @@ set processedArgs= set __unprocessedBuildArgs= set __RunArgs= set __BuildAgainstPackagesArg= +set __BuildAgainstPackagesMsbuildArg= set __SkipRestorePackages= set __SkipManaged= set __SkipNative= @@ -59,6 +60,8 @@ set __DoCrossgen= @REM appears to CMD parsing as "-priority 1". Handle -priority specially to avoid problems, @REM and allow the "-priority=1" syntax. set __Priority=0 +set __PriorityArg= +set __PassThroughArg= :Arg_Loop if "%1" == "" goto ArgsDone @@ -80,7 +83,7 @@ if /i "%1" == "skipmanaged" (set __SkipManaged=1&set processedArgs=!pr if /i "%1" == "skipnative" (set __SkipNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "buildtesthostonly" (set __SkipNative=1&set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) -if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set __BuildAgainstPackagesMsbuildArg=/p:BuildTestsAgainstPackages=true&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "skiprestorepackages" (set __SkipRestorePackages=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "ziptests" (set __ZipTests=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "crossgen" (set __DoCrossgen=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @@ -88,6 +91,7 @@ if /i "%1" == "runtimeid" (set __RuntimeId=%2&set processedArgs=!pro if /i "%1" == "targetsNonWindows" (set __TargetsWindows=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "Exclude" (set __Exclude=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) if /i "%1" == "-priority" (set __Priority=%2&shift&set processedArgs=!processedArgs! %1=%2&shift&goto Arg_Loop) +if /i "%1" == "--" (set __PassThroughArg=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if [!processedArgs!]==[] ( set __UnprocessedBuildArgs=%__args% @@ -101,7 +105,7 @@ if [!processedArgs!]==[] ( :ArgsDone @REM Special handling for -priority=N argument. -if %__Priority% GTR 0 (set "__UnprocessedBuildArgs=!__UnprocessedBuildArgs! -priority=%__Priority%") +if %__Priority% GTR 0 (set "__PriorityArg=-priority=%__Priority%") if defined __BuildAgainstPackagesArg ( if not defined __RuntimeID ( @@ -113,6 +117,8 @@ if defined __BuildAgainstPackagesArg ( @if defined _echo @echo on set __RunArgs=-BuildOS=%__BuildOS% -BuildType=%__BuildType% -BuildArch=%__BuildArch% +REM As we move from buildtools to arcade, __RunArgs should be replaced with __msbuildArgs +set __msbuildArgs=/p:__BuildOS=%__BuildOS% /p:__BuildType=%__BuildType% /p:__BuildArch=%__BuildArch% if defined __ToolsetDir ( rem arm64 builds currently use private toolset which has not been released yet @@ -156,6 +162,12 @@ REM === REM ========================================================================================= call "%__ProjectDir%\init-tools.cmd" @if defined _echo @echo on +set "__ToolsDir=%__ProjectDir%\Tools" +set "__DotnetHost=%__ToolsDir%\dotnetcli\dotnet.exe" +if not exist "%__DotnetHost%" ( + echo %__DotnetHost% not found after init-tools. + exit /b 1 +) REM ========================================================================================= REM === @@ -220,7 +232,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call "%__ProjectDir%\run.cmd" build -Project="%__NativeTestIntermediatesDir%\install.vcxproj" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__msbuildNativeArgs% %__RunArgs% %__unprocessedBuildArgs% +call "%__ProjectDir%\run.cmd" build -Project="%__NativeTestIntermediatesDir%\install.vcxproj" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__msbuildNativeArgs% %__RunArgs% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: echo %__BuildLog% @@ -250,7 +262,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -BatchRestorePackages -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs% +call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -BatchRestorePackages -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if not defined __BuildAgainstPackagesArg goto SkipRestoreProduct set __BuildLogRootName=Tests_GenerateRuntimeLayout @@ -261,7 +273,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\runtest.proj -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct -RuntimeId="%__RuntimeId%" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs% +call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\runtest.proj -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct -RuntimeId="%__RuntimeId%" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo BinPlace of mscorlib.dll failed exit /b 1 @@ -309,7 +321,7 @@ for /l %%G in (1, 1, %__BuildLoopCount%) do ( set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%";Append=!__AppendToLog! set TestBuildSlice=%%G - call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs% + call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: @@ -365,10 +377,13 @@ if defined __RuntimeId ( ) set TargetsWindowsArg= +set TargetsWindowsMsbuildArg= if "%__TargetsWindows%"=="1" ( set TargetsWindowsArg=-TargetsWindows=true + set TargetsWindowsMsbuildArg=/p:TargetsWindows=true ) else if "%__TargetsWindows%"=="0" ( set TargetsWindowsArg=-TargetsWindows=false + set TargetsWindowsMsbuildArg=/p:TargetsWindows=false ) echo %__MsgPrefix%Creating test overlay... @@ -381,7 +396,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs% +call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: echo %__BuildLog% @@ -403,7 +418,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testHost -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs% +call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testHost -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: echo %__BuildLog% @@ -424,7 +439,8 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -BuildWrappers -MsBuildEventLogging=" " -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %TargetsWindowsArg% %__unprocessedBuildArgs% +REM Build wrappers using the local SDK's msbuild. As we move to arcade, the other builds should be moved away from run.exe as well. +call %__DotnetHost% msbuild %__ProjectDir%\tests\runtest.proj /p:BuildWrappers=true !__msbuildLog! !__msbuildWrn! !__msbuildErr! %__msbuildArgs% %TargetsWindowsMsbuildArg% %__BuildAgainstPackagesMsbuildArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo Xunit Wrapper build failed exit /b 1 @@ -459,7 +475,7 @@ REM === Prep test binaries for Helix publishing REM === REM ========================================================================================= -call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__unprocessedBuildArgs% +call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: echo %__BuildLog% diff --git a/src/coreclr/build-test.sh b/src/coreclr/build-test.sh index ab73f97..fd2d8af 100755 --- a/src/coreclr/build-test.sh +++ b/src/coreclr/build-test.sh @@ -152,7 +152,7 @@ generate_layout() # === # ========================================================================================= - build_Tests_internal "Restore_Packages" "${__ProjectDir}/tests/build.proj" " -BatchRestorePackages" "Restore product binaries (build tests)" + build_Tests_internal "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages" if [ -n "$__UpdateInvalidPackagesArg" ]; then __up=-updateinvalidpackageversion @@ -172,7 +172,7 @@ generate_layout() mkdir -p $CORE_ROOT - build_Tests_internal "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "-testOverlay" "Creating test overlay" + build_Tests_internal "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay" chmod +x $__BinDir/corerun chmod +x $__BinDir/crossgen @@ -180,14 +180,6 @@ generate_layout() # Make sure to copy over the pulled down packages cp -r $__BinDir/* $CORE_ROOT/ > /dev/null - # Work hardcoded path around - if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets" ]; then - ln -s "${__BuildToolsDir}/Microsoft.CSharp.Core.targets" "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets" - fi - if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.targets" ]; then - ln -s "${__BuildToolsDir}/Microsoft.CSharp.Targets" "${__BuildToolsDir}/Microsoft.CSharp.targets" - fi - } generate_testhost() @@ -201,7 +193,7 @@ generate_testhost() echo "${__MsgPrefix}Creating test overlay..." mkdir -p $TEST_HOST - build_Tests_internal "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "-testHost" "Creating test host" + build_Tests_internal "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost" } @@ -246,15 +238,15 @@ build_Tests() # === # ========================================================================================= - build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" " -BatchRestorePackages" "Restore product binaries (build tests)" + build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages" if [ -n "$__BuildAgainstPackagesArg" ]; then - build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "-BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct" "Restore product binaries (run tests)" + build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "Restore product binaries (run tests)" "-BinPlaceRef" "-BinPlaceProduct" "-CopyCrossgenToProduct" fi echo "Starting the Managed Tests Build..." - build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "$__up" "Managed tests build (build tests)" + build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up" if [ $? -ne 0 ]; then echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)" @@ -270,7 +262,7 @@ build_Tests() if [ ! -f $__XUnitWrapperBuiltMarker ]; then - build_Tests_internal "Tests_XunitWrapper" "$__ProjectDir/tests/runtest.proj" "-BuildWrappers -MsBuildEventLogging=\" \" " "Test Xunit Wrapper" + build_Tests_internal "Tests_XunitWrapper" "$__ProjectDir/tests/runtest.proj" "Test Xunit Wrapper" "-BuildWrappers" "-MsBuildEventLogging= " "-TargetsWindows=false" if [ $? -ne 0 ]; then echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)" @@ -295,16 +287,19 @@ build_Tests() if [ $__ZipTests -ne 0 ]; then echo "${__MsgPrefix}ZIP tests packages..." - build_Tests_internal "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" " " "Prep test binaries for Helix publishing" + build_Tests_internal "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " " fi } build_Tests_internal() { subDirectoryName=$1 - projectName=$2 - extraBuildParameters=$3 - stepName="$4" + shift + projectName=$1 + shift + stepName="$1" + shift + extraBuildParameters=("$@") # Set up directories and file names __BuildLogRootName=$subDirectoryName @@ -312,6 +307,13 @@ build_Tests_internal() __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn" __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err" + # Use binclashlogger by default if no other logger is specified + if [[ "${extraBuildParameters[*]}" == *"-MsBuildEventLogging"* ]]; then + msbuildEventLogging="" + else + msbuildEventLogging="-MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\"" + fi + if [[ "$subDirectoryName" == "Tests_Managed" ]]; then # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache # See https://github.com/Microsoft/msbuild/issues/2993 @@ -337,12 +339,16 @@ build_Tests_internal() export TestBuildSlice=$slice # Generate build command - buildCommand="$__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog=${__msbuildLog} -MsBuildWrn=${__msbuildWrn} -MsBuildErr=${__msbuildErr} -MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs" + buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}") + buildArgs+=("$msbuildEventLogging") + buildArgs+=("${extraBuildParameters[@]}") + buildArgs+=("${__RunArgs[@]}") + buildArgs+=("${__UnprocessedBuildArgs[@]}") echo "Building step '$stepName' slice=$slice via $buildCommand" # Invoke MSBuild - eval $buildCommand + "$__ProjectRoot/run.sh" build "${buildArgs[@]}" # Make sure everything is OK if [ $? -ne 0 ]; then @@ -362,15 +368,16 @@ build_Tests_internal() __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\"" # Generate build command - buildCommand="$__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog=${__msbuildLog} -MsBuildWrn=${__msbuildWrn} -MsBuildErr=${__msbuildErr} -MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs" + buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}") + buildArgs+=("$msbuildEventLogging") + buildArgs+=("${extraBuildParameters[@]}") + buildArgs+=("${__RunArgs[@]}") + buildArgs+=("${__UnprocessedBuildArgs[@]}") echo "Building step '$stepName' via $buildCommand" # Invoke MSBuild - eval $buildCommand - - # Invoke MSBuild - # $__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog="$__msbuildLog" -MsBuildWrn="$__msbuildWrn" -MsBuildErr="$__msbuildErr" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs + "$__ProjectRoot/run.sh" build "${buildArgs[@]}" # Make sure everything is OK if [ $? -ne 0 ]; then @@ -524,7 +531,7 @@ __ZipTests=0 __NativeTestIntermediatesDir= __RunTests=0 __RebuildTests=0 -__BuildTestWrappers=0 +__BuildTestWrappers=1 __GenerateLayoutOnly= __GenerateTestHostOnly= __priority1= @@ -686,10 +693,10 @@ while :; do ;; priority1) __priority1=1 - __UnprocessedBuildArgs="$__UnprocessedBuildArgs -priority=1" + __UnprocessedBuildArgs+=("-priority=1") ;; *) - __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1" + __UnprocessedBuildArgs+=("$1") ;; esac @@ -697,12 +704,12 @@ while :; do done -__RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS" +__RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS") # Configure environment if we are doing a verbose build if [ $__VerboseBuild == 1 ]; then export VERBOSE=1 - __RunArgs="$__RunArgs -verbose" + __RunArgs+=("-verbose") fi # Set default clang version @@ -747,7 +754,7 @@ __CrossgenExe="$__CrossComponentBinDir/crossgen" isMSBuildOnNETCoreSupported -# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set. +# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it. # This is needed by CLI to function. if [ -z "$HOME" ]; then if [ ! -d "$__ProjectDir/temp_home" ]; then diff --git a/src/coreclr/buildpipeline/tests/Dotnet-CoreClr-Trusted-BuildTests.json b/src/coreclr/buildpipeline/tests/Dotnet-CoreClr-Trusted-BuildTests.json index b865ba8..544a961 100644 --- a/src/coreclr/buildpipeline/tests/Dotnet-CoreClr-Trusted-BuildTests.json +++ b/src/coreclr/buildpipeline/tests/Dotnet-CoreClr-Trusted-BuildTests.json @@ -125,7 +125,7 @@ }, "inputs": { "filename": "build-test.cmd", - "arguments": "$(ParentBuildType) $(Architecture) buildagainstpackages runtimeid $(Rid) $(TargetsNonWindowsArg)$(CrossgenArg)-OfficialBuildId=$(ParentOfficialBuildId) -OverwriteCoreClrPackageVersion -Priority=$(Priority) -- /p:IntermediateAzureFeed=$(IntermediateAzureFeed)", + "arguments": "$(ParentBuildType) $(Architecture) buildagainstpackages runtimeid $(Rid) $(TargetsNonWindowsArg) $(CrossgenArg) -Priority=$(Priority) -- /p:OfficialBuildId=$(ParentOfficialBuildId) /p:OverwriteCoreClrPackageVersion=true /p:IntermediateAzureFeed=$(IntermediateAzureFeed)", "workingFolder": "", "failOnStandardError": "false" } diff --git a/src/coreclr/dependencies.props b/src/coreclr/dependencies.props index 5dc7438..8792554 100644 --- a/src/coreclr/dependencies.props +++ b/src/coreclr/dependencies.props @@ -35,8 +35,7 @@ 3.0.0-preview1-26717-04 99.99.99-master-20180718-0214 3.0.0-preview1-26719-01 - 2.2.0-beta2-build3300 - 2.2.0-preview1-02830-02 + 2.4.0-beta.2.build4010 1.0.0-beta-build0015 2.0.4 2.2.0 @@ -164,10 +163,6 @@ $(XunitPerformanceApiPackageVersion) - - $(XunitConsoleNetcorePackageVersion) - - %(Identity) true diff --git a/src/coreclr/dir.common.props b/src/coreclr/dir.common.props new file mode 100644 index 0000000..f945289 --- /dev/null +++ b/src/coreclr/dir.common.props @@ -0,0 +1,36 @@ + + + + + + $(MSBuildThisFileDirectory) + $(CoreclrDir)/packages + + + + + $(__BuildArch) + x64 + x64 + + $(__BuildType) + Debug + Debug + Release + Checked + + $(__BuildOS) + Windows_NT + + $(BuildType) + $(BuildArch) + + + + $(PackagesDir) + + + + diff --git a/src/coreclr/dir.props b/src/coreclr/dir.props index 1b3329f..ad66a0b 100644 --- a/src/coreclr/dir.props +++ b/src/coreclr/dir.props @@ -2,6 +2,8 @@ + + @@ -42,18 +44,6 @@ - - $(__BuildArch) - x64 - x64 - - Debug - Debug - Release - Checked - - $(__BuildOS) - Windows_NT $(__ProjectDir)\ $(MSBuildThisFileDirectory) diff --git a/src/coreclr/run.sh b/src/coreclr/run.sh index 2d037e9..cc6a184 100755 --- a/src/coreclr/run.sh +++ b/src/coreclr/run.sh @@ -9,7 +9,7 @@ toolRuntime=$working_tree_root/Tools dotnet=$toolRuntime/dotnetcli/dotnet echo "Running: $dotnet $toolRuntime/run.exe $working_tree_root/config.json $*" -$dotnet $toolRuntime/run.exe $working_tree_root/config.json $* +$dotnet $toolRuntime/run.exe $working_tree_root/config.json "$@" if [ $? -ne 0 ] then echo "ERROR: An error occured in $dotnet $toolRuntime/run $#. Check $# logs under $working_tree_root." diff --git a/src/coreclr/tests/build.proj b/src/coreclr/tests/build.proj index aede131..a421b13 100644 --- a/src/coreclr/tests/build.proj +++ b/src/coreclr/tests/build.proj @@ -31,7 +31,6 @@ - diff --git a/src/coreclr/tests/dir.common.props b/src/coreclr/tests/dir.common.props new file mode 100644 index 0000000..5c596c0 --- /dev/null +++ b/src/coreclr/tests/dir.common.props @@ -0,0 +1,28 @@ + + + + + + + $(BuildOS).$(Platform).$(Configuration) + + $(CoreclrDir)/tests/src + $([System.String]::Copy('$(MSBuildProjectDirectary)').Replace($(TestSrcDir),''))/$(MSBuildProjectName) + + + $(CoreclrDir)/bin/tests/obj/$(OSPlatformConfig)/Managed/$(BuildProjectRelativeDir) + $(BaseIntermediateOutputPath) + + $(CoreclrDir)/bin/tests/$(OSPlatformConfig)/$(BuildProjectRelativeDir) + $(BaseOutputPath) + + + + diff --git a/src/coreclr/tests/dir.props b/src/coreclr/tests/dir.props index b29983c..5b07136 100644 --- a/src/coreclr/tests/dir.props +++ b/src/coreclr/tests/dir.props @@ -34,7 +34,6 @@ $(BuildToolsTargetsDesktop) true true - false @@ -47,7 +46,6 @@ $(ToolsDir)dotnetcli\ $(ToolsDir)net46\ $(DotnetCliPath)dotnet - $(ToolsDir)\Microsoft.CSharp.Core.targets <_TargetFrameworkDirectories Condition="'$(BuildToolsTargetsDesktop)' != 'true'">$(MSBuildThisFileDirectory)/Documentation @@ -105,8 +103,7 @@ - - + diff --git a/src/coreclr/tests/dir.sdkbuild.props b/src/coreclr/tests/dir.sdkbuild.props new file mode 100644 index 0000000..b5a0fdd --- /dev/null +++ b/src/coreclr/tests/dir.sdkbuild.props @@ -0,0 +1,14 @@ + + + + + + + netcoreapp2.0 + false + false + + + diff --git a/src/coreclr/tests/helixprep.proj b/src/coreclr/tests/helixprep.proj index 2d08e91b..1cbf0ed 100644 --- a/src/coreclr/tests/helixprep.proj +++ b/src/coreclr/tests/helixprep.proj @@ -38,7 +38,7 @@ Inputs="@(XunitDlls)" Outputs="$(TestWorkingDir)archive\**" > - @@ -85,8 +85,8 @@ set CORE_ROOT=%HELIX_CORRELATION_PAYLOAD% $(CmdCrossgenVar) ECHO BEGIN EXECUTION -ECHO %HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.netcore.exe %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing -%HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.netcore.exe %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing +ECHO %HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.dll %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing +%HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.dll %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing echo Finished running tests. Exit code = %ERRORLEVEL% EXIT /B %ERRORLEVEL% @@ -149,8 +149,8 @@ EXIT /B %ERRORLEVEL% $(WrapperShContents)%0a $(WrapperShContents)echo BEGIN EXECUTION%0a - $(WrapperShContents)echo "%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.netcore.exe %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a - $(WrapperShContents)"%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.netcore.exe %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a + $(WrapperShContents)echo "%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.dll %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a + $(WrapperShContents)"%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.dll %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a $(WrapperShContents)ErrorLevel=%24%3F%0a $(WrapperShContents)%0a $(WrapperShContents)echo Finished running tests. Exit code = %24ErrorLevel%0a diff --git a/src/coreclr/tests/override.targets b/src/coreclr/tests/override.targets index 0e7f82b..d4c07a0 100644 --- a/src/coreclr/tests/override.targets +++ b/src/coreclr/tests/override.targets @@ -3,10 +3,6 @@ Overrides for all other targets (including build tools) can go in this file. --> - - - - - - + $(XUnitTestBinBase)\$(CategoryWithSlash) + + + + - - - - - {8ffe99c0-22f8-4462-b839-970eac1b3472} - coreclr - - - {8ffe99c0-22f8-4462-b839-970eac1b3472} - coreclr - + - - - + + - - - $(XunitTestBinBase)\$(CategoryWithSlash)\ - %24(TestWrappersPackagesConfigFileDirectory)obj/project.assets.json - + + + - ]]> +]]> - @@ -151,7 +121,7 @@ $(_XunitEpilog) - + @@ -166,7 +136,6 @@ $(_XunitEpilog) $([System.String]::Copy('$(CategoryWithSlash)').Replace('/','.')) $(Category).XUnitWrapper $(XunitWrapperGeneratedCSDirBase)$(Category) - $(XunitWrapperOutputIntermediatedDirBase)$(Category) <_XunitProlog Condition=" '$(_XunitProlog)'=='' "> @@ -191,7 +160,7 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). { reportBase = System.Environment.GetEnvironmentVariable(%22XunitTestReportDirBase%22)%3B testBinaryBase = System.IO.Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath)%3B - coreRoot = System.IO.Path.GetFullPath(System.Environment.GetEnvironmentVariable(%22CORE_ROOT%22))%3B + coreRoot = System.Environment.GetEnvironmentVariable(%22CORE_ROOT%22)%3B if (String.IsNullOrEmpty(reportBase)) { reportBase = System.IO.Path.Combine(testBinaryBase, "Reports")%3B @@ -205,6 +174,8 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). throw new ArgumentException("Environment variable CORE_ROOT is not set")%3B } + coreRoot = System.IO.Path.GetFullPath(coreRoot)%3B + string operatingSystem = System.Environment.GetEnvironmentVariable("OS")%3B runningInWindows = (operatingSystem != null && operatingSystem.StartsWith("Windows"))%3B } @@ -258,7 +229,7 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). try { CoreclrTestWrapperLib wrapper = new CoreclrTestWrapperLib()%3B - string testSubfolder = @"\$(Category)\$([System.String]::Copy('%(AllCMDs.RelativeDir)').Replace("$(_CMDDIR)\",''))"%3B + string testSubfolder = @"\$(Category)\$([System.String]::Copy('%(AllCMDs.RelativeDir)').Replace("$(_CMDDIR)$([System.IO.Path]::DirectorySeparatorChar)",''))"%3B outputFile = System.IO.Path.GetFullPath(_Global.reportBase + testSubfolder + @"%(AllCMDs.FileName).output.txt")%3B errorFile = System.IO.Path.GetFullPath(_Global.reportBase + testSubfolder + @"%(AllCMDs.FileName).error.txt")%3B testExecutable = System.IO.Path.GetFullPath(_Global.testBinaryBase + @"$([System.String]::Copy('%(AllCMDs.FullPath)').Replace("$(_CMDDIR)",''))")%3B @@ -301,7 +272,7 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). outputText = "Unable to read output file: " + outputFile%3B } - string msg = infraEx != null ? "Test Infrastructure Failure: " + infraEx.Message + string msg = infraEx != null ? "Test Infrastructure Failure: " + infraEx.ToString() : sErrorText + "\n\n" + "Return code: " + ret + "\n" + "Raw output file: " + outputFile + "\n" + @@ -329,7 +300,8 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). - + + @@ -430,10 +402,13 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). + + + - + @@ -502,6 +477,6 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). - + diff --git a/src/coreclr/tests/runtest.py b/src/coreclr/tests/runtest.py new file mode 100755 index 0000000..7cadfb4b --- /dev/null +++ b/src/coreclr/tests/runtest.py @@ -0,0 +1,441 @@ +#!/usr/bin/env python +################################################################################ +################################################################################ +# +# Module: runtest.py +# +# Notes: +# +# Universal script to setup and run the xunit msbuild test runner. +# +# Use the instructions here: +# https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-test-instructions.md +# https://github.com/dotnet/coreclr/blob/master/Documentation/building/unix-test-instructions.md +# +################################################################################ +################################################################################ + +import argparse +import json +import os +import platform +import shutil +import subprocess +import sys +import tempfile + +from collections import defaultdict +from sys import platform as _platform + +################################################################################ +# Argument Parser +################################################################################ + +description = ("""Simple script that essentially sets up and runs either runtest.cmd + or runtests.sh. This wrapper is necessary to do all the setup work. + + Note that this is required because there is not a unified test runner + for coreclr.""") + +# Use either - or / to designate switches. +parser = argparse.ArgumentParser(description=description, prefix_chars='-/') + +parser.add_argument("-arch", dest="arch", nargs='?', default="x64") +parser.add_argument("-build_type", dest="build_type", nargs='?', default="Debug") +parser.add_argument("-test_location", dest="test_location", nargs="?", default=None) +parser.add_argument("-core_root", dest="core_root", nargs='?', default=None) +parser.add_argument("-coreclr_repo_location", dest="coreclr_repo_location", default=os.getcwd()) + +# Only used on Unix +parser.add_argument("-test_native_bin_location", dest="test_native_bin_location", nargs='?', default=None) + +################################################################################ +# Helper Functions +################################################################################ + +def create_and_use_test_env(_os, env, func): + """ Create a test env based on the env passed + + Args: + _os(str) : OS name + env(defaultdict(lambda: None)) : complus variables, key,value dict + func(lambda) : lambda to call, after creating the + : test_env + + Notes: + Using the env passed, create a temporary file to use as the + test_env to be passed for runtest.cmd. Note that this only happens + on windows, until xunit is used on unix there is no managed code run + in runtest.sh. + """ + + complus_vars = defaultdict(lambda: None) + + for key in env: + value = env[key] + if "complus" in key.lower(): + complus_vars[key] = value + + if len(complus_vars.keys()) > 0: + print "Found COMPlus variables in the current environment" + print + + file_header = None + + if _os == "Windows_NT": + file_header = \ +"""@echo off +REM Temporary test env for test run. + +""" + else: + file_header = \ +"""# Temporary test env for test run. + +""" + + with tempfile.NamedTemporaryFile() as test_env: + with open(test_env.name, 'w') as file_handle: + file_handle.write(file_header) + + for key in complus_vars: + value = complus_vars[key] + command = None + if _os == "Windows_NT": + command = "set" + else: + command = "export" + + print "Unset %s" % key + os.environ[key] = "" + + file_handle.write("%s %s=%s%s" % (command, key, value, os.linesep)) + + contents = None + with open(test_env.name) as file_handle: + contents = file_handle.read() + + print + print "TestEnv: %s" % test_env.name + print + print "Contents:" + print + print contents + print + + func(test_env.name) + + else: + func(None) + +def get_environment(): + """ Get all the COMPlus_* Environment variables + + Notes: + Windows uses msbuild for its test runner. Therefore, all COMPlus + variables will need to be captured as a test_env script and passed + to runtest.cmd. + """ + + complus_vars = defaultdict(lambda: "") + + for key in os.environ: + if "complus" in key.lower(): + complus_vars[key] = os.environ[key] + os.environ[key] = '' + elif "superpmi" in key.lower(): + complus_vars[key] = os.environ[key] + os.environ[key] = '' + + return complus_vars + +def call_msbuild(coreclr_repo_location, + msbuild_location, + host_os, + arch, + build_type, + sequential=False): + """ Call msbuild to run the tests built. + + Args: + coreclr_repo_location(str) : path to coreclr repo + msbuild_location(str) : path to msbuild + sequential(bool) : run sequentially if True + + host_os(str) : os + arch(str) : architecture + build_type(str) : configuration + + Notes: + At this point the environment should be setup correctly, including + the test_env, should it need to be passed. + + """ + + common_msbuild_arguments = ["/nologo", "/nodeReuse:false", "/p:Platform=%s" % arch] + + if sequential: + common_msbuild_arguments += ["/p:ParallelRun=false"] + else: + common_msbuild_arguments += ["/maxcpucount"] + + logs_dir = os.path.join(coreclr_repo_location, "bin", "Logs") + if not os.path.isdir(logs_dir): + os.makedirs(logs_dir) + + command = [msbuild_location, + os.path.join(coreclr_repo_location, "tests", "runtest.proj"), + "/p:Runtests=true", + "/clp:showcommandline"] + + log_path = os.path.join(logs_dir, "TestRunResults_%s_%s_%s" % (host_os, arch, build_type)) + build_log = log_path + ".log" + wrn_log = log_path + ".wrn" + err_log = log_path + ".err" + + msbuild_log_args = ["/fileloggerparameters:\"Verbosity=normal;LogFile=%s\"" % build_log, + "/fileloggerparameters1:\"WarningsOnly;LogFile=%s\"" % wrn_log, + "/fileloggerparameters2:\"ErrorsOnly;LogFile=%s\"" % err_log, + "/consoleloggerparameters:Summary", + "/verbosity:diag"] + + command += msbuild_log_args + + command += ["/p:__BuildOS=%s" % host_os, + "/p:__BuildArch=%s" % arch, + "/p:__BuildType=%s" % build_type, + "/p:__LogsDir=%s" % logs_dir] + + if host_os != "Windows_NT": + command = ["bash"] + command + + print " ".join(command) + subprocess.check_output(command) + +def copy_native_test_bin_to_core_root(host_os, path, core_root): + """ Recursively copy all files to core_root + + Args: + host_os(str) : os + path(str) : native test bin location + core_root(str) : core_root location + """ + assert os.path.isdir(path) or os.path.isfile(path) + assert os.path.isdir(core_root) + + extension = "so" if host_os == "Linux" else "dylib" + + if os.path.isdir(path): + for item in os.listdir(path): + copy_native_test_bin_to_core_root(host_os, os.path.join(path, item), core_root) + elif path.endswith(extension): + print "cp -p %s %s" % (path, core_root) + shutil.copy2(path, core_root) + +def run_tests(host_os, + arch, + build_type, + core_root, + coreclr_repo_location, + test_location, + test_native_bin_location, + test_env=None, + is_long_gc=False, + is_gcsimulator=False, + is_jitdasm=False, + is_ilasm=False, + run_sequential=False): + """ Run the coreclr tests + + Args: + host_os(str) : os + arch(str) : arch + build_type(str) : configuration + coreclr_repo_location(str) : path to the root of the repo + core_root(str) : Core_Root path + test_location(str) : Test bin, location + test_native_bin_location : Native test components, None and windows. + test_env(str) : path to the test_env to be used + """ + + # Copy all the native libs to core_root + if host_os != "Windows_NT": + copy_native_test_bin_to_core_root(host_os, os.path.join(test_native_bin_location, "src"), core_root) + + # Setup the msbuild location + msbuild_location = os.path.join(coreclr_repo_location, "Tools", "msbuild.%s" % ("cmd" if host_os == "Windows_NT" else "sh")) + + # Setup the environment + if is_long_gc: + print "Running Long GC Tests, extending timeout to 20 minutes." + os.environ["__TestTimeout"] = "1200000" # 1,200,000 + os.environ["RunningLongGCTests"] = "1" + + if is_gcsimulator: + print "Running GCSimulator tests, extending timeout to one hour." + os.environ["__TestTimeout"] = "3600000" # 3,600,000 + os.environ["RunningGCSimulatorTests"] = "1" + + if is_jitdasm: + print "Running jit disasm on framework and test assemblies." + os.environ["RunningJitDisasm"] = "1" + + if is_ilasm: + print "Running ILasm round trip." + os.environ["RunningIlasmRoundTrip"] = "1" + + # Set Core_Root + os.environ["CORE_ROOT"] = core_root + + # Call msbuild. + call_msbuild(coreclr_repo_location, + msbuild_location, + host_os, + arch, + build_type, + sequential=run_sequential) + + +def setup_args(args): + """ Setup the args based on the argparser obj + + Args: + args(ArgParser): Parsed arguments + + Notes: + If there is no core_root, or test location passed, create a default + location using the build type and the arch. + """ + + host_os = None + arch = args.arch + build_type = args.build_type + + test_location = args.test_location + core_root = args.core_root + test_native_bin_location = args.test_native_bin_location + + coreclr_repo_location = args.coreclr_repo_location + if os.path.basename(coreclr_repo_location) == "tests": + coreclr_repo_location = os.path.dirname(coreclr_repo_location) + + if _platform == "linux" or _platform == "linux2": + host_os = "Linux" + elif _platform == "darwin": + host_os = "OSX" + elif _platform == "win32": + host_os = "Windows_NT" + else: + print "Unknown OS: %s" % host_os + sys.exit(1) + + assert os.path.isdir(coreclr_repo_location) + + if test_location is None: + print "Using default test location." + test_location = os.path.join(coreclr_repo_location, "bin", "tests", "%s.%s.%s" % (host_os, arch, build_type)) + print "TestLocation: %s" % test_location + print + + if core_root is None: + print "Using default location for core_root." + core_root = os.path.join(test_location, "Tests", "Core_Root") + print "Core_Root: %s" % core_root + print + + if host_os != "Windows_NT": + if test_native_bin_location is None: + print "Using default location for test_native_bin_location." + test_native_bin_location = os.path.join(os.path.join(coreclr_repo_location, "bin", "obj", "%s.%s.%s" % (host_os, arch, build_type), "tests")) + print "Native bin location: %s" % test_native_bin_location + print + + valid_arches = ["x64", "x86", "arm", "arm64"] + if not arch in valid_arches: + print "Unsupported architecture: %s." % arch + print "Supported architectures: %s" % "[%s]" % ", ".join(valid_arches) + sys.exit(1) + + valid_build_types = ["Debug", "Checked", "Release"] + if not build_type in valid_build_types: + print "Unsupported configuration: %s." % build_type + print "Supported configurations: %s" % "[%s]" % ", ".join(valid_build_types) + sys.exit(1) + + if not os.path.isdir(test_location): + print "Error, test location: %s, does not exist." % test_location + sys.exit(1) + + if not os.path.isdir(core_root): + print "Error, core_root: %s, does not exist." % core_root + sys.exit(1) + + if host_os != "Windows_NT": + if not os.path.isdir(test_native_bin_location): + print "Error, test_native_bin_location: %s, does not exist." % test_native_bin_location + sys.exit(1) + + return host_os, arch, build_type, coreclr_repo_location, core_root, test_location, test_native_bin_location + +def setup_tools(host_os, coreclr_repo_location): + """ Setup the tools for the repo + + Args: + host_os(str) : os + coreclr_repo_location(str) : path to coreclr repo + + """ + + # Is the tools dir setup + setup = False + tools_dir = os.path.join(coreclr_repo_location, "Tools") + + is_windows = host_os == "Windows_NT" + + if os.path.isfile(os.path.join(tools_dir, "msbuild.%s" % ("cmd" if is_windows else "sh"))): + setup = True + + # init the tools for the repo + if not setup: + command = None + if is_windows: + command = [os.path.join(coreclr_repo_location, "init_tools.cmd")] + else: + command = ["sh", os.path.join(coreclr_repo_location, "init_tools.sh")] + + print " ".join(command) + subprocess.check_output(command) + + setup = True + + return setup + +################################################################################ +# Main +################################################################################ + +def main(args): + host_os, arch, build_type, coreclr_repo_location, core_root, test_location, test_native_bin_location = setup_args(args) + + # Setup the tools for the repo. + setup_tools(host_os, coreclr_repo_location) + + env = get_environment() + ret_code = create_and_use_test_env(host_os, + env, + lambda path: run_tests(host_os, + arch, + build_type, + core_root, + coreclr_repo_location, + test_location, + test_native_bin_location, + test_env=path)) + +################################################################################ +# __main__ +################################################################################ + +if __name__ == "__main__": + args = parser.parse_args() + sys.exit(main(args)) \ No newline at end of file diff --git a/src/coreclr/tests/scripts/scripts.csproj b/src/coreclr/tests/scripts/scripts.csproj index b1a1aab..e803a60 100644 --- a/src/coreclr/tests/scripts/scripts.csproj +++ b/src/coreclr/tests/scripts/scripts.csproj @@ -14,8 +14,8 @@ 1.0.0-alpha-build0040 - - 1.0.2-prerelease-00177 + + $(XunitPackageVersion) 1.0.0-prerelease-00629-04 diff --git a/src/coreclr/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj b/src/coreclr/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj index 2e7abfe..77629e6 100644 --- a/src/coreclr/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj +++ b/src/coreclr/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj @@ -1,35 +1,17 @@ - - - + + + + + + - Debug - AnyCPU - CoreclrTestWrapperLib - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Library - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - BuildOnly - false - BuildOnly true - - - - - - - - False - - + - - - - + + + diff --git a/src/coreclr/tests/src/Common/Desktop.Coreclr.TestWrapper/Desktop.Coreclr.TestWrapper.csproj b/src/coreclr/tests/src/Common/Desktop.Coreclr.TestWrapper/Desktop.Coreclr.TestWrapper.csproj deleted file mode 100644 index b26c893..0000000 --- a/src/coreclr/tests/src/Common/Desktop.Coreclr.TestWrapper/Desktop.Coreclr.TestWrapper.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - Debug - AnyCPU - {5259DD45-EA34-4EE7-B5C5-430B80384544} - Library - Coreclr.TestWrapper - Coreclr.TestWrapper - .NETFramework - v4.5 - true - BuildOnly - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - diff --git a/src/coreclr/tests/src/Common/external/external.depproj b/src/coreclr/tests/src/Common/external/external.depproj index 46d753c..aedcfe0 100644 --- a/src/coreclr/tests/src/Common/external/external.depproj +++ b/src/coreclr/tests/src/Common/external/external.depproj @@ -12,8 +12,8 @@ win7-x64 true $(TargetingPackPath) - xunit.console.netcore - xunit.runner.console + xunit.runner.console + netcoreapp1.0 SharedLibrary false @@ -45,8 +45,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) @@ -75,7 +75,6 @@ - @@ -84,14 +83,14 @@ $(SourceDir)Common\external\obj\project.assets.json - - + false $(XUnitRunnerPackageId) @@ -99,4 +98,4 @@ - \ No newline at end of file + diff --git a/src/coreclr/tests/src/JIT/Performance/CodeQuality/Layout/SearchLoops.cs b/src/coreclr/tests/src/JIT/Performance/CodeQuality/Layout/SearchLoops.cs index 60684f6..1d2bdaf 100644 --- a/src/coreclr/tests/src/JIT/Performance/CodeQuality/Layout/SearchLoops.cs +++ b/src/coreclr/tests/src/JIT/Performance/CodeQuality/Layout/SearchLoops.cs @@ -47,13 +47,13 @@ namespace Layout } [Benchmark(InnerIterationCount = 20000000)] - public void LoopReturn() + public void LoopReturnIter() { Benchmark.Iterate(() => LoopReturn(test1, test2)); } [Benchmark(InnerIterationCount = 20000000)] - public void LoopGoto() + public void LoopGotoIter() { Benchmark.Iterate(() => LoopGoto(test1, test2)); } diff --git a/src/coreclr/tests/src/JIT/Performance/CodeQuality/SIMD/SeekUnroll/SeekUnroll.cs b/src/coreclr/tests/src/JIT/Performance/CodeQuality/SIMD/SeekUnroll/SeekUnroll.cs index bfa1f43..ed7ec61 100644 --- a/src/coreclr/tests/src/JIT/Performance/CodeQuality/SIMD/SeekUnroll/SeekUnroll.cs +++ b/src/coreclr/tests/src/JIT/Performance/CodeQuality/SIMD/SeekUnroll/SeekUnroll.cs @@ -127,7 +127,7 @@ public static class SeekUnroll // Entrypoint for xunit-perf to call the benchmark [Benchmark] [MemberData(nameof(ArrayedBoxedIndicesToTest))] - public static bool Test(object boxedIndex) + public static bool TestWithXunit(object boxedIndex) { return Test((int)boxedIndex, true); } diff --git a/src/coreclr/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj b/src/coreclr/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj index 563a9a7..881d84f 100644 --- a/src/coreclr/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj +++ b/src/coreclr/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj @@ -82,8 +82,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) diff --git a/src/coreclr/tests/src/JIT/config/benchmark+serialize/benchmark+serialize.csproj b/src/coreclr/tests/src/JIT/config/benchmark+serialize/benchmark+serialize.csproj index d554c16..d2789e5 100644 --- a/src/coreclr/tests/src/JIT/config/benchmark+serialize/benchmark+serialize.csproj +++ b/src/coreclr/tests/src/JIT/config/benchmark+serialize/benchmark+serialize.csproj @@ -79,8 +79,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) diff --git a/src/coreclr/tests/src/JIT/config/benchmark/benchmark.csproj b/src/coreclr/tests/src/JIT/config/benchmark/benchmark.csproj index 4d49fde..aecfdec 100644 --- a/src/coreclr/tests/src/JIT/config/benchmark/benchmark.csproj +++ b/src/coreclr/tests/src/JIT/config/benchmark/benchmark.csproj @@ -97,8 +97,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) diff --git a/src/coreclr/tests/src/TestWrappersConfig/TestWrappersConfig.csproj b/src/coreclr/tests/src/TestWrappersConfig/TestWrappersConfig.csproj deleted file mode 100644 index 7612842..0000000 --- a/src/coreclr/tests/src/TestWrappersConfig/TestWrappersConfig.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Debug - AnyCPU - BuildOnly - false - - - - $(MicrosoftNETCorePlatformsPackageVersion) - - - $(XunitPackageVersion) - - - $(XunitPackageVersion) - - - $(XunitPackageVersion) - - - $(XunitPackageVersion) - - - - netcoreapp1.1;net45 - .NETCoreApp - $(PackageTargetFallback);dnxcore50;portable-net45+win8 - $(TargetRid) - true - false - - - - \ No newline at end of file diff --git a/src/coreclr/tests/src/dir.common.props b/src/coreclr/tests/src/dir.common.props deleted file mode 100644 index dda1755..0000000 --- a/src/coreclr/tests/src/dir.common.props +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - <__BuildArch Condition="'$(__BuildArch)' == ''">x64 - <__BuildType Condition="'$(__BuildType)' == ''">Debug - <__BuildOS Condition="'$(__BuildOS)' == ''">Windows_NT - $(__BuildArch) - $(__BuildType) - $(__BuildOS) - $(BuildType) - $(BuildArch) - - - - - true - false - full - $(DefineConstants);DEBUG;TRACE;XUNIT_PERF - - - true - true - pdbonly - $(DefineConstants);TRACE;XUNIT_PERF - - - true - true - full - $(DefineConstants);DEBUG;TRACE;XUNIT_PERF - - - - - 64 - 64 - 32 - 32 - - - - - $(BuildOS).$(Platform).$(Configuration) - $(ProjectDir)\..\bin\tests - $(__TestRootDir) - $(BaseOutputPath)\$(OSPlatformConfig)\ - $(BaseOutputPathWithConfig) - $(ProjectDir)\..\bin\tests\obj\$(OSPlatformConfig)\Managed\ - $(__ManagedTestIntermediatesDir)\ - <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == ''">$([System.IO.Path]::GetFullPath($(BaseOutputPathWithConfig)..\obj\$(BuildOS).$(Platform).$(Configuration)\Native\)) - $(MSBuildProjectName)\ - $([System.String]::Copy('$(MSBuildProjectDirectory)').Replace($(SourceDir),''))\$(MSBuildProjectName) - $(BaseIntermediateOutputPath)$(BuildProjectRelativeDir)\ - $(BaseOutputPathWithConfig)$(BuildProjectRelativeDir)\ - $(BaseOutputPath)\testStagingDir\ - $(TestWorkingDir)$(OSPlatformConfig)\$(MSBuildProjectName)/ - - - - diff --git a/src/coreclr/tests/src/dir.props b/src/coreclr/tests/src/dir.props index 925e3fa..f3f229d 100644 --- a/src/coreclr/tests/src/dir.props +++ b/src/coreclr/tests/src/dir.props @@ -1,5 +1,52 @@ - + + + + + + + true + false + full + $(DefineConstants);DEBUG;TRACE;XUNIT_PERF + + + true + true + pdbonly + $(DefineConstants);TRACE;XUNIT_PERF + + + true + true + full + $(DefineConstants);DEBUG;TRACE;XUNIT_PERF + + + + + 64 + 64 + 32 + 32 + + + + + $(ProjectDir)\..\bin\tests + $(__TestRootDir) + $(BaseOutputPath)\$(OSPlatformConfig)\ + $(BaseOutputPathWithConfig) + $(ProjectDir)\..\bin\tests\obj\$(OSPlatformConfig)\Managed\ + $(__ManagedTestIntermediatesDir)\ + <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == ''">$([System.IO.Path]::GetFullPath($(BaseOutputPathWithConfig)..\obj\$(BuildOS).$(Platform).$(Configuration)\Native\)) + $(MSBuildProjectName)\ + $([System.String]::Copy('$(MSBuildProjectDirectory)').Replace($(SourceDir),''))\$(MSBuildProjectName) + $(BaseIntermediateOutputPath)$(BuildProjectRelativeDir)\ + $(BaseOutputPathWithConfig)$(BuildProjectRelativeDir)\ + $(BaseOutputPath)\testStagingDir\ + $(TestWorkingDir)$(OSPlatformConfig)\$(MSBuildProjectName)/ + @@ -11,8 +58,6 @@ 78,162,164,168,169,219,251,252,414,429,642,649,652,675,1691,1717,1718,3001,3002,3003,3005,3008 false true - - $(MSBuildThisFileDirectory)TestWrappersConfig\ Test diff --git a/src/coreclr/tests/src/dirs.proj b/src/coreclr/tests/src/dirs.proj index 58c3559..785a058 100644 --- a/src/coreclr/tests/src/dirs.proj +++ b/src/coreclr/tests/src/dirs.proj @@ -16,8 +16,7 @@ - - + diff --git a/src/coreclr/tests/src/performance/performance.csproj b/src/coreclr/tests/src/performance/performance.csproj index 94caf35..c6c0b5c 100644 --- a/src/coreclr/tests/src/performance/performance.csproj +++ b/src/coreclr/tests/src/performance/performance.csproj @@ -94,8 +94,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) diff --git a/src/coreclr/tests/tests.targets b/src/coreclr/tests/tests.targets index 8f00fd7..9a16cb0 100644 --- a/src/coreclr/tests/tests.targets +++ b/src/coreclr/tests/tests.targets @@ -1,8 +1,6 @@ - - <_SkipTestAssemblies Include="$(SkipTestAssemblies)" /> @@ -26,10 +24,6 @@ - - @@ -37,20 +31,28 @@ category=outerloop;category=failing - true + all - + + + $(CORE_ROOT)\xunit.console.dll + + -parallel $(ParallelRun) + $(XunitArgs) -html $(__TestRunHtmlLog) + $(XunitArgs) -xml $(__TestRunXmlLog) + $(XunitArgs) @(IncludeTraitsItems->'-trait %(Identity)', ' ') + $(XunitArgs) @(ExcludeTraitsItems->'-notrait %(Identity)', ' ') + + $(CORE_ROOT)\corerun + $(CORE_ROOT)\corerun.exe + $(CorerunExecutable) $(XunitConsoleRunner) @(TestAssemblies->'%(Identity)', ' ') $(XunitArgs) + + diff --git a/src/coreclr/tests/xunitwrapper.targets b/src/coreclr/tests/xunitwrapper.targets deleted file mode 100644 index a0ff7f5..0000000 --- a/src/coreclr/tests/xunitwrapper.targets +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - <_ProjectReferenceFilenames Include="@(_ResolvedProjectReferencePaths->'%(FileName)%(Extension)')"> - %(Identity) - - - <_ReferencesFileNames Include="@(Reference->'%(FileName)%(Extension)')"> - %(Identity) - - - <_CopyLocalFileNames Include="@(CopyLocal->'%(FileName)%(Extension)')"> - %(Identity) - - - - <_ReferenceFileNamesToRemove Include="@(_ReferencesFileNames->'%(OriginalIdentity)')" Condition="'@(_ProjectReferenceFilenames)' == '@(_ReferencesFileNames)' and '%(Identity)' != ''"/> - <_CopyLocalFileNamesToRemove Include="@(_CopyLocalFileNames->'%(OriginalIdentity)')" Condition="'@(_ProjectReferenceFilenames)' == '@(_CopyLocalFileNames)' and '%(Identity)' != ''"/> - - - - - - - - - - - - - - -- 2.7.4