Skip to content

Commit

Permalink
Fix build-test.sh wrapper build (dotnet#19779)
Browse files Browse the repository at this point in the history
* Fix build-test.sh wrapper build

In addition this change creates a json file with the build info so that the wrapper build
may be skipped if it was built on the same os/arch/buildtype.

* Address pr feedback
  • Loading branch information
Jarret Shook authored Aug 31, 2018
1 parent 3b80794 commit 6de8d61
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
2 changes: 2 additions & 0 deletions build-test.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 =========================================================================================
Expand Down
31 changes: 24 additions & 7 deletions build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -612,6 +629,7 @@ __SourceDir="$__ProjectDir/src"
__PackagesDir="$__ProjectDir/packages"
__RootBinDir="$__ProjectDir/bin"
__BuildToolsDir="$__ProjectDir/Tools"
__DotNetCli="${__BuildToolsDir}/dotnetcli/dotnet"
__UnprocessedBuildArgs=
__RunArgs=
__MSBCleanBuildArgs=
Expand Down Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions tests/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 7 additions & 16 deletions tests/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function print_usage {
echo ' --tieredcompilation : Runs the tests with COMPlus_TieredCompilation=1'
echo ' --link <ILlink> : Runs the tests after linking via ILlink'
echo ' --xunitOutputPath=<path> : Create xUnit XML report at the specifed path (default: <test root>/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 '
Expand Down Expand Up @@ -219,7 +219,7 @@ verbose=0
doCrossgen=0
jitdisasm=0
ilasmroundtrip=
skipXunitWrapperBuild=
buildXUnitWrappers=
printLastResultsOnly=
generateLayoutOnly=
generateLayout=
Expand Down Expand Up @@ -255,8 +255,8 @@ do
release|Release)
buildConfiguration="Release"
;;
--skipXunitWrapperBuild)
skipXunitWrapperBuild=1
--buildXUnitWrappers)
buildXUnitWrappers=1
;;
--printLastResultsOnly)
printLastResultsOnly=1
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6de8d61

Please sign in to comment.