[Lldb-commits] [PATCH] D85258: [test] Use realpath consistently for test root file paths.

Jordan Rupprecht via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 5 11:36:14 PDT 2020


This revision was automatically updated to reflect the committed changes.
rupprecht marked an inline comment as done.
Closed by commit rGfcb0d8163a4f: [lldb/test] Use realpath consistently for test root file paths. (authored by rupprecht).

Changed prior to commit:
  https://reviews.llvm.org/D85258?vs=283060&id=283316#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85258/new/

https://reviews.llvm.org/D85258

Files:
  lldb/packages/Python/lldbsuite/__init__.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/use_lldb_suite.py


Index: lldb/test/API/use_lldb_suite.py
===================================================================
--- lldb/test/API/use_lldb_suite.py
+++ lldb/test/API/use_lldb_suite.py
@@ -4,9 +4,8 @@
 
 
 def find_lldb_root():
-    lldb_root = os.path.dirname(
-        os.path.abspath(inspect.getfile(inspect.currentframe()))
-    )
+    lldb_root = os.path.realpath(
+        os.path.dirname(inspect.getfile(inspect.currentframe())))
     while True:
         parent = os.path.dirname(lldb_root)
         if parent == lldb_root: # dirname('/') == '/'
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -496,8 +496,12 @@
             mydir = TestBase.compute_mydir(__file__)
         '''
         # /abs/path/to/packages/group/subdir/mytest.py -> group/subdir
-        rel_prefix = test_file[len(configuration.test_src_root) + 1:]
-        return os.path.dirname(rel_prefix)
+        lldb_test_src = configuration.test_src_root
+        if not test_file.startswith(lldb_test_src):
+          raise Exception(
+              "Test file '%s' must reside within lldb_test_src "
+              "(which is '%s')." % (test_file, lldb_test_src))
+        return os.path.dirname(os.path.relpath(test_file, start=lldb_test_src))
 
     def TraceOn(self):
         """Returns True if we are in trace mode (tracing detailed test execution)."""
Index: lldb/packages/Python/lldbsuite/__init__.py
===================================================================
--- lldb/packages/Python/lldbsuite/__init__.py
+++ lldb/packages/Python/lldbsuite/__init__.py
@@ -6,7 +6,8 @@
 
 
 def find_lldb_root():
-    lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+    lldb_root = os.path.realpath(
+        os.path.dirname(inspect.getfile(inspect.currentframe())))
     while True:
         parent = os.path.dirname(lldb_root)
         if parent == lldb_root: # dirname('/') == '/'


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85258.283316.patch
Type: text/x-patch
Size: 2056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200805/08138501/attachment-0001.bin>


More information about the lldb-commits mailing list