|
15 | 15 | REQUIREMENTS = FALCON_ROOT / 'requirements' / 'cibwtest' |
16 | 16 | TESTS = FALCON_ROOT / 'tests' |
17 | 17 |
|
| 18 | +EXPECTED_SCRIPTS = set({'falcon-bench', 'falcon-inspect-app', 'falcon-print-routes'}) |
| 19 | +EXPECTED_PACKAGES = set({'falcon'}) |
| 20 | + |
18 | 21 |
|
19 | 22 | def test_package(package): |
20 | 23 | with tempfile.TemporaryDirectory() as tmpdir: |
21 | 24 | venv = pathlib.Path(tmpdir) / 'venv' |
| 25 | + venv_bin = venv / 'bin' |
| 26 | + venv_pip = venv_bin / 'pip' |
22 | 27 | subprocess.check_call((sys.executable, '-m', 'venv', venv)) |
23 | 28 | logging.info(f'Created a temporary venv in {venv}.') |
24 | 29 |
|
25 | | - subprocess.check_call((venv / 'bin' / 'pip', 'install', '--upgrade', 'pip')) |
26 | | - subprocess.check_call((venv / 'bin' / 'pip', 'install', '-r', REQUIREMENTS)) |
| 30 | + subprocess.check_call((venv_pip, 'install', '--upgrade', 'pip')) |
| 31 | + subprocess.check_call((venv_pip, 'install', '-r', REQUIREMENTS)) |
27 | 32 | logging.info(f'Installed test requirements in {venv}.') |
28 | | - subprocess.check_call( |
29 | | - (venv / 'bin' / 'pip', 'install', package), |
30 | | - ) |
| 33 | + |
| 34 | + (venv_site_pkg,) = venv.glob('lib/python*/site-packages') |
| 35 | + bin_before = {path.name for path in venv_bin.iterdir()} |
| 36 | + pkg_before = {path.name for path in venv_site_pkg.iterdir()} |
| 37 | + |
| 38 | + subprocess.check_call((venv_pip, 'install', package)) |
31 | 39 | logging.info(f'Installed {package} into {venv}.') |
32 | 40 |
|
33 | | - subprocess.check_call((venv / 'bin' / 'pytest', TESTS), cwd=venv) |
| 41 | + bin_after = {path.name for path in venv_bin.iterdir()} |
| 42 | + assert bin_after - bin_before == EXPECTED_SCRIPTS, ( |
| 43 | + f'Unexpected scripts installed in {venv_bin} from {package}: ' |
| 44 | + f'{bin_after - bin_before - EXPECTED_SCRIPTS}' |
| 45 | + ) |
| 46 | + pkg_after = { |
| 47 | + path.name for path in venv_site_pkg.iterdir() if path.suffix != '.dist-info' |
| 48 | + } |
| 49 | + assert pkg_after - pkg_before == EXPECTED_PACKAGES, ( |
| 50 | + f'Unexpected packages installed in {venv_site_pkg} from {package}: ' |
| 51 | + f'{pkg_after - pkg_before - EXPECTED_PACKAGES}' |
| 52 | + ) |
| 53 | + |
| 54 | + subprocess.check_call((venv_bin / 'pytest', TESTS), cwd=venv) |
34 | 55 | logging.info(f'{package} passes tests.') |
35 | 56 |
|
36 | 57 |
|
|
0 commit comments