Skip to content

Commit 8da41d4

Browse files
committed
Fix testsuite.py --debug
1 parent 7b2a054 commit 8da41d4

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

testsuite/drivers/basic.py

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import glob
2+
import logging
23
import os
34
import sys
45

6+
from e3.os.process import Run, command_line_image
7+
8+
59
from drivers import ALSTestDriver
610
from e3.testsuite.driver.classic import TestAbortWithFailure
711

@@ -29,17 +33,36 @@ def run(self):
2933
if self.env.options.format:
3034
cmd.append("--format=%s" % self.env.options.format)
3135

36+
env = {
37+
"ALS": self.env.als,
38+
"ALS_HOME": self.env.als_home,
39+
"ALS_WAIT_FACTOR": str(self.env.wait_factor),
40+
"PYTHON": sys.executable,
41+
}
42+
3243
if self.env.main_options.debug:
3344
cmd.append("--debug")
3445

35-
self.shell(
36-
cmd,
37-
cwd=wd,
38-
env={
39-
"ALS": self.env.als,
40-
"ALS_HOME": self.env.als_home,
41-
"ALS_WAIT_FACTOR": str(self.env.wait_factor),
42-
"PYTHON": sys.executable,
43-
},
44-
ignore_environ=False,
45-
)
46+
# In debug mode, we want to run the subprocess without piping so that it
47+
# can communicate the PID to debug and wait for input. So we use
48+
# e3.process.Run directly instead of self.shell.
49+
logging.info(f"Running: cd {wd}; {command_line_image(cmd)}")
50+
p = Run(
51+
cmd,
52+
cwd=wd,
53+
env=env,
54+
ignore_environ=False,
55+
output=None,
56+
)
57+
if p.status != 0:
58+
raise TestAbortWithFailure("non-zero status code")
59+
else:
60+
p = self.shell(
61+
cmd,
62+
cwd=wd,
63+
env=env,
64+
ignore_environ=False,
65+
)
66+
67+
if self.env.main_options.verbose:
68+
print(p.out)

0 commit comments

Comments
 (0)