aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Lee <davelee.com@gmail.com>2022-11-11 14:32:04 -0800
committerDave Lee <davelee.com@gmail.com>2022-11-11 16:07:38 -0800
commit5223366416fbde8ac5d53c586c985bffac9cb168 (patch)
tree4eb42042613cd8010ddc457ba7aac8dede7526aa
parent4d25761b076d19c237890ad7b7331d01bd3a84b6 (diff)
downloadllvm-5223366416fbde8ac5d53c586c985bffac9cb168.zip
llvm-5223366416fbde8ac5d53c586c985bffac9cb168.tar.gz
llvm-5223366416fbde8ac5d53c586c985bffac9cb168.tar.bz2
[lldb] Fix SBFileSpec.fullpath for Windows
Fix `fullpath` to not assume a `/` path separator. This was discovered when D133130 failed on Windows. Use `os.path.join()` to fix the issue. Reviewed By: mib Differential Revision: https://reviews.llvm.org/D133366
-rw-r--r--lldb/bindings/interface/SBFileSpec.i2
-rw-r--r--lldb/test/API/python_api/file_spec/TestFileSpecAPI.py15
2 files changed, 16 insertions, 1 deletions
diff --git a/lldb/bindings/interface/SBFileSpec.i b/lldb/bindings/interface/SBFileSpec.i
index b549321..1043394 100644
--- a/lldb/bindings/interface/SBFileSpec.i
+++ b/lldb/bindings/interface/SBFileSpec.i
@@ -88,7 +88,7 @@ public:
spec_dir = self.GetDirectory()
spec_file = self.GetFilename()
if spec_dir and spec_file:
- return '%s/%s' % (spec_dir, spec_file)
+ return os.path.join(spec_dir, spec_file)
elif spec_dir:
return spec_dir
elif spec_file:
diff --git a/lldb/test/API/python_api/file_spec/TestFileSpecAPI.py b/lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
new file mode 100644
index 0000000..6c074df
--- /dev/null
+++ b/lldb/test/API/python_api/file_spec/TestFileSpecAPI.py
@@ -0,0 +1,15 @@
+import lldb
+import os
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCase(TestBase):
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_full_path(self):
+ file_spec = lldb.SBFileSpec()
+ file_spec.SetDirectory("a")
+ file_spec.SetFilename("b")
+ self.assertEqual(file_spec.fullpath, os.path.join("a", "b"))