[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 4 23:39:26 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Igor Kudrin (igorkudrin)

<details>
<summary>Changes</summary>

The decorators caused the main test, i.e. `test_set_use_source_cache_true()`, to be skipped in most scenarios. It was only run on a Windows host targeting a non-Windows remote platform, and it failed in this case because the source file is opened with the `FILE_SHARE_DELETE` share mode, which allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()` in `llvm/lib/Support/Windows/Path.inc`.

This patch changes the test to check that the content can still be displayed, even after deleting the file, when the source cache is enabled. The updated test is expected to pass on any platform, so the decorators are removed.

---
Full diff: https://github.com/llvm/llvm-project/pull/111237.diff


1 Files Affected:

- (modified) lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py (+4-7) 


``````````diff
diff --git a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index 421599080a9e51..421b13f253f05b 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self):
         """Test that after 'set use-source-cache false', files are not locked."""
         self.set_use_source_cache_and_test(False)
 
-    @skipIf(hostoslist=no_match(["windows"]))
-    @skipIf(oslist=["windows"])  # Fails on windows 11
     def test_set_use_source_cache_true(self):
         """Test that after 'set use-source-cache false', files are locked."""
         self.set_use_source_cache_and_test(True)
@@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled):
             self, "calc"
         )
 
-        # Show the source file contents to make sure LLDB loads src file.
-        self.runCmd("source list")
+        # Ensure that the source file is loaded.
+        self.expect("step", patterns=["-> .+ int x4 ="])
 
         # Try deleting the source file.
         is_file_removed = self.removeFile(src)
 
         if is_cache_enabled:
-            self.assertFalse(
-                is_file_removed, "Source cache is enabled, but delete file succeeded"
-            )
+            # Regardless of whether the file is removed, its contents should be displayed.
+            self.expect("step", patterns=["-> .+ int x5 ="])
 
         if not is_cache_enabled:
             self.assertTrue(

``````````

</details>


https://github.com/llvm/llvm-project/pull/111237


More information about the lldb-commits mailing list