def test_partial_build_rebuild(dds: DDS): """ Change the content of a header, but cause one user of that header to fail compilation. The fact that compilation fails means it is still `out-of-date`, and will need to be compiled after we have fixed it up. """ assert build_and_get_rc(dds) == 0 dds.scope.enter_context( dds.set_contents( 'src/values.hpp', b''' const int first_value_q = 6; const int second_value_q = 99; ''', )) # Header now causes errors in 1.cpp and 2.cpp with pytest.raises(subprocess.CalledProcessError): dds.build() # Fix 1.cpp dds.scope.enter_context( dds.set_contents( 'src/1.cpp', b''' #include "./values.hpp" int value_1() { return first_value_q; } ''', )) # We will still see a failure, but now the DB will record the updated values.hpp with pytest.raises(subprocess.CalledProcessError): dds.build() # Should should raise _again_, even though we've successfully compiled one # of the two files with the changed `values.hpp`, because `2.cpp` still # has a pending update with pytest.raises(subprocess.CalledProcessError): dds.build() dds.scope.enter_context( dds.set_contents( 'src/2.cpp', b''' #include "./values.hpp" int value_2() { return second_value_q; } ''', )) # We should now compile and link to get the updated value assert build_and_get_rc(dds) == (99 - 6)
def test_import_json(dds: DDS): dds.scope.enter_context(ensure_dir(dds.build_dir)) dds.catalog_create() json_fpath = dds.build_dir / 'data.json' import_data = { 'version': 1, 'packages': { 'foo': { '1.2.4': { 'git': { 'url': 'http://example.com', 'ref': 'master', }, 'depends': {}, }, '1.2.5': { 'git': { 'url': 'http://example.com', 'ref': 'master', }, }, }, }, } dds.scope.enter_context( dds.set_contents(json_fpath, json.dumps(import_data).encode())) dds.catalog_import(json_fpath)
def test_get(dds: DDS): dds.scope.enter_context(ensure_dir(dds.build_dir)) dds.catalog_create() json_path = dds.build_dir / 'catalog.json' import_data = { 'version': 1, 'packages': { 'neo-sqlite3': { '0.3.0': { 'git': { 'url': 'https://github.com/vector-of-bool/neo-sqlite3.git', 'ref': '0.3.0', }, }, }, }, } dds.scope.enter_context( dds.set_contents(json_path, json.dumps(import_data).encode())) dds.catalog_import(json_path) dds.catalog_get('[email protected]') assert (dds.source_root / '[email protected]').is_dir() assert (dds.source_root / '[email protected]/package.jsonc').is_file()
def test_rebuild_header_change(dds: DDS): """Change the content of the header which defines the values""" assert build_and_get_rc(dds) == 0 dds.scope.enter_context( dds.set_contents( 'src/values.hpp', b''' const int first_value = 63; const int second_value = 88; ''', )) assert build_and_get_rc(dds) == (88 - 63)
def test_simple_rebuild(dds: DDS): """ Check that changing a source file will update the resulting application. """ assert build_and_get_rc(dds) == 0 dds.scope.enter_context( dds.set_contents( 'src/1.cpp', b''' int value_1() { return 33; } ''', )) # 33 - 32 = 1 assert build_and_get_rc(dds) == 1