[llvm-commits] [LNT] r166901 - /lnt/trunk/lnt/tests/nt.py
Daniel Dunbar
daniel at zuster.org
Sun Oct 28 14:23:29 PDT 2012
Author: ddunbar
Date: Sun Oct 28 16:23:29 2012
New Revision: 166901
URL: http://llvm.org/viewvc/llvm-project?rev=166901&view=rev
Log:
lnt.tests.nt: Validate --cc and --cxx options a bit better.
Modified:
lnt/trunk/lnt/tests/nt.py
Modified: lnt/trunk/lnt/tests/nt.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/nt.py?rev=166901&r1=166900&r2=166901&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/nt.py (original)
+++ lnt/trunk/lnt/tests/nt.py Sun Oct 28 16:23:29 2012
@@ -50,6 +50,20 @@
###
+def resolve_command_path(name):
+ # If the given name exists (or is a path), make it absolute.
+ if os.path.exists(name):
+ return os.path.abspath(name)
+
+ # Otherwise we most likely have a command name, try to look it up.
+ path = which(name)
+ if path is not None:
+ note("resolved command %r to path %r" % (name, path))
+ return path
+
+ # If that failed just return the original name.
+ return name
+
def scan_for_test_modules(opts):
base_modules_path = os.path.join(opts.test_suite_root, 'LNTBased')
if opts.only_test is None:
@@ -1188,6 +1202,9 @@
if opts.cc_under_test is None:
parser.error('--cc is required')
+ # Resolve the cc_under_test path.
+ opts.cc_under_test = resolve_command_path(opts.cc_under_test)
+
# If there was no --cxx given, attempt to infer it from the --cc.
if opts.cxx_under_test is None:
opts.cxx_under_test = lnt.testing.util.compilers.infer_cxx_compiler(
@@ -1200,11 +1217,22 @@
if opts.test_cxx and opts.cxx_under_test is None:
parser.error('--cxx is required')
+ if opts.cxx_under_test is not None:
+ opts.cxx_under_test = resolve_command_path(opts.cxx_under_test)
+
# Always set cxx_under_test, since it may be used as the linker even
# when not testing C++ code.
if opts.cxx_under_test is None:
opts.cxx_under_test = opts.cc_under_test
+ # Validate that the compilers under test exist.
+ if not os.path.exists(opts.cc_under_test):
+ parser.error("invalid --cc argument %r, does not exist" % (
+ opts.cc_under_test))
+ if not os.path.exists(opts.cxx_under_test):
+ parser.error("invalid --cxx argument %r, does not exist" % (
+ opts.cxx_under_test))
+
# FIXME: As a hack to allow sampling old Clang revisions, if we are
# given a C++ compiler that doesn't exist, reset it to just use the
# given C compiler.
More information about the llvm-commits
mailing list