Skip to content

Commit

Permalink
Add chmod to make file removal after tests more reliable.
Browse files Browse the repository at this point in the history
MacOS does not allow files to be removed recursively unless the owner has write and execute permissions on all the directories.

Some tests leave the permissions in a bad state so fix them up before trying to delete.
  • Loading branch information
dwsteele committed Jan 24, 2021
1 parent 04e84da commit ef2dc6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/lib/pgBackRestTest/Common/JobTest.pm
Expand Up @@ -701,7 +701,7 @@ sub end
containerRemove("test-$self->{iVmIdx}");
}

executeTest("rm -rf ${strHostTestPath}");
executeTest("chmod -R 700 ${strHostTestPath}/* 2>&1;rm -rf ${strHostTestPath}");
}

$bDone = true;
Expand Down
8 changes: 6 additions & 2 deletions test/src/common/harnessTest.c
Expand Up @@ -169,7 +169,9 @@ testBegin(const char *name)

// Clear out the test directory so the next test starts clean
char buffer[2048];
snprintf(buffer, sizeof(buffer), "%srm -rf %s/" "*", testContainer() ? "sudo " : "", testPath());
snprintf(
buffer, sizeof(buffer), "%schmod -R 700 %s/" "*;%srm -rf %s/" "*", testContainer() ? "sudo " : "", testPath(),
testContainer() ? "sudo " : "", testPath());

if (system(buffer) != 0)
{
Expand All @@ -179,7 +181,9 @@ testBegin(const char *name)
}

// Clear out the data directory so the next test starts clean
snprintf(buffer, sizeof(buffer), "%srm -rf %s/" "*", testContainer() ? "sudo " : "", testDataPath());
snprintf(
buffer, sizeof(buffer), "%schmod -R 700 %s/" "*;%srm -rf %s/" "*", testContainer() ? "sudo " : "",
testDataPath(), testContainer() ? "sudo " : "", testDataPath());

if (system(buffer) != 0)
{
Expand Down

0 comments on commit ef2dc6d

Please sign in to comment.