Skip to content

Commit

Permalink
Lean: print name of failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ineol authored and Alasdair committed Feb 14, 2025
1 parent a84fb81 commit 0c561cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions test/lean/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ def test_lean(subdir: str, allowed_list = None, runnable: bool = False):
'--splice',
'coq-print.splice'
] if runnable else [ ])
step('\'{}\' {} {} --lean --lean-output-dir {}'.format(sail, extra_flags, filename, basename))
step('\'{}\' {} {} --lean --lean-output-dir {}'.format(sail, extra_flags, filename, basename), name=filename)
if runnable:
step(f'lake exe run > expected 2> err_status', cwd=f'{basename}/out')
step(f'lake exe run > expected 2> err_status', cwd=f'{basename}/out', name=filename)
else:
# NOTE: lake --dir does not behave the same as cd $dir && lake build...
step('lake build', cwd=f'{basename}/out')
step('lake build', cwd=f'{basename}/out', name=filename)

status = step_with_status(f'diff {basename}/out/Out.lean {basename}.expected.lean')
status = step_with_status(f'diff {basename}/out/Out.lean {basename}.expected.lean', name=filename)
if status != 0:
if update_expected:
print(f'Overriding file {basename}.expected.lean')
Expand All @@ -69,7 +69,7 @@ def test_lean(subdir: str, allowed_list = None, runnable: bool = False):
sys.exit(1)

if runnable:
status = step_with_status(f'diff {basename}/out/expected {basename}.expect')
status = step_with_status(f'diff {basename}/out/expected {basename}.expect', name=filename)
if status != 0:
sys.exit(1)
step('rm -r {}'.format(basename))
Expand Down
8 changes: 4 additions & 4 deletions test/sailtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,24 @@ def project_chunks(filenames, cores):
ys.append(list(chunk))
return ys

def step_with_status(string, expected_status=0, cwd=None):
def step_with_status(string, expected_status=0, cwd=None, name=""):
p = subprocess.Popen(string, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, cwd=cwd)
out, err = p.communicate()
status = p.wait()
if status != expected_status:
if is_compact():
compact_char(color.FAIL, 'X')
else:
print("{}Failed{}: {}".format(color.FAIL, color.END, string))
print("{}Failed{}: {} {}".format(color.FAIL, color.END, name, string))
if not args.hide_error_output:
print('{}stdout{}:'.format(color.NOTICE, color.END))
print(out.decode('utf-8'))
print('{}stderr{}:'.format(color.NOTICE, color.END))
print(err.decode('utf-8'))
return status

def step(string, expected_status=0, cwd=None):
if step_with_status(string, expected_status=expected_status, cwd=cwd) != expected_status:
def step(string, expected_status=0, cwd=None, name=""):
if step_with_status(string, expected_status=expected_status, cwd=cwd, name=name) != expected_status:
sys.exit(1)

def banner(string):
Expand Down

0 comments on commit 0c561cd

Please sign in to comment.