Skip to content

Commit

Permalink
Pass --no-error-banner not tests
Browse files Browse the repository at this point in the history
  • Loading branch information
certik committed Oct 22, 2021
1 parent 7bc8024 commit 6a1fa35
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
13 changes: 10 additions & 3 deletions compiler_tester/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def fixdir(s):
local_dir = os.getcwd()
return s.replace(local_dir.encode(), "$DIR".encode())

def run(basename, cmd, out_dir, infile=None):
def run(basename, cmd, out_dir, infile=None, extra_args=None):
"""
Runs the `cmd` and collects stdout, stderr, exit code.
Expand All @@ -118,6 +118,7 @@ def run(basename, cmd, out_dir, infile=None):
out_dir .... output directory to store output
infile ..... optional input file. If present, it will check that it exists
and hash it.
extra_args . extra arguments, not part of the hash
Examples:
Expand All @@ -131,6 +132,8 @@ def run(basename, cmd, out_dir, infile=None):
raise RunException("The input file does not exist")
outfile = os.path.join(out_dir, basename + "." + "out")
cmd2 = cmd.format(infile=infile, outfile=outfile)
if extra_args:
cmd2 += " " + extra_args
r = subprocess.run(cmd2, shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Expand Down Expand Up @@ -183,7 +186,8 @@ def run(basename, cmd, out_dir, infile=None):
json.dump(data, open(json_file, "w"), indent=4)
return json_file

def run_test(basename, cmd, infile=None, update_reference=False):
def run_test(basename, cmd, infile=None, update_reference=False,
extra_args=None):
"""
Runs the test `cmd` and compare against reference results.
Expand All @@ -200,6 +204,8 @@ def run_test(basename, cmd, infile=None, update_reference=False):
it exists and hash it.
update_reference ... if True, it will copy the output into the reference
directory as reference results, overwriting old ones
extra_args ......... Extra arguments to append to the command that are not
part of the hash
Examples:
Expand All @@ -212,7 +218,8 @@ def run_test(basename, cmd, infile=None, update_reference=False):
basename = bname(basename, cmd, infile)
if infile:
infile = os.path.join("tests", infile)
jo = run(basename, cmd, os.path.join("tests", "output"), infile=infile)
jo = run(basename, cmd, os.path.join("tests", "output"), infile=infile,
extra_args=extra_args)
jr = os.path.join("tests", "reference", os.path.basename(jo))
do = json.load(open(jo))
if update_reference:
Expand Down
34 changes: 18 additions & 16 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,86 +60,88 @@ def main():

print(color(style.bold)+"TEST:"+color(style.reset), filename)

extra_args = "--no-error-banner"

if tokens:
run_test("tokens", "lfortran --no-color --show-tokens {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)

if ast:
if filename.endswith(".f"):
# Use fixed form
run_test("ast", "lfortran --fixed-form --show-ast --no-color {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)
else:
# Use free form
run_test("ast", "lfortran --show-ast --no-color {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)
if ast_indent:
run_test("ast_indent", "lfortran --show-ast --indent --no-color {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)

if ast_f90:
if filename.endswith(".f"):
# Use fixed form
run_test("ast_f90", "lfortran --fixed-form --show-ast-f90 --no-color {infile}",
filename, update_reference)
filename, update_reference, extra_args)
else:
# Use free form
run_test("ast_f90", "lfortran --show-ast-f90 --no-color {infile}",
filename, update_reference)
filename, update_reference, extra_args)

if ast_openmp:
run_test("ast_openmp", "cpptranslate --show-ast-openmp {infile}",
filename, update_reference)

if asr:
run_test("asr", "lfortran --show-asr --no-color {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)

if asr_preprocess:
run_test("asr_preprocess", "lfortran --cpp --show-asr --no-color {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)

if asr_indent:
run_test("asr_indent", "lfortran --show-asr --indent --no-color {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)

if mod_to_asr:
run_test("mod_to_asr", "lfortran mod --show-asr --no-color {infile}",
filename, update_reference)

if pass_ == "do_loops":
run_test("pass_do_loops", "lfortran --pass=do_loops --show-asr --no-color {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)

if pass_ == "global_stmts":
run_test("pass_global_stmts", "lfortran --pass=global_stmts --show-asr --no-color {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)

if llvm:
if no_llvm:
print(" * llvm SKIPPED as requested")
else:
run_test("llvm", "lfortran --no-color --show-llvm {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)

if cpp:
run_test("cpp", "lfortran --no-color --show-cpp {infile}",
filename, update_reference)
filename, update_reference, extra_args)

if obj:
if no_llvm:
print(" * obj SKIPPED as requested")
else:
run_test("obj", "lfortran --no-color -c {infile} -o output.o",
filename, update_reference)
filename, update_reference, extra_args)

if x86:
run_test("x86", "lfortran --no-color --backend=x86 {infile} -o output",
filename, update_reference)
filename, update_reference, extra_args)

if bin_:
run_test("bin", "lfortran --no-color {infile} -o {outfile}",
filename, update_reference)
filename, update_reference, extra_args)


print()
Expand Down

0 comments on commit 6a1fa35

Please sign in to comment.