forked from OSchip/llvm-project
[lldbtest] Fix self.filecheck check file lookup
The 'test_filename' property in TestBase changes over time, so attempting to find a check file relative to the directory containing 'test_filename' is flaky. Use the absolute path of the check file as that's always correct (and simpler). This relies on the test driver changing into the test directory, which it seems we can safely assume. As a drive-by, make self.filecheck respect the trace (-t) option. llvm-svn: 342699
This commit is contained in:
parent
0744d3c5a1
commit
f853c6e074
|
@ -2233,11 +2233,7 @@ class TestBase(Base):
|
||||||
# a file within the inline test directory.
|
# a file within the inline test directory.
|
||||||
if check_file.endswith('.pyc'):
|
if check_file.endswith('.pyc'):
|
||||||
check_file = check_file[:-1]
|
check_file = check_file[:-1]
|
||||||
if hasattr(self, 'test_filename'):
|
check_file_abs = os.path.abspath(check_file)
|
||||||
check_file_abs = os.path.join(os.path.dirname(self.test_filename),
|
|
||||||
check_file)
|
|
||||||
else:
|
|
||||||
check_file_abs = os.path.abspath(check_file)
|
|
||||||
|
|
||||||
# Run FileCheck.
|
# Run FileCheck.
|
||||||
filecheck_bin = configuration.get_filecheck_path()
|
filecheck_bin = configuration.get_filecheck_path()
|
||||||
|
@ -2248,10 +2244,9 @@ class TestBase(Base):
|
||||||
cmd_stdout, cmd_stderr = subproc.communicate(input=output)
|
cmd_stdout, cmd_stderr = subproc.communicate(input=output)
|
||||||
cmd_status = subproc.returncode
|
cmd_status = subproc.returncode
|
||||||
|
|
||||||
if cmd_status != 0:
|
filecheck_cmd = " ".join(filecheck_args)
|
||||||
filecheck_cmd = " ".join(filecheck_args)
|
filecheck_trace = """
|
||||||
self.assertTrue(cmd_status == 0, """
|
--- FileCheck trace (code={0}) ---
|
||||||
--- FileCheck failed (code={0}) ---
|
|
||||||
{1}
|
{1}
|
||||||
|
|
||||||
FileCheck input:
|
FileCheck input:
|
||||||
|
@ -2260,7 +2255,13 @@ FileCheck input:
|
||||||
FileCheck output:
|
FileCheck output:
|
||||||
{3}
|
{3}
|
||||||
{4}
|
{4}
|
||||||
""".format(cmd_status, filecheck_cmd, output, cmd_stdout, cmd_stderr))
|
""".format(cmd_status, filecheck_cmd, output, cmd_stdout, cmd_stderr)
|
||||||
|
|
||||||
|
trace = cmd_status != 0 or traceAlways
|
||||||
|
with recording(self, trace) as sbuf:
|
||||||
|
print(filecheck_trace, file=sbuf)
|
||||||
|
|
||||||
|
self.assertTrue(cmd_status == 0)
|
||||||
|
|
||||||
def expect(
|
def expect(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Reference in New Issue