Skip to content

Commit 0a09b26

Browse files
committed
tests: add a script to run tests from a Python distribution
It is pretty basic. But it gets the job done. We are currently looking at 52 test failures on Linux.
1 parent 91b7641 commit 0a09b26

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

Diff for: test-distribution.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
"""Script to run Python tests from a distribution archive."""
7+
8+
import json
9+
import pathlib
10+
import subprocess
11+
import sys
12+
import tarfile
13+
import tempfile
14+
15+
import zstandard
16+
17+
18+
def main(args):
19+
if not args:
20+
print("Usage: test-distribution.py path/to/distribution.tar.zst")
21+
return 1
22+
23+
distribution_path = args[0]
24+
25+
with tempfile.TemporaryDirectory() as td:
26+
td = pathlib.Path(td)
27+
28+
with open(distribution_path, "rb") as fh:
29+
dctx = zstandard.ZstdDecompressor()
30+
with dctx.stream_reader(fh) as reader:
31+
with tarfile.open(mode="r|", fileobj=reader) as tf:
32+
tf.extractall(td)
33+
34+
root = td / "python"
35+
36+
python_json = root / "PYTHON.json"
37+
38+
with python_json.open("rb") as fh:
39+
info = json.load(fh)
40+
41+
test_args = [
42+
str(root / info["python_exe"]),
43+
str(root / info["run_tests"]),
44+
]
45+
46+
test_args.extend(args[1:])
47+
48+
return subprocess.run(test_args).returncode
49+
50+
51+
if __name__ == "__main__":
52+
sys.exit(main(sys.argv[1:]))

0 commit comments

Comments
 (0)