diff --git a/src/test/py/bazel/bazel_windows_test.py b/src/test/py/bazel/bazel_windows_test.py index d9dc71e8c31aad..92f986ffd9b11f 100644 --- a/src/test/py/bazel/bazel_windows_test.py +++ b/src/test/py/bazel/bazel_windows_test.py @@ -434,9 +434,7 @@ def testZipUndeclaredTestOutputs(self): ], ) 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. diff --git a/tools/test/windows/tw.cc b/tools/test/windows/tw.cc index 8d5f61c4a3d915..2992acf2129d10 100644 --- a/tools/test/windows/tw.cc +++ b/tools/test/windows/tw.cc @@ -1297,6 +1297,19 @@ bool StartSubprocess(const Path& path, const std::wstring& args, return true; } +bool RemoveRelativeRecursively(const Path& root, + const std::vector& files) { + Path path; + for (const auto& file : files) { + if (!(path.Set(file.RelativePath()) && path.Absolutize(root) && + blaze_util::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, @@ -1306,10 +1319,15 @@ bool ArchiveUndeclaredOutputs(const UndeclaredOutputs& undecl) { } std::vector files; - return GetFileListRelativeTo(undecl.root, &files) && - (files.empty() || - (CreateZip(undecl.root, files, undecl.zip) && - CreateUndeclaredOutputsManifest(files, undecl.manifest))); + if (!GetFileListRelativeTo(undecl.root, &files)) { + return false; + } + if (files.empty()) { + return true; + } + return CreateZip(undecl.root, files, undecl.zip) && + CreateUndeclaredOutputsManifest(files, undecl.manifest) && + RemoveRelativeRecursively(undecl.root, files); } // Creates the Undeclared Outputs Annotations file.