Browse Source

Fix up all tests to work with the catalog

default_compile_flags
vector-of-bool 5 years ago
parent
commit
f9b4d5f85c
15 changed files with 85 additions and 24 deletions
  1. +2
    -2
      tests/basics/test_app_only.py
  2. +2
    -2
      tests/catalog/create_test.py
  3. +3
    -4
      tests/catalog/get_test.py
  4. +2
    -3
      tests/catalog/import_test.py
  5. +16
    -9
      tests/dds.py
  6. +2
    -0
      tests/deps/do_test.py
  7. +24
    -0
      tests/deps/git-remote/catalog.json
  8. +0
    -2
      tests/deps/git-remote/remote.dds
  9. +4
    -0
      tests/deps/no-deps/catalog.json
  10. +0
    -0
      tests/deps/no-deps/remote.dds
  11. +14
    -0
      tests/deps/use-remote/catalog.json
  12. +0
    -1
      tests/deps/use-remote/remote.dds
  13. +15
    -0
      tests/deps/use-spdlog/project/catalog.json
  14. +0
    -1
      tests/deps/use-spdlog/project/remote.dds
  15. +1
    -0
      tests/deps/use-spdlog/use_spdlog_test.py

+ 2
- 2
tests/basics/test_app_only.py View File

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() {}',

+ 2
- 2
tests/catalog/create_test.py View File



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()

+ 3
- 4
tests/catalog/get_test.py View 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()

+ 2
- 3
tests/catalog/import_test.py View 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)

+ 16
- 9
tests/dds.py View File

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,
]) ])



+ 2
- 0
tests/deps/do_test.py View File



@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)

+ 24
- 0
tests/deps/git-remote/catalog.json View File

{
"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": {}
}
}
}
}

+ 0
- 2
tests/deps/git-remote/remote.dds View File

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

+ 4
- 0
tests/deps/no-deps/catalog.json View File

{
"version": 1,
"packages": {}
}

+ 0
- 0
tests/deps/no-deps/remote.dds View File


+ 14
- 0
tests/deps/use-remote/catalog.json View File

{
"version": 1,
"packages": {
"nlohmann-json": {
"3.7.1": {
"git": {
"url": "https://github.com/vector-of-bool/json.git",
"ref": "dds/3.7.1"
},
"depends": {}
}
}
}
}

+ 0
- 1
tests/deps/use-remote/remote.dds View File

Remote-Package: nlohmann-json@3.7.1; git url=https://github.com/vector-of-bool/json.git ref=dds/3.7.1

+ 15
- 0
tests/deps/use-spdlog/project/catalog.json View File

{
"version": 1,
"packages": {
"spdlog": {
"1.4.2": {
"git": {
"url": "https://github.com/gabime/spdlog.git",
"ref": "v1.4.2",
"auto-lib": "spdlog/spdlog"
},
"depends": {}
}
}
}
}

+ 0
- 1
tests/deps/use-spdlog/project/remote.dds View File

Remote-Package: spdlog@1.4.2; git url=https://github.com/gabime/spdlog.git ref=v1.4.2 auto=spdlog/spdlog

+ 1
- 0
tests/deps/use-spdlog/use_spdlog_test.py View File





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)

Loading…
Cancel
Save