kAvoidDevNull = kIsWindows
def executeCommand(command, cwd=None, env=None):
+ # Close extra file handles on UNIX (on Windows this cannot be done while
+ # also redirecting input).
+ close_fds = not kIsWindows
+
p = subprocess.Popen(command, cwd=cwd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
- env=env)
+ env=env, close_fds=close_fds)
out,err = p.communicate()
exitCode = p.wait()
return executeCommand(command, cwd=cwd, env=test.config.environment)
-def isExpectedFail(xfails, xtargets, target_triple):
- # Check if any xfail matches this target.
+def isExpectedFail(test, xfails):
+ # Check if any of the xfails match an available feature or the target.
for item in xfails:
- if item == '*' or item in target_triple:
- break
- else:
- return False
+ # If this is the wildcard, it always fails.
+ if item == '*':
+ return True
- # If so, see if it is expected to pass on this target.
- #
- # FIXME: Rename XTARGET to something that makes sense, like XPASS.
- for item in xtargets:
- if item == '*' or item in target_triple:
- return False
+ # If this is an exact match for one of the features, it fails.
+ if item in test.config.available_features:
+ return True
- return True
+ # If this is a part of the target triple, it fails.
+ if item in test.suite.config.target_triple:
+ return True
-def parseIntegratedTestScript(test, normalize_slashes=False):
+ return False
+
+def parseIntegratedTestScript(test, normalize_slashes=False,
+ extra_substitutions=[]):
"""parseIntegratedTestScript - Scan an LLVM/Clang style integrated test
- script and extract the lines to 'RUN' as well as 'XFAIL' and 'XTARGET'
+ script and extract the lines to 'RUN' as well as 'XFAIL' and 'REQUIRES'
information. The RUN lines also will have variable substitution performed.
"""
sourcedir = os.path.dirname(sourcepath)
execpath = test.getExecPath()
execdir,execbase = os.path.split(execpath)
- tmpBase = os.path.join(execdir, 'Output', execbase)
+ tmpDir = os.path.join(execdir, 'Output')
+ tmpBase = os.path.join(tmpDir, execbase)
if test.index is not None:
tmpBase += '_%d' % test.index
if normalize_slashes:
sourcepath = sourcepath.replace('\\', '/')
sourcedir = sourcedir.replace('\\', '/')
+ tmpDir = tmpDir.replace('\\', '/')
tmpBase = tmpBase.replace('\\', '/')
# We use #_MARKER_# to hide %% while we do the other substitutions.
- substitutions = [('%%', '#_MARKER_#')]
+ substitutions = list(extra_substitutions)
+ substitutions.extend([('%%', '#_MARKER_#')])
substitutions.extend(test.config.substitutions)
substitutions.extend([('%s', sourcepath),
('%S', sourcedir),
('%p', sourcedir),
+ ('%{pathsep}', os.pathsep),
('%t', tmpBase + '.tmp'),
+ ('%T', tmpDir),
# FIXME: Remove this once we kill DejaGNU.
('%abs_tmp', tmpBase + '.tmp'),
('#_MARKER_#', '%')])
# Collect the test lines from the script.
script = []
xfails = []
- xtargets = []
requires = []
+ line_number = 0
for ln in open(sourcepath):
+ line_number += 1
if 'RUN:' in ln:
# Isolate the command to run.
index = ln.index('RUN:')
# Trim trailing whitespace.
ln = ln.rstrip()
+ # Substitute line number expressions
+ ln = re.sub('%\(line\)', str(line_number), ln)
+ def replace_line_number(match):
+ if match.group(1) == '+':
+ return str(line_number + int(match.group(2)))
+ if match.group(1) == '-':
+ return str(line_number - int(match.group(2)))
+ ln = re.sub('%\(line *([\+-]) *(\d+)\)', replace_line_number, ln)
+
# Collapse lines with trailing '\\'.
if script and script[-1][-1] == '\\':
script[-1] = script[-1][:-1] + ln
elif 'XFAIL:' in ln:
items = ln[ln.index('XFAIL:') + 6:].split(',')
xfails.extend([s.strip() for s in items])
- elif 'XTARGET:' in ln:
- items = ln[ln.index('XTARGET:') + 8:].split(',')
- xtargets.extend([s.strip() for s in items])
elif 'REQUIRES:' in ln:
items = ln[ln.index('REQUIRES:') + 9:].split(',')
requires.extend([s.strip() for s in items])
return (Test.UNSUPPORTED,
"Test requires the following features: %s" % msg)
- isXFail = isExpectedFail(xfails, xtargets, test.suite.config.target_triple)
+ isXFail = isExpectedFail(test, xfails)
return script,isXFail,tmpBase,execdir
def formatTestOutput(status, out, err, exitCode, failDueToStderr, script):
# considered to fail if there is any standard error output.
out,err,exitCode = res
if isXFail:
- ok = exitCode != 0 or err
+ ok = exitCode != 0 or err and not litConfig.ignoreStdErr
if ok:
status = Test.XFAIL
else:
status = Test.XPASS
else:
- ok = exitCode == 0 and not err
+ ok = exitCode == 0 and (not err or litConfig.ignoreStdErr)
if ok:
status = Test.PASS
else:
# Set a flag for formatTestOutput so it can explain why the test was
# considered to have failed, despite having an exit code of 0.
- failDueToStderr = exitCode == 0 and err
+ failDueToStderr = exitCode == 0 and err and not litConfig.ignoreStdErr
return formatTestOutput(status, out, err, exitCode, failDueToStderr, script)
-def executeShTest(test, litConfig, useExternalSh):
+def executeShTest(test, litConfig, useExternalSh,
+ extra_substitutions=[]):
if test.config.unsupported:
return (Test.UNSUPPORTED, 'Test is unsupported')
- res = parseIntegratedTestScript(test, useExternalSh)
+ res = parseIntegratedTestScript(test, useExternalSh, extra_substitutions)
if len(res) == 2:
return res