Skip to content

Commit e417815

Browse files
ptrojakanigsson
authored andcommitted
Replace e3.os.process.Run with subprocess.run
We don't need a full-blown "Run" function from e3, which pulls a lot of dependencies and makes loading of test_support.py much slow.
1 parent 96a1f4c commit e417815

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

testsuite/gnatprove/lib/python/test_support.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from fnmatch import fnmatch
1111
from time import sleep
1212
from shutil import which
13-
from e3.os.process import Run, STDOUT
13+
import subprocess
1414
from test_util import sort_key_for_errors
1515

1616

@@ -54,6 +54,13 @@
5454
is_mark = re.compile(r"@(\w*):(\w*)")
5555

5656

57+
def Run(command):
58+
result = subprocess.run(
59+
command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
60+
)
61+
return result
62+
63+
5764
def benchmark_mode():
5865
if "benchmark" in os.environ:
5966
return os.environ["benchmark"]
@@ -732,15 +739,15 @@ def gcc(src, opt=None):
732739
cmd += to_list(opt)
733740
cmd += [src]
734741
process = Run(cmd)
735-
print_sorted(str.splitlines(process.out))
742+
print_sorted(str.splitlines(process.stdout))
736743

737744

738745
def gprbuild(opt=None, sort_lines=True):
739746
"""Call gprbuld -q **opt. Sort the output if sort_lines is True."""
740747
if opt is None:
741748
opt = []
742-
process = Run(["gprbuild", "-q"] + opt, error=STDOUT)
743-
lines = str.splitlines(process.out)
749+
process = Run(["gprbuild", "-q"] + opt)
750+
lines = str.splitlines(process.stdout)
744751
if len(lines) == 0:
745752
return
746753

@@ -886,15 +893,15 @@ def gnatprove(
886893
# process = open("test.out", 'r').read()
887894

888895
# Check marks in source code and print the command output sorted
889-
strlist = str.splitlines(process.out)
896+
strlist = str.splitlines(process.stdout)
890897
# Replace line above by the one below for testing the scripts without
891898
# running the tool
892899
# strlist = str.splitlines(process)
893900

894901
check_marks(strlist)
895902
check_fail(strlist, no_fail)
896903
# Check that the exit status is as expected
897-
if exit_status is not None and process.status != exit_status:
904+
if exit_status is not None and process.returncode != exit_status:
898905
print("Unexpected exit status of", process.status)
899906
failure = True
900907
else:
@@ -1367,7 +1374,7 @@ def print_version():
13671374
os.environ["LD_LIBRARY_PATH"] = ""
13681375

13691376
p = Run(["gnatprove", "--version"])
1370-
lines = p.out.splitlines()
1377+
lines = p.stdout.splitlines()
13711378
# drop first line of output
13721379
lines = lines[1:]
13731380
for line in lines:

testsuite/gnatprove/tests/RA29-011__cvc4/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Env().add_path(bindir)
88

99
process = Run(["cvc5", "--show-config"])
10-
lines = process.out.splitlines()
10+
lines = process.stdout.splitlines()
1111
# First three lines of cvc5 output contain date and exact compiler version, so
1212
# remove this output. We also remove the "scm" line which refers to the exact
1313
# git commit in some builds. Same for "portfolio", which is only available on

testsuite/gnatprove/tests/RA29-011__why3/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
bindir = os.path.join(installdir, "libexec", "spark", "bin")
77
Env().add_path(bindir)
88
process = Run(["gnatwhy3", "--show-config"])
9-
print(process.out)
9+
print(process.stdout)

0 commit comments

Comments
 (0)