diff --git a/build-test.cmd b/build-test.cmd index 18100515b2ae..361a3f8c3106 100644 --- a/build-test.cmd +++ b/build-test.cmd @@ -482,6 +482,8 @@ if errorlevel 1 ( exit /b 1 ) +echo { "build_os": "%__BuildOS%", "build_arch": "%__BuildArch%", "build_type": "%__BuildType%" } > "%__TestBinDir%/build_info.json" + :SkipBuildingWrappers REM ========================================================================================= diff --git a/build-test.sh b/build-test.sh index 7ae045be8b92..b7feaa498f6c 100755 --- a/build-test.sh +++ b/build-test.sh @@ -203,6 +203,10 @@ build_Tests() __ProjectFilesDir=$__TestDir __TestBinDir=$__TestWorkingDir + if [ -f "${__TestWorkingDir}/build_info.json" ]; then + rm "${__TestWorkingDir}/build_info.json" + fi + if [ $__RebuildTests -ne 0 ]; then if [ -d "${__TestBinDir}" ]; then echo "Removing tests build dir: ${__TestBinDir}" @@ -289,18 +293,31 @@ build_Tests() if [ $__BuildTestWrappers -ne -0 ]; then echo "${__MsgPrefix}Creating test wrappers..." - # Always create the test wrappers and set the exclude file. - export __Exclude="$__TestDir/issues.targets" - echo "Exclude set to $__TestDir/issues.targets" - build_MSBuild_projects "Tests_XunitWrapper" "$__ProjectDir/tests/runtest.proj" "Test Xunit Wrapper" "-BuildWrappers" "-MsBuildEventLogging= " "-TargetsWindows=false" + export __Exclude="${__ProjectDir}/tests/issues.targets" + export __BuildLogRootName="Tests_XunitWrapper" + + # Set up directories and file names + __BuildLogRootName=$subDirectoryName + __BuildLog="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.log" + __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn" + __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err" + + buildVerbosity="Summary" + + if [ $__VerboseBuild == 1 ]; then + buildVerbosity="Diag" + fi + + echo "${__DotNetCli}" msbuild "${__ProjectDir}/tests/runtest.proj" /p:RestoreAdditionalProjectSources=https://dotnet.myget.org/F/dotnet-core/ /p:BuildWrappers=true /p:TargetsWindows=false /fileloggerparameters:"\"Verbosity=normal;LogFile=${__BuildLog}\"" /fileloggerparameters1:"\"WarningsOnly;LogFile=${__BuildWrn}\"" /fileloggerparameters2:"\"ErrorsOnly;LogFile=${__BuildErr}\"" /consoleloggerparameters:$buildVerbosity /p:__BuildOS=$__BuildOS /p:__BuildType=$__BuildType /p:__BuildArch=$__BuildArch + "${__DotNetCli}" msbuild "${__ProjectDir}/tests/runtest.proj" /p:RestoreAdditionalProjectSources=https://dotnet.myget.org/F/dotnet-core/ /p:BuildWrappers=true /p:TargetsWindows=false /fileloggerparameters:"\"Verbosity=normal;LogFile=${__BuildLog}\"" /fileloggerparameters1:"\"WarningsOnly;LogFile=${__BuildWrn}\"" /fileloggerparameters2:"\"ErrorsOnly;LogFile=${__BuildErr}\"" /consoleloggerparameters:$buildVerbosity /p:__BuildOS=$__BuildOS /p:__BuildType=$__BuildType /p:__BuildArch=$__BuildArch if [ $? -ne 0 ]; then echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)" exit 1 else echo "XUnit Wrappers have been built." - echo "Create marker \"${__XUnitWrapperBuiltMarker}\"" - touch $__XUnitWrapperBuiltMarker + echo { "\"build_os\"": "\"${__BuildOS}\"", "\"build_arch\"": "\"${__BuildArch}\"", "\"build_type\"": "\"${__BuildType}\"" } > "${__TestWorkingDir}/build_info.json" + fi fi @@ -612,6 +629,7 @@ __SourceDir="$__ProjectDir/src" __PackagesDir="$__ProjectDir/packages" __RootBinDir="$__ProjectDir/bin" __BuildToolsDir="$__ProjectDir/Tools" +__DotNetCli="${__BuildToolsDir}/dotnetcli/dotnet" __UnprocessedBuildArgs= __RunArgs= __MSBCleanBuildArgs= @@ -862,7 +880,6 @@ initHostDistroRid # Set the remaining variables based upon the determined build configuration __BinDir="$__RootBinDir/Product/$__BuildOS.$__BuildArch.$__BuildType" __PackagesBinDir="$__BinDir/.nuget" -__ToolsDir="$__RootBinDir/tools" __TestDir="$__ProjectDir/tests" __TestWorkingDir="$__RootBinDir/tests/$__BuildOS.$__BuildArch.$__BuildType" __IntermediatesDir="$__RootBinDir/obj/$__BuildOS.$__BuildArch.$__BuildType" diff --git a/tests/runtest.py b/tests/runtest.py index 36f3f8ef8cd8..bd45d1118b1b 100755 --- a/tests/runtest.py +++ b/tests/runtest.py @@ -1914,6 +1914,23 @@ def do_setup(host_os, if unprocessed_args.build_test_wrappers: build_test_wrappers(host_os, arch, build_type, coreclr_repo_location, test_location) + else: + # We will write out build information into the test directory. This is used + # by runtest.py to determine whether we need to rebuild the test wrappers. + if os.path.isfile(os.path.join(test_location, "build_info.json")): + build_info = None + with open(os.path.join(test_location, "build_info.json")) as file_handle: + build_info = json.load(file_handle) + + is_same_os = build_info["build_os"] == host_os + is_same_arch = build_info["build_arch"] == arch + is_same_build_type = build_info["build_type"] == build_type + + # We will force a build of the test wrappers if they were cross built + if not (is_same_os and is_same_arch and is_same_build_type): + build_test_wrappers(host_os, arch, build_type, coreclr_repo_location, test_location) + else: + build_test_wrappers(host_os, arch, build_type, coreclr_repo_location, test_location) run_tests(host_os, arch, diff --git a/tests/runtest.sh b/tests/runtest.sh index 614692e4f83a..09170947109d 100755 --- a/tests/runtest.sh +++ b/tests/runtest.sh @@ -40,7 +40,7 @@ function print_usage { echo ' --tieredcompilation : Runs the tests with COMPlus_TieredCompilation=1' echo ' --link : Runs the tests after linking via ILlink' echo ' --xunitOutputPath= : Create xUnit XML report at the specifed path (default: /coreclrtests.xml)' - echo ' --skipXunitWrapperBuild : Skip creating the xunit wrapper' + echo ' --buildXUnitWrappers : Force creating the xunit wrappers, this is useful if there have been changes to issues.targets' echo ' --printLastResultsOnly : Print the results of the last run' echo '' echo 'CoreFX Test Options ' @@ -219,7 +219,7 @@ verbose=0 doCrossgen=0 jitdisasm=0 ilasmroundtrip= -skipXunitWrapperBuild= +buildXUnitWrappers= printLastResultsOnly= generateLayoutOnly= generateLayout= @@ -255,8 +255,8 @@ do release|Release) buildConfiguration="Release" ;; - --skipXunitWrapperBuild) - skipXunitWrapperBuild=1 + --buildXUnitWrappers) + buildXUnitWrappers=1 ;; --printLastResultsOnly) printLastResultsOnly=1 @@ -515,20 +515,11 @@ if [ ! -z "$ilasmroundtrip" ]; then runtestPyArguments+=("--ilasmroundtrip") fi -if [ ! -z "$skipXunitWrapperBuild" ]; then +if [ ! -z "$buildXUnitWrappers" ]; then + runtestPyArguments+=("--build_xunit_test_wrappers") +else echo "Skipping xunit wrapper build. If build-test was called on a different" echo "host_os or arch the test run will most likely have failures." -else - # By default rebuild the test wrappers, as we cannot gaurentee the following - # is true: - # 1) There are no added or removed excludes since the tests were built - # 2) That the wrapper generation happened on the same host_os and arch - # as where we are running now - # - # Note that the wrapper generation is slow. To skip this pass --skipXunitWrapperBuild - # if the above requirements are met. - - runtestPyArguments+=("--build_xunit_test_wrappers") fi if (($verbose!=0)); then