|
1 | 1 | """Configure SCons and CxxTest for the CI matrix.""" |
2 | 2 |
|
| 3 | +import json |
3 | 4 | from pathlib import Path |
4 | 5 |
|
5 | | -test_requirements = Path("requirements/tests.txt").read_text().splitlines() |
| 6 | +requirements = ["python"] |
| 7 | +for filename in ("build.txt", "conda.txt", "tests.txt"): |
| 8 | + for line in (Path("requirements") / filename).read_text().splitlines(): |
| 9 | + spec = line.split("#", 1)[0].strip() |
| 10 | + if spec and spec != "cxxtest": |
| 11 | + requirements.append(spec) |
| 12 | + |
6 | 13 | Path("build").mkdir(exist_ok=True) |
7 | | -Path("build/matrix-tests.txt").write_text( |
8 | | - "\n".join(line for line in test_requirements if line.strip() != "cxxtest") |
| 14 | +Path("build/matrix-environment.yml").write_text( |
| 15 | + json.dumps( |
| 16 | + { |
| 17 | + "name": "test", |
| 18 | + "channels": ["conda-forge"], |
| 19 | + "dependencies": requirements, |
| 20 | + }, |
| 21 | + indent=2, |
| 22 | + ) |
9 | 23 | + "\n" |
10 | 24 | ) |
11 | 25 |
|
|
19 | 33 | env.Replace(CXXTEST=os.path.join(cxxtest, 'bin', 'cxxtestgen'), |
20 | 34 | CXXTEST_INSTALL_DIR=cxxtest, CXXTEST_PYTHON=sys.executable) |
21 | 35 |
|
22 | | -if env['PLATFORM'] != 'win32': |
| 36 | +if env['PLATFORM'] == 'win32': |
| 37 | + from SCons.Platform.win32 import exec_spawn |
| 38 | +
|
| 39 | + # The outer CI shell already activates conda and SCons configures MSVC. |
| 40 | + # /D stops each compiler/test-generator child from repeating cmd AutoRun. |
| 41 | + def spawn_without_autorun(sh, escape, cmd, args, child_env): |
| 42 | + return exec_spawn([sh, '/D', '/C', escape(' '.join(args))], child_env) |
| 43 | +
|
| 44 | + env['SPAWN'] = spawn_without_autorun |
| 45 | +else: |
23 | 46 | env.Replace(CXX=os.environ.get('CXX', os.path.join(prefix, 'bin', 'c++'))) |
24 | 47 | env.Prepend(CCFLAGS=['-isystem' + os.path.join(prefix, 'include')]) |
25 | 48 | env.Append(LIBPATH=os.path.join(prefix, 'lib')) |
|
0 commit comments