Example #1
0
def test_lib_with_tweaks(project_opener: ProjectOpener) -> None:
    pr = project_opener.open('projects/tweaks')
    pr.build()
    app = pr.build_root / ('tweakable' + paths.EXE_SUFFIX)
    res = proc.run([app])
    # The default value is 99:
    assert res.returncode == 99
    # Build again, but with an empty/non-existent tweaks directory
    pr.build(tweaks_dir=pr.root / 'conf')
    res = proc.run([app])
    assert res.returncode == 99
    # Now write a tweaks header and rebuild:
    pr.write(
        'conf/tweakable.tweaks.hpp', r'''
    #pragma once

    namespace tweakable {
        namespace config {
            const int value = 41;
        }
    }
    ''')
    pr.build(tweaks_dir=pr.root / 'conf')
    res = proc.run([app])
    assert res.returncode == 41
Example #2
0
def test_catch_testdriver(dds: DDS):
    dds.build(tests=True)
    test_exe = dds.build_dir / f'test/testlib/calc{dds.exe_suffix}'
    assert test_exe.exists()
    assert proc.run([test_exe]).returncode == 0
Example #3
0
def build_and_get_rc(dds: DDS) -> int:
    dds.build()
    app = dds.build_dir / ('app' + dds.exe_suffix)
    return proc.run(app).returncode
Example #4
0
 def run_unchecked(self, cmd: proc.CommandLine, *,
                   cwd: Path = None) -> subprocess.CompletedProcess:
     full_cmd = itertools.chain([self.dds_exe], cmd)
     return proc.run(full_cmd, cwd=cwd or self.source_root)
Example #5
0
def build_and_get_rc(proj: Project) -> int:
    proj.build()
    app = proj.build_root.joinpath('app' + paths.EXE_SUFFIX)
    return proc.run([app]).returncode
Example #6
0
def test_main(project_opener: ProjectOpener) -> None:
    proj = project_opener.open('main')
    proj.build()
    test_exe = proj.build_root.joinpath('test/testlib/calc' + paths.EXE_SUFFIX)
    assert test_exe.is_file()
    assert proc.run([test_exe]).returncode == 0