Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up test intermediates when clean test rebuild is requested #62001

Merged
merged 2 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/tests/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions src/tests/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a preceding:

if [[ -d "${__TestIntermediatesDir}" ]]; then

? Or will rm -rf not complain if it doesn't exist? Of course, if __TestBinDir exists, it will essentially always exist anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Bruce for pointing that out. I have locally verified that rm -rf has no trouble with non-existent folders so I just removed the pre-existing condition instead of introducing a new one.

rm -rf "${__TestIntermediatesDir}"
fi
fi

Expand Down