Coverage for gpaw/test/crontab.py: 29%
28 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-08 00:17 +0000
1"""Test GPAW in a venv."""
3import os
4import shutil
5import subprocess
6import sys
7from pathlib import Path
10cmds = """\
11python3 -m venv venv
12. venv/bin/activate
13pip install -U pip -qq
14pip install pytest sphinx-rtd-theme coverage
15pip install -q git+https://gitlab.com/ase/ase.git@master
16git clone git@gitlab.com:gpaw/gpaw
17cd gpaw
18pip install -e .
19coverage run -m pytest > test-1.out
20coverage html
21gpaw -P 2 python -m pytest -x > test-2.out
22gpaw -P 4 python -m pytest -x > test-4.out
23gpaw -P 8 python -m pytest -x > test-8.out"""
26def run_tests():
27 home = Path.cwd()
28 root = Path('/tmp/gpaw-tests')
29 if root.is_dir():
30 sys.exit('Locked')
31 root.mkdir()
32 os.chdir(root)
33 cmds2 = ' && '.join(cmd for cmd in cmds.splitlines()
34 if not cmd.startswith('#'))
35 p = subprocess.run(cmds2, shell=True)
36 if p.returncode == 0:
37 status = 'ok'
38 for n in [1, 2, 4, 8]:
39 shutil.copy2(root / f'gpaw/test-{n}.out', home)
40 else:
41 print('FAILED!', file=sys.stdout)
42 status = 'error'
43 f = root.with_name('gpaw-test-' + status)
44 if f.is_dir():
45 shutil.rmtree(f)
46 root.rename(f)
47 return status
50if __name__ == '__main__':
51 run_tests()