test_cmake_resolve.py¶
tests/test_cmake_resolve.py
CMake variables in generation rules expanded where the build file alone settles them (2.1).
test_a_quoted_argument_resolves_without_its_quotes
None test_cmake_resolve.test_a_quoted_argument_resolves_without_its_quotes()
FOUND MEASURING mbedtls: `"./framework/x.py"` kept its quotes as part of the path.
tests/test_cmake_resolve.py:101
Checks
assert (resolve_argument('"${CMAKE_CURRENT_SOURCE_DIR}/gen.py"', "tests", {}, True) == "tests/gen.py" )assert resolve_argument('"${CMAKE_SOURCE_DIR}/./x.py"', "tests", {}, True) == "x.py"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | measured | test_a_quoted_argument_resolves_without_its_quotes → resolve_argument |
Source · 9 lines
def test_a_quoted_argument_resolves_without_its_quotes() -> None:
"""@brief FOUND MEASURING mbedtls: `"./framework/x.py"` kept its quotes as part of the path."""
assert (
resolve_argument('"${CMAKE_CURRENT_SOURCE_DIR}/gen.py"', "tests", {}, True)
== "tests/gen.py"
)
assert resolve_argument('"${CMAKE_SOURCE_DIR}/./x.py"', "tests", {}, True) == "x.py"
Activity · 2 steps
test_a_quoted_set_value_expands_without_its_quotes
None test_cmake_resolve.test_a_quoted_set_value_expands_without_its_quotes()
FOUND MEASURING mbedtls: `set(x "${CMAKE_CURRENT_SOURCE_DIR}/gen.sh")` kept its quotes.
tests/test_cmake_resolve.py:110
Checks
assert variables["gen"] == "${CMAKE_CURRENT_SOURCE_DIR}/gen.sh"assert resolve_argument('"${gen}"', "programs/test", variables, True) == "programs/test/gen.sh"assert resolve_argument("${empty}", "programs/test", variables, True) == ""
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | measured | test_a_quoted_set_value_expands_without_its_quotes → resolve_argument |
Source · 11 lines
def test_a_quoted_set_value_expands_without_its_quotes() -> None:
"""@brief FOUND MEASURING mbedtls: `set(x "${CMAKE_CURRENT_SOURCE_DIR}/gen.sh")` kept its quotes."""
from tests.test_cmake_generation import _tree
from clew.cmakeast import _variables
tree = _tree(b'set(gen "${CMAKE_CURRENT_SOURCE_DIR}/gen.sh")\nset(empty "")\n')
variables = _variables(tree.root_node)
assert variables["gen"] == "${CMAKE_CURRENT_SOURCE_DIR}/gen.sh"
assert resolve_argument('"${gen}"', "programs/test", variables, True) == "programs/test/gen.sh"
assert resolve_argument("${empty}", "programs/test", variables, True) == ""1 more lines, not shown
Activity · 7 steps
test_a_variable_set_in_the_file_expands
None test_cmake_resolve.test_a_variable_set_in_the_file_expands()
`set()` / `file(GLOB)` values, one level of nesting.
tests/test_cmake_resolve.py:35
Checks
assert resolve_argument("${hdrs}", "library", variables, True) == "include/*.h"assert (resolve_argument("${CMAKE_CURRENT_SOURCE_DIR}/${GEN}", "scripts", variables, True) == "scripts/gen.pl" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | measured | test_a_variable_set_in_the_file_expands → resolve_argument |
Source · 10 lines
def test_a_variable_set_in_the_file_expands() -> None:
"""@brief `set()` / `file(GLOB)` values, one level of nesting."""
variables = {"hdrs": "${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h", "GEN": "gen.pl"}
assert resolve_argument("${hdrs}", "library", variables, True) == "include/*.h"
assert (
resolve_argument("${CMAKE_CURRENT_SOURCE_DIR}/${GEN}", "scripts", variables, True)
== "scripts/gen.pl"
)
Activity · 3 steps
test_an_indexed_build_records_the_resolved_path
None test_cmake_resolve.test_an_indexed_build_records_the_resolved_path(Path tmp_path)
`generated_files.arg_resolved`, beside the literal as written.
tests/test_cmake_resolve.py:57
Checks
assert rows["${CMAKE_CURRENT_SOURCE_DIR}/../scripts/gen.pl"] == "scripts/gen.pl"assert rows["${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data/error.fmt"] == "scripts/data/error.fmt"assert rows["${hdrs}"] == "include/*.h"assert rows["${PERL_EXECUTABLE}"] == ""
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CLI-001 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → report_stats |
| REQ-DDB-CLI-002 | inferred | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → _doxygen_or_partial → _doxygen_stage → _run_doxygen_from_args → run_doxygen → doxygen_supports_sqlite3 |
| REQ-DDB-CONFIG-001 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _apply_declared_document → stated_document_meta |
| REQ-DDB-CONFIG-003 | inferred | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml → _is_flat_req_list |
| REQ-DDB-CONFIG-004 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_preprocessor |
| REQ-DDB-CONFIG-005 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig |
| REQ-DDB-CONFIG-006 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _recorded_entry_patterns → recorded_explicit |
| REQ-DDB-CONFIG-007 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature |
| REQ-DDB-CONFIG-009 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _apply_toolchain_exclusions → load_toolchain_config |
| REQ-DDB-GUARD-012 | inferred | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → load_guard_config → read_guard_config → read_requirements_section |
| REQ-DDB-GUARD-019 | inferred | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings → summarize → parse_doxygen_tags |
| REQ-DDB-GUARD-024 | inferred | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings → summarize → apply_autobrief |
| REQ-DDB-INDEX-001 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _verify_extra_input_is_read → effective_file_patterns |
| REQ-DDB-INDEX-002 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → build_lock |
| REQ-DDB-INDEX-003 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → report_index_coverage |
| REQ-DDB-INDEX-004 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → recover_ast_symbols |
| REQ-DDB-INDEX-005 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → stamp_external_provenance |
| REQ-DDB-INDEX-006 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → record_code_text → code_text_rows |
| REQ-DDB-INDEX-007 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → record_owners |
| REQ-DDB-INDEX-008 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_licenses |
| REQ-DDB-INDEX-009 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc |
| REQ-DDB-INDEX-010 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_ast_includes |
| REQ-DDB-INDEX-011 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_property_keys |
| REQ-DDB-MCP-001 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _operator_excludes → meta_section |
| REQ-DDB-MCP-004 | measured | |
| REQ-DDB-PIPE-001 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_database |
| REQ-DDB-PIPE-003 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → build_call_edges |
| REQ-DDB-PIPE-004 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → python_entry_seeds |
| REQ-DDB-PIPE-005 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → write_build_signature |
| REQ-DDB-PIPE-006 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → run_rustdoc → _require_nightly_rustdoc → clean_subprocess_env |
| REQ-DDB-PIPE-007 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_kconfig_gates |
| REQ-DDB-PIPE-008 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_docs |
| REQ-DDB-PIPE-009 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → prune_dominated_fuzzy_call_edges |
| REQ-DDB-PIPE-010 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_shared_key_edges_inferred → _build_inferred_edges |
| REQ-DDB-PIPE-011 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_ast_includes → run_harvest → _harvest_one_file → _parseable_file |
| REQ-DDB-PIPE-012 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → build_harvest_plan → js_symbol_harvester |
| REQ-DDB-PIPE-013 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → enrich_python_docstrings |
| REQ-DDB-PIPE-014 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_kerneldoc → within_repo |
| REQ-DDB-PIPE-015 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_config_defaults |
| REQ-DDB-QUERY-003 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → mark_test_scope |
| REQ-DDB-QUERY-011 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads → _ensure_threads_tables |
| REQ-DDB-SCHEMA-001 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → extract_threads |
| REQ-DDB-SCHEMA-002 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_shared_key_edges_inferred → _writer_dispatch_map |
| REQ-DDB-SCHEMA-003 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_callback_registration_edges → _ensure_external_boundaries_table |
| REQ-DDB-SCHEMA-004 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest |
| REQ-DDB-SCHEMA-005 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → resolve_key_alias_prefixes |
| REQ-DDB-SCHEMA-006 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml |
| REQ-DDB-SCHEMA-007 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_callback_registration_edges → _ensure_external_boundaries_table |
| REQ-DDB-SCHEMA-009 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_event_edges |
| REQ-DDB-SCHEMA-011 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → extract_context_conflicts |
| REQ-DDB-SCHEMA-012 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → load_dispatch_manifest → declaration_origin |
| REQ-DDB-SCHEMA-013 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → import_data_model_keys |
| REQ-DDB-SCHEMA-014 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_file_docs → ensure_file_docs_table |
| REQ-DDB-SCHEMA-015 | measured | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → ingest_requirements_yaml |
| REQ-DDB-WIKI-054 | inferred | test_an_indexed_build_records_the_resolved_path → _run_pipeline → _run_pipeline_inner → _build_stages → recover_ast_symbols → _recover_into → all |
Source · 33 lines
def test_an_indexed_build_records_the_resolved_path(tmp_path: Path) -> None:
"""@brief `generated_files.arg_resolved`, beside the literal as written."""
from clew.cli import _build_argparser, _run_pipeline
repo = tmp_path / "repo"
(repo / "library").mkdir(parents=True)
(repo / "scripts" / "data").mkdir(parents=True)
(repo / "include").mkdir()
(repo / "CMakeLists.txt").write_text("project(demo C)\nadd_subdirectory(library)\n")
(repo / "library" / "CMakeLists.txt").write_text(
"file(GLOB hdrs ${CMAKE_CURRENT_SOURCE_DIR}/../include/*.h)\n"
"add_custom_command(\n OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/error.c\n"
" COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/gen.pl\n"
" DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data/error.fmt ${hdrs}\n)\n"
)
(repo / "scripts" / "gen.pl").write_text("print 1;\n")
(repo / "scripts" / "data" / "error.fmt").write_text("x\n")
(repo / "include" / "a.h").write_text("int a(void);\n")
db = tmp_path / "x.db"
_run_pipeline(_build_argparser().parse_args(["--output", str(db), "--repo-root", str(repo)]))
rows = dict(
sqlite3.connect(db)
.execute(
"SELECT arg_literal, arg_resolved FROM generated_files WHERE output_name = 'error.c'"
)
.fetchall()
)
assert rows["${CMAKE_CURRENT_SOURCE_DIR}/../scripts/gen.pl"] == "scripts/gen.pl"
assert rows["${CMAKE_CURRENT_SOURCE_DIR}/../scripts/data/error.fmt"] == "scripts/data/error.fmt"
assert rows["${hdrs}"] == "include/*.h"
assert rows["${PERL_EXECUTABLE}"] == ""
Activity · 17 steps
test_only_an_expanded_variable_resolves
None test_cmake_resolve.test_only_an_expanded_variable_resolves()
Plain words do not resolve.
tests/test_cmake_resolve.py:90
Checks
assert resolve_argument(word, "library", {}, True) == "", word
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | measured | test_only_an_expanded_variable_resolves → resolve_argument |
Source · 11 lines
def test_only_an_expanded_variable_resolves() -> None:
"""FOUND MEASURING mbedtls: 67 of 94 "resolved" values were command words (`sed`, `-i.bak`,
`ctest`) passed through because they held no variable. Only an expanded variable resolves;
a plain literal already says all it can.
@brief Plain words do not resolve.
"""
for word in ("sed", "-i.bak", "ctest", "scripts/gen.pl"):
assert resolve_argument(word, "library", {}, True) == "", word
Activity · 2 steps
test_the_files_own_directory_and_the_root_expand
None test_cmake_resolve.test_the_files_own_directory_and_the_root_expand()
Source-dir variables expand; the path is normalised inside the tree.
tests/test_cmake_resolve.py:24
Checks
assert (resolve_argument("${CMAKE_CURRENT_SOURCE_DIR}/../scripts/gen.pl", "library", {}, True) == "scripts/gen.pl" )assert resolve_argument("${CMAKE_CURRENT_LIST_DIR}/gen.py", "tools", {}, True) == "tools/gen.py"assert resolve_argument("${CMAKE_SOURCE_DIR}/include/a.h", "library", {}, True) == "include/a.h"assert resolve_argument("${PROJECT_SOURCE_DIR}/x.fmt", "", {}, True) == "x.fmt"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | measured | test_the_files_own_directory_and_the_root_expand → resolve_argument |
Source · 11 lines
def test_the_files_own_directory_and_the_root_expand() -> None:
"""@brief Source-dir variables expand; the path is normalised inside the tree."""
assert (
resolve_argument("${CMAKE_CURRENT_SOURCE_DIR}/../scripts/gen.pl", "library", {}, True)
== "scripts/gen.pl"
)
assert resolve_argument("${CMAKE_CURRENT_LIST_DIR}/gen.py", "tools", {}, True) == "tools/gen.py"
assert resolve_argument("${CMAKE_SOURCE_DIR}/include/a.h", "library", {}, True) == "include/a.h"
assert resolve_argument("${PROJECT_SOURCE_DIR}/x.fmt", "", {}, True) == "x.fmt"
Activity · 4 steps
test_what_the_build_file_does_not_settle_stays_unresolved
None test_cmake_resolve.test_what_the_build_file_does_not_settle_stays_unresolved()
The binary dir, a found program, an unknown variable, a path out of the tree: "".
tests/test_cmake_resolve.py:45
Checks
assert resolve_argument("${CMAKE_CURRENT_BINARY_DIR}/error.c", "library", {}, True) == ""assert resolve_argument("${PERL_EXECUTABLE}", "library", {}, True) == ""assert (resolve_argument("${CMAKE_CURRENT_SOURCE_DIR}/../../outside.pl", "library", {}, True) == "" )assert resolve_argument("${CMAKE_SOURCE_DIR}/a.h", "library", {}, False) == "", ("no root CMakeLists" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | measured | test_what_the_build_file_does_not_settle_stays_unresolved → resolve_argument |
Source · 12 lines
def test_what_the_build_file_does_not_settle_stays_unresolved() -> None:
"""@brief The binary dir, a found program, an unknown variable, a path out of the tree: ""."""
assert resolve_argument("${CMAKE_CURRENT_BINARY_DIR}/error.c", "library", {}, True) == ""
assert resolve_argument("${PERL_EXECUTABLE}", "library", {}, True) == ""
assert (
resolve_argument("${CMAKE_CURRENT_SOURCE_DIR}/../../outside.pl", "library", {}, True) == ""
)
assert resolve_argument("${CMAKE_SOURCE_DIR}/a.h", "library", {}, False) == "", (
"no root CMakeLists"
)