def test_get_build_use_cryptopp(dds: DDS): dds.catalog_import(dds.source_root / 'catalog.json') tc_fname = 'gcc.tc.jsonc' if 'gcc' in dds.default_builtin_toolchain else 'msvc.tc.jsonc' tc = str(dds.test_dir / tc_fname) dds.build(toolchain=tc) proc.check_run( (dds.build_dir / 'use-cryptopp').with_suffix(dds.exe_suffix))
def self_build(exe: Path, *, toolchain: str, lmi_path: Path = None, cat_path: Path = Path('_build/catalog.db'), cat_json_path: Path = Path('catalog.json'), dds_flags: proc.CommandLine = ()): # Copy the exe to another location, as windows refuses to let a binary be # replaced while it is executing new_exe = ROOT / '_dds.bootstrap-test.exe' shutil.copy2(exe, new_exe) try: proc.check_run( new_exe, 'catalog', 'import', f'--catalog={cat_path}', f'--json={cat_json_path}', ) proc.check_run( new_exe, 'build', f'--catalog={cat_path}', f'--repo-dir={ROOT}/_build/ci-repo', dds_flags, ('--toolchain', toolchain), ('-I', lmi_path) if lmi_path else (), ) finally: new_exe.unlink()
def test_get_build_use_spdlog(test_parent_dir: Path, project_opener: ProjectOpener, http_repo: RepoServer) -> None: proj = project_opener.open('project') http_repo.import_json_file(proj.root / 'catalog.json') proj.dds.repo_add(http_repo.url) tc_fname = 'gcc.tc.jsonc' if 'gcc' in toolchain.get_default_test_toolchain( ).name else 'msvc.tc.jsonc' proj.build(toolchain=test_parent_dir / tc_fname) proc.check_run([ (proj.build_root / 'use-spdlog').with_suffix(paths.EXE_SUFFIX) ])
def test_get_build_use_cryptopp(test_parent_dir: Path, tmp_project: Project, http_repo: RepoServer) -> None: http_repo.import_json_data(CRYPTOPP_JSON) tmp_project.dds.repo_add(http_repo.url) tmp_project.package_json = { 'name': 'usr-cryptopp', 'version': '1.0.0', 'namespace': 'test', 'depends': ['[email protected]'], } tmp_project.library_json = { 'name': 'use-cryptopp', 'uses': ['cryptopp/cryptopp'], } tc_fname = 'gcc.tc.jsonc' if 'gcc' in toolchain.get_default_test_toolchain( ).name else 'msvc.tc.jsonc' tmp_project.write('src/use-cryptopp.main.cpp', APP_CPP) tmp_project.build(toolchain=test_parent_dir / tc_fname, timeout=60 * 10) proc.check_run([ (tmp_project.build_root / 'use-cryptopp').with_suffix(paths.EXE_SUFFIX) ])
def test_cmake_simple(project_opener: ProjectOpener) -> None: proj = project_opener.open('projects/simple') proj.dds.pkg_import(proj.root) cm_proj_dir = project_opener.test_dir / 'projects/simple-cmake' proj.build_root.mkdir(exist_ok=True, parents=True) proj.dds.run( [ 'build-deps', proj.dds.cache_dir_arg, '[email protected]', ('-t', ':gcc' if 'gcc' in toolchain.get_default_toolchain().name else ':msvc'), f'--cmake=libraries.cmake', ], cwd=proj.build_root, ) try: proc.check_run(['cmake', '-S', cm_proj_dir, '-B', proj.build_root]) except FileNotFoundError: assert False, 'Running the integration tests requires a CMake executable' proc.check_run(['cmake', '--build', proj.build_root])
def main(argv: Sequence[str]) -> int: parser = argparse.ArgumentParser() parser.add_argument( '-B', '--bootstrap-with', help='How are we to obtain a bootstrapped DDS executable?', choices=('download', 'build', 'skip'), required=True, ) parser.add_argument('--toolchain', '-T', help='The toolchain to use for the CI process', required=True) args = parser.parse_args(argv) opts = CIOptions(toolchain=args.toolchain) if args.bootstrap_with == 'build': _do_bootstrap_build(opts) elif args.bootstrap_with == 'download': _do_bootstrap_download() elif args.bootstrap_with == 'skip': pass else: assert False, 'impossible' cat_path = paths.BUILD_DIR / 'catalog.db' if cat_path.is_file(): cat_path.unlink() ci_repo_dir = paths.BUILD_DIR / '_ci-repo' if ci_repo_dir.exists(): shutil.rmtree(ci_repo_dir) proc.check_run([ paths.PREBUILT_DDS, 'catalog', 'import', ('--catalog', cat_path), ('--json', paths.PROJECT_ROOT / 'catalog.json'), ]) self_build(paths.PREBUILT_DDS, toolchain=opts.toolchain, dds_flags=[ ('--catalog', cat_path), ('--repo-dir', ci_repo_dir), ]) print('Main build PASSED!') # Delete the catalog database, since there may be schema changes since the # bootstrap executable was built cat_path.unlink() proc.check_run([ paths.CUR_BUILT_DDS, 'catalog', 'import', ('--catalog', cat_path), ('--json', paths.PROJECT_ROOT / 'catalog.json'), ]) self_build( paths.CUR_BUILT_DDS, toolchain=opts.toolchain, dds_flags=[f'--repo-dir={ci_repo_dir}', f'--catalog={cat_path}']) print('Bootstrap test PASSED!') return pytest.main([ '-v', '--durations=10', f'--basetemp={paths.BUILD_DIR / "_tmp"}', '-n4', 'tests/', ])