From 7aa6ef34b1cd59402166e5ed50ee2aeecbe2c6b5 Mon Sep 17 00:00:00 2001 From: Tomas Rylek Date: Wed, 24 Nov 2021 01:30:30 +0100 Subject: [PATCH 1/2] Clean up test intermediates when clean test rebuild is requested I hit this problem locally when working on the test merging - I made a change in Jeremy's Roslyn generator logic adding a hard FailFast and the tests continued building normally even when specifying the rebuild option because the XUnitWrapperGenerator project remained in the intermediate test folder and didn't get actually rebuilt. Thanks Tomas --- src/tests/build.cmd | 4 +++- src/tests/build.sh | 15 ++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/tests/build.cmd b/src/tests/build.cmd index 9e0cf478808f95..18dd4ee6266e6d 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -146,8 +146,10 @@ set "__TestBinDir=%__TestRootDir%\%__OSPlatformConfig%" set "__TestIntermediatesDir=%__TestRootDir%\obj\%__OSPlatformConfig%" if "%__RebuildTests%" == "1" ( - echo Removing tests build dir^: !__TestBinDir! + echo Removing test build dir^: !__TestBinDir! rmdir /s /q !__TestBinDir! + echo Removing test intermediate dir^: !__TestIntermediatesDir! + rmdir /s /q !__TestIntermediatesDir! ) REM We have different managed and native intermediate dirs because the managed bits will include diff --git a/src/tests/build.sh b/src/tests/build.sh index a462005fc21231..96f2b32d7f5f04 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -5,11 +5,10 @@ build_Tests() echo "${__MsgPrefix}Building Tests..." __ProjectFilesDir="$__TestDir" - __TestBinDir="$__TestWorkingDir" __Exclude="$__RepoRootDir/src/tests/issues.targets" - if [[ -f "${__TestWorkingDir}/build_info.json" ]]; then - rm "${__TestWorkingDir}/build_info.json" + if [[ -f "${__TestBinDir}/build_info.json" ]]; then + rm "${__TestBinDir}/build_info.json" fi if [[ "$__RebuildTests" -ne 0 ]]; then @@ -363,7 +362,7 @@ __OSPlatformConfig="$__TargetOS.$__BuildArch.$__BuildType" __BinDir="$__RootBinDir/bin/coreclr/$__OSPlatformConfig" __PackagesBinDir="$__BinDir/.nuget" __TestDir="$__RepoRootDir/src/tests" -__TestWorkingDir="$__RootBinDir/tests/coreclr/$__OSPlatformConfig" +__TestBinDir="$__RootBinDir/tests/coreclr/$__OSPlatformConfig" __IntermediatesDir="$__RootBinDir/obj/coreclr/$__OSPlatformConfig" __TestIntermediatesDir="$__RootBinDir/tests/coreclr/obj/$__OSPlatformConfig" __CrossCompIntermediatesDir="$__IntermediatesDir/crossgen" @@ -382,9 +381,11 @@ if [[ -z "$HOME" ]]; then fi if [[ "$__RebuildTests" -ne 0 ]]; then - if [[ -d "${__TestWorkingDir}" ]]; then - echo "Removing tests build dir: ${__TestWorkingDir}" - rm -rf "${__TestWorkingDir}" + if [[ -d "${__TestBinDir}" ]]; then + echo "Removing test build dir: ${__TestBinDir}" + rm -rf "${__TestBinDir}" + echo "Removing test intermediate dir: ${__TestIntermediatesDir}" + rm -rf "${__TestIntermediatesDir}" fi fi From b573a17991e21a19d11b2890cfffe1911377f7b4 Mon Sep 17 00:00:00 2001 From: Tomas Rylek Date: Wed, 24 Nov 2021 01:56:49 +0100 Subject: [PATCH 2/2] Remove superfluous conditional section on Unix per Bruce's feedback I have double-checked locally that Unix has no problem whatsoever with rm -rf on a non-existent directory. For this reason I have removed the pre-existing conditional block instead of creating a new one to cater for the intermediate folder. Thanks Tomas --- src/tests/build.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/tests/build.sh b/src/tests/build.sh index 96f2b32d7f5f04..35a309242f26a2 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -381,12 +381,10 @@ if [[ -z "$HOME" ]]; then fi if [[ "$__RebuildTests" -ne 0 ]]; then - if [[ -d "${__TestBinDir}" ]]; then - echo "Removing test build dir: ${__TestBinDir}" - rm -rf "${__TestBinDir}" - echo "Removing test intermediate dir: ${__TestIntermediatesDir}" - rm -rf "${__TestIntermediatesDir}" - fi + echo "Removing test build dir: ${__TestBinDir}" + rm -rf "${__TestBinDir}" + echo "Removing test intermediate dir: ${__TestIntermediatesDir}" + rm -rf "${__TestIntermediatesDir}" fi build_Tests