from tests.fileutil import set_contents | from tests.fileutil import set_contents | ||||
def test_lib_with_just_app(dds: DDS, scope: ExitStack): | |||||
scope.enter_context( | |||||
def test_lib_with_just_app(dds: DDS): | |||||
dds.scope.enter_context( | |||||
set_contents( | set_contents( | ||||
dds.source_root / 'src/foo.main.cpp', | dds.source_root / 'src/foo.main.cpp', | ||||
b'int main() {}', | b'int main() {}', |
def test_create_catalog(dds: DDS): | def test_create_catalog(dds: DDS): | ||||
dds.scope.enter_context(ensure_dir(dds.build_dir)) | dds.scope.enter_context(ensure_dir(dds.build_dir)) | ||||
dds.catalog_create(dds.build_dir / 'cat.db') | |||||
assert (dds.build_dir / 'cat.db').is_file() | |||||
dds.catalog_create() | |||||
assert dds.catalog_path.is_file() |
def test_get(dds: DDS): | def test_get(dds: DDS): | ||||
dds.scope.enter_context(ensure_dir(dds.build_dir)) | dds.scope.enter_context(ensure_dir(dds.build_dir)) | ||||
cat_path = dds.build_dir / 'catalog.db' | |||||
dds.catalog_create(cat_path) | |||||
dds.catalog_create() | |||||
json_path = dds.build_dir / 'catalog.json' | json_path = dds.build_dir / 'catalog.json' | ||||
import_data = { | import_data = { | ||||
dds.set_contents(json_path, | dds.set_contents(json_path, | ||||
json.dumps(import_data).encode())) | json.dumps(import_data).encode())) | ||||
dds.catalog_import(cat_path, json_path) | |||||
dds.catalog_import(json_path) | |||||
dds.catalog_get(cat_path, 'neo-sqlite3@0.2.2') | |||||
dds.catalog_get('neo-sqlite3@0.2.2') | |||||
assert (dds.source_root / 'neo-sqlite3@0.2.2').is_dir() | assert (dds.source_root / 'neo-sqlite3@0.2.2').is_dir() | ||||
assert (dds.source_root / 'neo-sqlite3@0.2.2/package.dds').is_file() | assert (dds.source_root / 'neo-sqlite3@0.2.2/package.dds').is_file() |
def test_import_json(dds: DDS): | def test_import_json(dds: DDS): | ||||
dds.scope.enter_context(ensure_dir(dds.build_dir)) | dds.scope.enter_context(ensure_dir(dds.build_dir)) | ||||
cat_path = dds.build_dir / 'catalog.db' | |||||
dds.catalog_create(cat_path) | |||||
dds.catalog_create() | |||||
json_fpath = dds.build_dir / 'data.json' | json_fpath = dds.build_dir / 'data.json' | ||||
import_data = { | import_data = { | ||||
dds.scope.enter_context( | dds.scope.enter_context( | ||||
dds.set_contents(json_fpath, | dds.set_contents(json_fpath, | ||||
json.dumps(import_data).encode())) | json.dumps(import_data).encode())) | ||||
dds.catalog_import(cat_path, json_fpath) | |||||
dds.catalog_import(json_fpath) |
def repo_dir(self) -> Path: | def repo_dir(self) -> Path: | ||||
return self.scratch_dir / 'repo' | return self.scratch_dir / 'repo' | ||||
@property | |||||
def catalog_path(self) -> Path: | |||||
return self.scratch_dir / 'catalog.db' | |||||
@property | @property | ||||
def deps_build_dir(self) -> Path: | def deps_build_dir(self) -> Path: | ||||
return self.scratch_dir / 'deps-build' | return self.scratch_dir / 'deps-build' | ||||
return self.run([ | return self.run([ | ||||
'deps', | 'deps', | ||||
'get', | 'get', | ||||
f'--catalog={self.catalog_path}', | |||||
self.repo_dir_arg, | self.repo_dir_arg, | ||||
]) | ]) | ||||
f'We don\'t know the executable suffix for the platform "{os.name}"' | f'We don\'t know the executable suffix for the platform "{os.name}"' | ||||
) | ) | ||||
def catalog_create(self, path: Path) -> subprocess.CompletedProcess: | |||||
return self.run(['catalog', 'create', f'--catalog={path}'], | |||||
cwd=self.test_dir) | |||||
def catalog_create(self) -> subprocess.CompletedProcess: | |||||
self.scratch_dir.mkdir(parents=True, exist_ok=True) | |||||
return self.run( | |||||
['catalog', 'create', f'--catalog={self.catalog_path}'], | |||||
cwd=self.test_dir) | |||||
def catalog_import(self, path: Path, | |||||
json_path: Path) -> subprocess.CompletedProcess: | |||||
def catalog_import(self, json_path: Path) -> subprocess.CompletedProcess: | |||||
self.scratch_dir.mkdir(parents=True, exist_ok=True) | |||||
return self.run([ | return self.run([ | ||||
'catalog', | 'catalog', | ||||
'import', | 'import', | ||||
f'--catalog={path}', | |||||
json_path, | |||||
f'--catalog={self.catalog_path}', | |||||
f'--json={json_path}', | |||||
]) | ]) | ||||
def catalog_get(self, path: Path, req: str) -> subprocess.CompletedProcess: | |||||
def catalog_get(self, req: str) -> subprocess.CompletedProcess: | |||||
return self.run([ | return self.run([ | ||||
'catalog', | 'catalog', | ||||
'get', | 'get', | ||||
f'--catalog={path}', | |||||
f'--catalog={self.catalog_path}', | |||||
req, | req, | ||||
]) | ]) | ||||
@dds_conf | @dds_conf | ||||
def test_deps_build(dds: DDS): | def test_deps_build(dds: DDS): | ||||
dds.catalog_import(dds.source_root / 'catalog.json') | |||||
assert not dds.repo_dir.exists() | assert not dds.repo_dir.exists() | ||||
dds.deps_get() | dds.deps_get() | ||||
assert dds.repo_dir.exists(), '`deps get` did not generate a repo directory' | assert dds.repo_dir.exists(), '`deps get` did not generate a repo directory' | ||||
@dds_fixture_conf_1('use-remote') | @dds_fixture_conf_1('use-remote') | ||||
def test_use_nlohmann_json_remote(dds: DDS): | def test_use_nlohmann_json_remote(dds: DDS): | ||||
dds.catalog_import(dds.source_root / 'catalog.json') | |||||
dds.deps_get() | dds.deps_get() | ||||
dds.deps_build() | dds.deps_build() | ||||
dds.build(apps=True) | dds.build(apps=True) |
{ | |||||
"version": 1, | |||||
"packages": { | |||||
"neo-buffer": { | |||||
"0.1.0": { | |||||
"git": { | |||||
"url": "https://github.com/vector-of-bool/neo-buffer.git", | |||||
"ref": "develop" | |||||
}, | |||||
"depends": {} | |||||
} | |||||
}, | |||||
"range-v3": { | |||||
"0.9.1": { | |||||
"git": { | |||||
"url": "https://github.com/ericniebler/range-v3.git", | |||||
"ref": "0.9.1", | |||||
"auto-lib": "Niebler/range-v3" | |||||
}, | |||||
"depends": {} | |||||
} | |||||
} | |||||
} | |||||
} |
Remote-Package: neo-buffer@0.1.0; git url=https://github.com/vector-of-bool/neo-buffer.git ref=develop | |||||
Remote-Package: range-v3@0.9.1; git url=https://github.com/ericniebler/range-v3.git ref=0.9.1 auto=Niebler/range-v3 |
{ | |||||
"version": 1, | |||||
"packages": {} | |||||
} |
{ | |||||
"version": 1, | |||||
"packages": { | |||||
"nlohmann-json": { | |||||
"3.7.1": { | |||||
"git": { | |||||
"url": "https://github.com/vector-of-bool/json.git", | |||||
"ref": "dds/3.7.1" | |||||
}, | |||||
"depends": {} | |||||
} | |||||
} | |||||
} | |||||
} |
Remote-Package: nlohmann-json@3.7.1; git url=https://github.com/vector-of-bool/json.git ref=dds/3.7.1 |
{ | |||||
"version": 1, | |||||
"packages": { | |||||
"spdlog": { | |||||
"1.4.2": { | |||||
"git": { | |||||
"url": "https://github.com/gabime/spdlog.git", | |||||
"ref": "v1.4.2", | |||||
"auto-lib": "spdlog/spdlog" | |||||
}, | |||||
"depends": {} | |||||
} | |||||
} | |||||
} | |||||
} |
Remote-Package: spdlog@1.4.2; git url=https://github.com/gabime/spdlog.git ref=v1.4.2 auto=spdlog/spdlog |
def test_get_build_use_spdlog(dds: DDS): | def test_get_build_use_spdlog(dds: DDS): | ||||
dds.catalog_import(dds.source_root / 'catalog.json') | |||||
dds.deps_get() | dds.deps_get() | ||||
tc_fname = 'gcc.tc.dds' if 'gcc' in dds.default_builtin_toolchain else 'msvc.tc.dds' | tc_fname = 'gcc.tc.dds' if 'gcc' in dds.default_builtin_toolchain else 'msvc.tc.dds' | ||||
tc = str(dds.test_dir / tc_fname) | tc = str(dds.test_dir / tc_fname) |