diff --git a/tests/run-tests.py b/tests/run-tests.py index 093656299f..392597c6d2 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -456,12 +456,12 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False): if is_special: # check for any cmdline options needed for this test - args = [MICROPYTHON] + cmdlist = [MICROPYTHON] with open(test_file, "rb") as f: line = f.readline() if line.startswith(b"# cmdline:"): # subprocess.check_output on Windows only accepts strings, not bytes - args += [str(c, "utf-8") for c in line[10:].strip().split()] + cmdlist += [str(c, "utf-8") for c in line[10:].strip().split()] # run the test, possibly with redirected input try: @@ -497,10 +497,10 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False): return get() with open(test_file, "rb") as f: - # instead of: output_mupy = subprocess.check_output(args, stdin=f) + # instead of: output_mupy = subprocess.check_output(cmdlist, stdin=f) master, slave = pty.openpty() p = subprocess.Popen( - args, stdin=slave, stdout=slave, stderr=subprocess.STDOUT, bufsize=0 + cmdlist, stdin=slave, stdout=slave, stderr=subprocess.STDOUT, bufsize=0 ) banner = get(True) output_mupy = banner + b"".join(send_get(line) for line in f) @@ -519,7 +519,7 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False): os.close(slave) else: output_mupy = subprocess.check_output( - args + [test_file], stderr=subprocess.STDOUT + cmdlist + [test_file], stderr=subprocess.STDOUT ) except subprocess.CalledProcessError: return b"CRASH" @@ -585,7 +585,12 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False): if is_special or test_file_abspath in tests_with_regex_output: # convert parts of the output that are not stable across runs - with open(test_file + ".exp", "rb") as f: + # Prefer emitter-specific expected output. + exp_file = test_file + "." + args.emit + ".exp" + if not os.path.isfile(exp_file): + # Fall back to generic expected output. + exp_file = test_file + ".exp" + with open(exp_file, "rb") as f: lines_exp = [] for line in f.readlines(): if line == b"########\n":