Skip to content

Commit

Permalink
Remove undeclared test outputs after zipping on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Dec 13, 2022
1 parent ccd8f48 commit 743e71f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/test/py/bazel/bazel_windows_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,7 @@ def testZipUndeclaredTestOutputs(self):
'//:foo_test',
], )
self.AssertExitCode(exit_code, 0, stderr)
# FIXME: The Windows test runner does not delete the undeclared outputs
# after zipping, which differs from the behavior on other platforms.
self.assertTrue(os.path.exists(output_file))
self.assertFalse(os.path.exists(output_file))
self.assertTrue(os.path.exists(output_zip))

# Run the test without undeclared outputs zipping.
Expand Down
15 changes: 14 additions & 1 deletion tools/test/windows/tw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,18 @@ bool StartSubprocess(const Path& path, const std::wstring& args,
return true;
}

bool RemoveRelativeRecursively(const Path& root,
const std::vector<FileInfo>& files) {
Path path;
for (const auto& file : files) {
if (!(path.Set(file.RelativePath()) && path.Absolutize(root)
&& RemoveRecursively(::blaze_util::WstringToCstring(path.Get())))) {
return false;
}
}
return true;
}

bool ArchiveUndeclaredOutputs(const UndeclaredOutputs& undecl) {
if (undecl.root.Get().empty() || undecl.zip.Get().empty()) {
// TEST_UNDECLARED_OUTPUTS_DIR was undefined, so there's nothing to archive,
Expand All @@ -1309,7 +1321,8 @@ bool ArchiveUndeclaredOutputs(const UndeclaredOutputs& undecl) {
return GetFileListRelativeTo(undecl.root, &files) &&
(files.empty() ||
(CreateZip(undecl.root, files, undecl.zip) &&
CreateUndeclaredOutputsManifest(files, undecl.manifest)));
CreateUndeclaredOutputsManifest(files, undecl.manifest) &&
RemoveRelativeRecursively(files)));
}

// Creates the Undeclared Outputs Annotations file.
Expand Down

0 comments on commit 743e71f

Please sign in to comment.