Skip to content

Commit caaea3f

Browse files
committed
Merge branch 'topic/testsuite-improvements' into 'master'
Testsuite improvements See merge request eng/ide/ada_language_server!1830
2 parents 0d9a30a + af4f702 commit caaea3f

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

.mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[mypy]
2+
mypy_path = $MYPY_CONFIG_FILE_DIR/testsuite

.pre-commit-config.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ repos:
2222
hooks:
2323
- id: mypy
2424
files: '\.py$'
25-
# exclude: "^tests/.+$"
25+
args:
26+
# These flags make mypy associate different module names to `test.py`
27+
# files from different test directories.
28+
- --explicit-package-bases
29+
- --namespace-packages
2630
additional_dependencies:
2731
- pytest-lsp
32+
- e3-testsuite
33+
- psutil
34+
- types-psutil
35+
36+
- repo: local
37+
hooks:
38+
# This hook checks that Python test directories are valid module names so
39+
# that mypy will accept to analyse multiple test.py in different
40+
# directories.
41+
- id: py-filenames
42+
name: Python test.py paths
43+
entry: Python path components should be valid modules names (e.g. no '.' or whitespace). This is for mypy to accept dealing with test.py files in different directories.
44+
language: fail
45+
files: 'testsuite.*[^A-Za-z0-9_\/].*test\.py$'

testsuite/drivers/pylsp.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,14 @@ def run(self) -> None:
8282
str(python_file),
8383
]
8484

85-
for _ in range(0, self.env.main_options.verbose): # type: ignore
85+
assert self.env.main_options
86+
for _ in range(0, self.env.main_options.verbose):
8687
# Transfer -v arguments to the Python test driver to reflect verbosity
8788
cmd += ["-v"]
8889

90+
if self.env.main_options.debug:
91+
cmd.append("--debug")
92+
8993
# Spawn a child Python process to run the test, to avoid lingering file
9094
# handles which can create issues on Windows when the test work dir is
9195
# cleaned up after execution.
@@ -95,9 +99,9 @@ def run(self) -> None:
9599
"PYTHONPATH": os.path.dirname(os.path.dirname(__file__)),
96100
}
97101

98-
assert self.env.main_options
99-
if self.env.main_options.debug:
100-
cmd.append("--debug")
102+
if self.env.main_options.debug or self.env.main_options.verbose:
103+
# In this case we use Run directly without piping options to connect the
104+
# subprocess directly to the parent I/O.
101105

102106
LOG.info(f"Run: cd {wd}; {command_line_image(cmd)}")
103107
r = Run(

testsuite/drivers/shell.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
class ShellTestDriver(ALSTestDriver):
66
"""
77
Run the test.sh test program.
8-
98
"""
109

11-
def run(self):
10+
def run(self) -> None:
11+
1212
# This takes care of failing the test in case the return code is
1313
# non-zero
1414
check_call(
@@ -22,4 +22,5 @@ def run(self):
2222
# The following makes the child process inherit the parent process's
2323
# environment, in addition to the above environment.
2424
ignore_environ=False,
25+
timeout=15, # seconds
2526
)

0 commit comments

Comments
 (0)