[Lldb-commits] [PATCH] D85175: [test] Use abspath instead of realpath sometimes

Jordan Rupprecht via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 3 17:41:31 PDT 2020


rupprecht created this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
rupprecht requested review of this revision.
Herald added a subscriber: JDevlieghere.

In these two cases, use of `os.path.realpath` is problematic:

- The name of the compiler is significant [1] . For testing purposes, we might provide a compiler called "clang" which is actually a symlink to some build script (which does some flag processing before invoking the real clang). The destination the symlink may not be called "clang", but we still want it to be treated as such.
- When using a build system that puts build artifacts in an arbitrary build location, and later creates a symlink for it (e.g. creates a "<lldb root>/lldbsuite/test/dotest.py" symlinks that points to "/build/artifact/<hash>/dotest.py"), looking at the realpath will not match the "test" convention required here.

[1] See `Makefile.rules` in the lldb tree, e.g. we use different flags if the compiler is named "clang"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85175

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -241,7 +241,7 @@
         do_help = True
 
     if args.compiler:
-        configuration.compiler = os.path.realpath(args.compiler)
+        configuration.compiler = os.path.abspath(args.compiler)
         if not is_exe(configuration.compiler):
             configuration.compiler = which(args.compiler)
         if not is_exe(configuration.compiler):
@@ -461,7 +461,7 @@
     if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
         scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
     else:
-        scriptPath = os.path.dirname(os.path.realpath(__file__))
+        scriptPath = os.path.dirname(os.path.abspath(__file__))
     if not scriptPath.endswith('test'):
         print("This script expects to reside in lldb's test directory.")
         sys.exit(-1)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85175.282777.patch
Type: text/x-patch
Size: 1007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200804/29462a5e/attachment.bin>


More information about the lldb-commits mailing list