test_config_defaults.py

tests/test_config_defaults.py

What a build leaves OFF, which an index of what exists cannot otherwise hold.

test_a_commented_define_in_ordinary_source_is_not_a_config_option

None test_config_defaults.test_a_commented_define_in_ordinary_source_is_not_a_config_option(Path tmp_path)

Ordinary source is not mined for commented-out code.

tests/test_config_defaults.py:148

Show on the map →

Called by none

Calls _build

Checks

  • assert "DEBUG_ONLY_LEFTOVER" not in names, "a commented define in .c is not an option"
  • assert not any(r[3].endswith(".c") for r in rows), "no row may come from ordinary source"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_a_commented_define_in_ordinary_source_is_not_a_config_option → _build → import_config_defaults → run_harvest
REQ-DDB-PIPE-011measuredtest_a_commented_define_in_ordinary_source_is_not_a_config_option → _build → import_config_defaults → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_commented_define_in_ordinary_source_is_not_a_config_option → _build → import_config_defaults → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-PIPE-015measuredtest_a_commented_define_in_ordinary_source_is_not_a_config_option → _build → import_config_defaults
REQ-DDB-SCHEMA-012measured
Source · 19 lines
def test_a_commented_define_in_ordinary_source_is_not_a_config_option(tmp_path: Path) -> None:
    """A COMMENTED DEFINE IN A .c FILE IS DEAD CODE, not a configuration decision. That is a
    different finding, and letting it into this layer would make every answer here less
    trustworthy — a reader could not tell an option the project offers from a line somebody
    abandoned.

    Also guards the inverse: a prose comment MENTIONING a define must not become a row, which
    is why the scan reads comment nodes and requires the define to be the whole comment.

    @brief Dead code stays out.
    @return None.
    @version 1
    """
    _, rows = _build(tmp_path)
    names = {r[0] for r in rows}
    assert "DEBUG_ONLY_LEFTOVER" not in names, "a commented define in .c is not an option"
    assert not any(r[3].endswith(".c") for r in rows), "no row may come from ordinary source"

Activity · 4 steps
lines 161–161_, rows = _build(tmp_path)lines 162–162names = {r[0] for r in rows}lines 163–163assert "DEBUG_ONLY_LEFTOVER" not in names, "a commented define in .c is not an option"lines 164–164assert not any(r[3].endswith(".c") for r in rows), "no row may come from ordinary source"

test_a_commented_out_define_is_recorded_as_off_by_default

None test_config_defaults.test_a_commented_out_define_is_recorded_as_off_by_default(Path tmp_path)

A commented-out define is recorded as off, not omitted.

tests/test_config_defaults.py:91

Show on the map →

Called by none

Calls _build

Checks

  • assert by[("FEATURE_PLATFORM_MEMORY", shipped)][1] == "off"
  • assert by[("FEATURE_SPACED_FORM", shipped)][1] == "off"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_a_commented_out_define_is_recorded_as_off_by_default → _build → import_config_defaults → run_harvest
REQ-DDB-PIPE-011measuredtest_a_commented_out_define_is_recorded_as_off_by_default → _build → import_config_defaults → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_a_commented_out_define_is_recorded_as_off_by_default → _build → import_config_defaults → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-PIPE-015measuredtest_a_commented_out_define_is_recorded_as_off_by_default → _build → import_config_defaults
REQ-DDB-SCHEMA-012measured
Source · 21 lines
def test_a_commented_out_define_is_recorded_as_off_by_default(tmp_path: Path) -> None:
    """THE WHOLE POINT. Without this row the only trace of the option in the index is the
    alternative profile that enables it, so an agent reads "defined" and answers the opposite
    of the truth for a default build.

    @brief Commented defines are off.
    @return None.
    @version 1
    """
    _, rows = _build(tmp_path)
    ## KEYED ON (macro, file), NOT macro ALONE. One macro legitimately has a row per header
    ## that decides it — that is the whole mbedtls shape — so a macro-keyed lookup silently
    ## returns whichever row sorted last and this assertion would then describe the wrong file.
    by = {(r[0], r[3]): r for r in rows}
    shipped = "include/proj_config.h"
    assert by[("FEATURE_PLATFORM_MEMORY", shipped)][1] == "off"
    ## BOTH COMMENT SPELLINGS. `//#define` with no space is mbedtls's; `/* #define X */` is the
    ## other common form, and recognising only one would silently halve the layer.
    assert by[("FEATURE_SPACED_FORM", shipped)][1] == "off"

Activity · 5 steps
lines 100–100_, rows = _build(tmp_path)lines 104–104by = {(r[0], r[3]): r for r in rows}lines 105–105shipped = "include/proj_config.h"lines 106–106assert by[("FEATURE_PLATFORM_MEMORY", shipped)][1] == "off"lines 109–109assert by[("FEATURE_SPACED_FORM", shipped)][1] == "off"

test_a_gate_carries_its_macros_shipped_default

None test_config_defaults.test_a_gate_carries_its_macros_shipped_default(Path tmp_path)

A covering gate carries the shipped default of the macro it names.

tests/test_config_defaults.py:307

Show on the map →

Called by none

Calls _gate_db, gates_covering

Checks

  • assert len(gates) == 1
  • assert gates[0].default_state == "off"
  • assert gates[0].default_site == "include/proj_config.h:208"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-015measuredtest_a_gate_carries_its_macros_shipped_default → _gate_db → ensure_config_defaults_table
REQ-DDB-QUERY-003measuredtest_a_gate_carries_its_macros_shipped_default → gates_covering → table_exists
REQ-DDB-QUERY-004measuredtest_a_gate_carries_its_macros_shipped_default → gates_covering → _with_defaults → _in_default_build
REQ-DDB-QUERY-006measuredtest_a_gate_carries_its_macros_shipped_default → gates_covering
REQ-DDB-QUERY-013measuredtest_a_gate_carries_its_macros_shipped_default → gates_covering → _with_defaults → decided_default
REQ-DDB-SCHEMA-012measured
Source · 24 lines
def test_a_gate_carries_its_macros_shipped_default(tmp_path: Path) -> None:
    """THE JOIN THAT ANSWERS THE QUESTION, and the reason the harvest layer alone is worth
    nothing. `form` says "present when this symbol is set"; the default says whether it IS set.
    Only the two together answer "is this code compiled in", which is what the mbedtls marks
    asked and the index-only arm scored 0/3 on.

    @brief Gates carry defaults.
    @return None.
    @version 1
    """
    from clew.query.kconfig import gates_covering

    conn = _gate_db(
        tmp_path,
        "g.db",
        [("FEATURE_X", "off", "", "include/proj_config.h", 208, "", "declared")],
    )
    gates, _ = gates_covering(conn, "src/platform.h", 20)
    conn.close()
    assert len(gates) == 1
    assert gates[0].default_state == "off"
    assert gates[0].default_site == "include/proj_config.h:208"

Activity · 7 steps
lines 317–317from clew.query.kconfig import gates_coveringlines 319–323conn = _gate_db( tmp_path, "g.db", [("FEATURE_X", "off", "", "include/proj_config.h", 208, "", "declared")], )lines 324–324gates, _ = gates_covering(conn, "src/platform.h", 20)lines 325–325conn.close()lines 326–326assert len(gates) == 1lines 327–327assert gates[0].default_state == "off"lines 328–328assert gates[0].default_site == "include/proj_config.h:208"

test_an_active_define_is_recorded_as_on

None test_config_defaults.test_an_active_define_is_recorded_as_on(Path tmp_path)

An active define in the same header is recorded as on.

tests/test_config_defaults.py:115

Show on the map →

Called by none

Calls _build

Checks

  • assert by[("FEATURE_ON_BY_DEFAULT", "include/proj_config.h")][1] == "on"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_an_active_define_is_recorded_as_on → _build → import_config_defaults → run_harvest
REQ-DDB-PIPE-011measuredtest_an_active_define_is_recorded_as_on → _build → import_config_defaults → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_an_active_define_is_recorded_as_on → _build → import_config_defaults → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-PIPE-015measuredtest_an_active_define_is_recorded_as_on → _build → import_config_defaults
REQ-DDB-SCHEMA-012measured
Source · 14 lines
def test_an_active_define_is_recorded_as_on(tmp_path: Path) -> None:
    """ONE SCAN FOR BOTH STATES, so "on" and "off" cannot disagree about which options a header
    decides. A layer that recorded only the off ones would leave a reader unable to tell an
    enabled option from an option this header never mentions.

    @brief Active defines are on.
    @return None.
    @version 1
    """
    _, rows = _build(tmp_path)
    by = {(r[0], r[3]): r for r in rows}
    assert by[("FEATURE_ON_BY_DEFAULT", "include/proj_config.h")][1] == "on"

Activity · 3 steps
lines 124–124_, rows = _build(tmp_path)lines 125–125by = {(r[0], r[3]): r for r in rows}lines 126–126assert by[("FEATURE_ON_BY_DEFAULT", "include/proj_config.h")][1] == "on"

test_an_include_guard_is_not_an_option

None test_config_defaults.test_an_include_guard_is_not_an_option(Path tmp_path)

An include guard is not a configuration option.

tests/test_config_defaults.py:229

Checks

  • assert "PROJ_CONFIG_H" not in names, "an include guard is not a configuration option"
  • assert "FEATURE_REAL_OPTION" in names
  • assert "FEATURE_OFF_OPTION" in names

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_an_include_guard_is_not_an_option → import_config_defaults → run_harvest
REQ-DDB-PIPE-011measuredtest_an_include_guard_is_not_an_option → import_config_defaults → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_an_include_guard_is_not_an_option → import_config_defaults → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-PIPE-015measuredtest_an_include_guard_is_not_an_option → import_config_defaults
REQ-DDB-SCHEMA-012measured
Source · 44 lines
def test_an_include_guard_is_not_an_option(tmp_path: Path) -> None:
    """`#ifndef FOO_H` / `#define FOO_H` IS "INCLUDE ME ONCE", NOT A FEATURE. Measured on the
    real mbedtls tree before this exclusion: 39 of 1,206 "on" rows were guards, and nobody asks
    whether MBEDTLS_CONFIG_H is enabled by default. Left in, they rank EXACT on their own names
    in the discovery surface and become pure noise — the same reason `kconfig_gates` excludes
    them from gating sites.

    STRUCTURAL, NOT A `_H` SUFFIX RULE. The discriminator is that the guarded block defines the
    SAME symbol it just tested, which no configuration option ever does. A suffix test misses
    guards spelled otherwise and would catch feature macros that legitimately end in _H.

    @brief Guards stay out.
    @return None.
    @version 1
    """
    repo = tmp_path / "repo"
    (repo / "include").mkdir(parents=True)
    (repo / "include" / "guard_config.h").write_text(
        "#ifndef PROJ_CONFIG_H\n"
        "#define PROJ_CONFIG_H\n"
        "#define FEATURE_REAL_OPTION\n"
        "//#define FEATURE_OFF_OPTION\n"
        "#endif\n",
        encoding="utf-8",
    )
    db = tmp_path / "guard.db"
    conn = sqlite3.connect(str(db))
    conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT)")
    conn.execute("INSERT INTO path (rowid, name) VALUES (1, 'include/guard_config.h')")
    conn.commit()
    conn.close()

    import_config_defaults(db, repo)
    conn = sqlite3.connect(str(db))
    names = {r[0] for r in conn.execute("SELECT macro FROM config_defaults").fetchall()}
    conn.close()

    assert "PROJ_CONFIG_H" not in names, "an include guard is not a configuration option"
    ## The real options inside the guarded block must survive it — a guard excludes ITSELF,
    ## not everything it wraps, which is every option in a guarded config header.
    assert "FEATURE_REAL_OPTION" in names
    assert "FEATURE_OFF_OPTION" in names

Activity · 16 steps
lines 244–244repo = tmp_path / "repo"lines 245–245(repo / "include").mkdir(parents=True)lines 246–253(repo / "include" / "guard_config.h").write_text( "#ifndef PROJ_CONFIG_H\n" "#define PROJ_CONFIG_H\n" "#define FEATURE_REAL_OPTION\n" "//#define FEATURE_OFF_OPTION\n" "#endif\n", encoding="utf-8", )lines 254–254db = tmp_path / "guard.db"lines 255–255conn = sqlite3.connect(str(db))lines 256–256conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT)")lines 257–257conn.execute("INSERT INTO path (rowid, name) VALUES (1, 'include/guard_config.h')")lines 258–258conn.commit()lines 259–259conn.close()lines 261–261import_config_defaults(db, repo)lines 262–262conn = sqlite3.connect(str(db))lines 263–263names = {r[0] for r in conn.execute("SELECT macro FROM config_defaults").fetchall()}lines 264–264conn.close()lines 266–266assert "PROJ_CONFIG_H" not in names, "an include guard is not a configuration option"lines 269–269assert "FEATURE_REAL_OPTION" in nameslines 270–270assert "FEATURE_OFF_OPTION" in names

test_an_index_without_the_table_still_serves_gates

None test_config_defaults.test_an_index_without_the_table_still_serves_gates(Path tmp_path)

An index built before this layer serves gates unchanged.

tests/test_config_defaults.py:391

Show on the map →

Called by none

Calls _gate_db, gates_covering

Checks

  • assert len(gates) == 1 and gates[0].default_state == ""

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-015catalogtest_an_index_without_the_table_still_serves_gates → _gate_db → ensure_config_defaults_table
REQ-DDB-QUERY-003measuredtest_an_index_without_the_table_still_serves_gates → gates_covering → table_exists
REQ-DDB-QUERY-004inferredtest_an_index_without_the_table_still_serves_gates → gates_covering → _with_defaults → _in_default_build
REQ-DDB-QUERY-006measuredtest_an_index_without_the_table_still_serves_gates → gates_covering
REQ-DDB-QUERY-013inferredtest_an_index_without_the_table_still_serves_gates → gates_covering → _with_defaults → decided_default
Source · 15 lines
def test_an_index_without_the_table_still_serves_gates(tmp_path: Path) -> None:
    """THE TABLE IS NEW, SO EVERY INDEX IN EXISTENCE LACKS IT. A reader of an older index must
    get its gates with an empty default rather than an exception — the same tolerance every
    other column-added layer here carries.

    @brief Older indexes still work.
    @return None.
    @version 1
    """
    from clew.query.kconfig import gates_covering

    conn = _gate_db(tmp_path, "old.db", None)
    gates, _ = gates_covering(conn, "src/platform.h", 20)
    conn.close()
    assert len(gates) == 1 and gates[0].default_state == ""

1 more lines, not shown

Activity · 5 steps
lines 400–400from clew.query.kconfig import gates_coveringlines 402–402conn = _gate_db(tmp_path, "old.db", None)lines 403–403gates, _ = gates_covering(conn, "src/platform.h", 20)lines 404–404conn.close()lines 405–405assert len(gates) == 1 and gates[0].default_state == ""

test_disagreeing_profiles_leave_the_default_undecided

None test_config_defaults.test_disagreeing_profiles_leave_the_default_undecided(Path tmp_path)

Disagreeing guesses with no declared header decide nothing.

tests/test_config_defaults.py:364

Show on the map →

Called by none

Calls _gate_db, gates_covering

Checks

  • assert gates[0].default_state == "", "two guesses that disagree must not pick a winner"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-015measuredtest_disagreeing_profiles_leave_the_default_undecided → _gate_db → ensure_config_defaults_table
REQ-DDB-QUERY-003measuredtest_disagreeing_profiles_leave_the_default_undecided → gates_covering → table_exists
REQ-DDB-QUERY-004inferredtest_disagreeing_profiles_leave_the_default_undecided → gates_covering → _with_defaults → _in_default_build
REQ-DDB-QUERY-006measuredtest_disagreeing_profiles_leave_the_default_undecided → gates_covering
REQ-DDB-QUERY-013measuredtest_disagreeing_profiles_leave_the_default_undecided → gates_covering → _with_defaults → decided_default
REQ-DDB-SCHEMA-012measured
Source · 24 lines
def test_disagreeing_profiles_leave_the_default_undecided(tmp_path: Path) -> None:
    """EMPTY MEANS UNDECIDED, NEVER OFF. With two profiles disagreeing and no declared header to
    settle it, naming either as "the default" is the confident wrong answer this whole layer
    exists to remove — rebuilt one level up, which is exactly how it would come back.

    @brief Ambiguity stays ambiguous.
    @return None.
    @version 1
    """
    from clew.query.kconfig import gates_covering

    conn = _gate_db(
        tmp_path,
        "a.db",
        [
            ("FEATURE_X", "off", "", "configs/a_config.h", 1, "", "heuristic"),
            ("FEATURE_X", "on", "", "configs/b_config.h", 1, "", "heuristic"),
        ],
    )
    gates, _ = gates_covering(conn, "src/platform.h", 20)
    conn.close()
    assert gates[0].default_state == "", "two guesses that disagree must not pick a winner"

Activity · 5 steps
lines 373–373from clew.query.kconfig import gates_coveringlines 375–382conn = _gate_db( tmp_path, "a.db", [ ("FEATURE_X", "off", "", "configs/a_config.h", 1, "", "heuristic"), ("FEATURE_X", "on", "", "configs/b_config.h", 1, "", "heuristic"), ], )lines 383–383gates, _ = gates_covering(conn, "src/platform.h", 20)lines 384–384conn.close()lines 385–385assert gates[0].default_state == "", "two guesses that disagree must not pick a winner"

test_header_detection_is_named_and_narrow

None test_config_defaults.test_header_detection_is_named_and_narrow(Path tmp_path)

The config-header heuristic is narrow and is labelled as a heuristic.

tests/test_config_defaults.py:210

Show on the map →

Called by none

Calls _build, looks_like_config_header

Checks

  • assert looks_like_config_header("include/mbedtls/mbedtls_config.h")
  • assert looks_like_config_header("tests/configs/user-config-malloc-0-null.h")
  • assert not looks_like_config_header("library/ssl_tls.c")
  • assert not looks_like_config_header("include/mbedtls/platform.h")
  • assert {r[5] for r in rows} == {"heuristic"}, "an unstated header is a guess, and says so"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_header_detection_is_named_and_narrow → _build → import_config_defaults → run_harvest
REQ-DDB-PIPE-011measuredtest_header_detection_is_named_and_narrow → _build → import_config_defaults → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_header_detection_is_named_and_narrow → _build → import_config_defaults → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-PIPE-015measuredtest_header_detection_is_named_and_narrow → _build → import_config_defaults
REQ-DDB-SCHEMA-012measured
Source · 16 lines
def test_header_detection_is_named_and_narrow(tmp_path: Path) -> None:
    """NAME-MATCHED, AND THE ROW SAYS SO. `origin` separates a header the operator declared
    from one this guessed at, so a consumer is never handed a guess as a fact.

    @brief Heuristic is labelled.
    @return None.
    @version 1
    """
    assert looks_like_config_header("include/mbedtls/mbedtls_config.h")
    assert looks_like_config_header("tests/configs/user-config-malloc-0-null.h")
    assert not looks_like_config_header("library/ssl_tls.c")
    assert not looks_like_config_header("include/mbedtls/platform.h")
    _, rows = _build(tmp_path)
    assert {r[5] for r in rows} == {"heuristic"}, "an unstated header is a guess, and says so"

Activity · 6 steps
lines 218–218assert looks_like_config_header("include/mbedtls/mbedtls_config.h")lines 219–219assert looks_like_config_header("tests/configs/user-config-malloc-0-null.h")lines 220–220assert not looks_like_config_header("library/ssl_tls.c")lines 221–221assert not looks_like_config_header("include/mbedtls/platform.h")lines 222–222_, rows = _build(tmp_path)lines 223–223assert {r[5] for r in rows} == {"heuristic"}, "an unstated header is a guess, and says so"

test_the_commented_value_is_kept

None test_config_defaults.test_the_commented_value_is_kept(Path tmp_path)

The value a commented define carries is kept beside its state.

tests/test_config_defaults.py:132

Show on the map →

Called by none

Calls _build

Checks

  • assert by[("FEATURE_WITH_VALUE", "include/proj_config.h")][2] == "42"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_the_commented_value_is_kept → _build → import_config_defaults → run_harvest
REQ-DDB-PIPE-011measuredtest_the_commented_value_is_kept → _build → import_config_defaults → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_the_commented_value_is_kept → _build → import_config_defaults → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-PIPE-015measuredtest_the_commented_value_is_kept → _build → import_config_defaults
REQ-DDB-SCHEMA-012measured
Source · 13 lines
def test_the_commented_value_is_kept(tmp_path: Path) -> None:
    """ "off" and "off, and it would be 42" are different answers, and the second is what a
    reader asking about a default actually wants.

    @brief Values survive.
    @return None.
    @version 1
    """
    _, rows = _build(tmp_path)
    by = {(r[0], r[3]): r for r in rows}
    assert by[("FEATURE_WITH_VALUE", "include/proj_config.h")][2] == "42"

Activity · 3 steps
lines 140–140_, rows = _build(tmp_path)lines 141–141by = {(r[0], r[3]): r for r in rows}lines 142–142assert by[("FEATURE_WITH_VALUE", "include/proj_config.h")][2] == "42"

test_the_declared_header_wins_over_an_alternative_profile

None test_config_defaults.test_the_declared_header_wins_over_an_alternative_profile(Path tmp_path)

The declared header outvotes an alternative profile.

tests/test_config_defaults.py:334

Show on the map →

Called by none

Calls _gate_db, gates_covering

Checks

  • assert gates[0].default_state == "off", "the shipped header decides the default build"
  • assert gates[0].default_site == "include/proj_config.h:208"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-015measuredtest_the_declared_header_wins_over_an_alternative_profile → _gate_db → ensure_config_defaults_table
REQ-DDB-QUERY-003measuredtest_the_declared_header_wins_over_an_alternative_profile → gates_covering → table_exists
REQ-DDB-QUERY-004measuredtest_the_declared_header_wins_over_an_alternative_profile → gates_covering → _with_defaults → _in_default_build
REQ-DDB-QUERY-006measuredtest_the_declared_header_wins_over_an_alternative_profile → gates_covering
REQ-DDB-QUERY-013measuredtest_the_declared_header_wins_over_an_alternative_profile → gates_covering → _with_defaults → decided_default
REQ-DDB-SCHEMA-012measured
Source · 27 lines
def test_the_declared_header_wins_over_an_alternative_profile(tmp_path: Path) -> None:
    """THE EXACT mbedtls SHAPE. `MBEDTLS_PLATFORM_MEMORY` is commented out in the declared
    `mbedtls_config.h` and actively defined in two profiles under `configs/`. A default build
    reads the declared header, so it answers; the profiles describe other builds and must not
    outvote it. Letting them would reproduce the measured wrong answer with extra steps.

    @brief Declared beats heuristic.
    @return None.
    @version 1
    """
    from clew.query.kconfig import gates_covering

    conn = _gate_db(
        tmp_path,
        "w.db",
        [
            ("FEATURE_X", "off", "", "include/proj_config.h", 208, "", "declared"),
            ("FEATURE_X", "on", "", "configs/profile_a_config.h", 87, "", "heuristic"),
            ("FEATURE_X", "on", "", "configs/profile_b_config.h", 20, "", "heuristic"),
        ],
    )
    gates, _ = gates_covering(conn, "src/platform.h", 20)
    conn.close()
    assert gates[0].default_state == "off", "the shipped header decides the default build"
    assert gates[0].default_site == "include/proj_config.h:208"

Activity · 6 steps
lines 344–344from clew.query.kconfig import gates_coveringlines 346–354conn = _gate_db( tmp_path, "w.db", [ ("FEATURE_X", "off", "", "include/proj_config.h", 208, "", "declared"), ("FEATURE_X", "on", "", "configs/profile_a_config.h", 87, "", "heuristic"), ("FEATURE_X", "on", "", "configs/profile_b_config.h", 20, "", "heuristic"), ], )lines 355–355gates, _ = gates_covering(conn, "src/platform.h", 20)lines 356–356conn.close()lines 357–357assert gates[0].default_state == "off", "the shipped header decides the default build"lines 358–358assert gates[0].default_site == "include/proj_config.h:208"

test_the_table_is_created_even_at_zero_rows

None test_config_defaults.test_the_table_is_created_even_at_zero_rows(Path tmp_path)

The table exists even when a repo decides nothing.

tests/test_config_defaults.py:188

Checks

  • assert found, "the table must exist at zero rows"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-015measuredtest_the_table_is_created_even_at_zero_rows → ensure_config_defaults_table
REQ-DDB-SCHEMA-012measured
Source · 19 lines
def test_the_table_is_created_even_at_zero_rows(tmp_path: Path) -> None:
    """An EMPTY table means "we looked and this repo decides nothing"; an ABSENT one means the
    layer never ran. A consumer separating a correct negative from a detector failure needs
    both, and writing down the wrong one is the mistake this repo has made three times.

    @brief Empty is not absent.
    @return None.
    @version 1
    """
    db = tmp_path / "empty.db"
    conn = sqlite3.connect(str(db))
    ensure_config_defaults_table(conn)
    found = conn.execute(
        "SELECT name FROM sqlite_master WHERE type='table' AND name='config_defaults'"
    ).fetchone()
    conn.close()
    assert found, "the table must exist at zero rows"

Activity · 6 steps
lines 197–197db = tmp_path / "empty.db"lines 198–198conn = sqlite3.connect(str(db))lines 199–199ensure_config_defaults_table(conn)lines 200–202found = conn.execute( "SELECT name FROM sqlite_master WHERE type='table' AND name='config_defaults'" ).fetchone()lines 203–203conn.close()lines 204–204assert found, "the table must exist at zero rows"

test_two_headers_disagreeing_both_get_rows

None test_config_defaults.test_two_headers_disagreeing_both_get_rows(Path tmp_path)

An alternative profile's active define is recorded separately, not merged.

tests/test_config_defaults.py:170

Show on the map →

Called by none

Calls _build

Checks

  • assert ("include/proj_config.h", "off") in states
  • assert ("profiles/tiny_config.h", "on") in states

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measuredtest_two_headers_disagreeing_both_get_rows → _build → import_config_defaults → run_harvest
REQ-DDB-PIPE-011measuredtest_two_headers_disagreeing_both_get_rows → _build → import_config_defaults → run_harvest → _harvest_one_file → _parseable_file
REQ-DDB-PIPE-012inferredtest_two_headers_disagreeing_both_get_rows → _build → import_config_defaults → run_harvest → _harvest_one_file → _ts_language_for → _grammar_available → has_language
REQ-DDB-PIPE-015measuredtest_two_headers_disagreeing_both_get_rows → _build → import_config_defaults
REQ-DDB-SCHEMA-012measured
Source · 15 lines
def test_two_headers_disagreeing_both_get_rows(tmp_path: Path) -> None:
    """THE EXACT mbedtls SHAPE: the shipped header says off, a profile says on, and BOTH are
    true of their own file. Collapsing them to one answer is what produced the wrong one — a
    consumer needs to see that the default is off and that something else turns it on.

    @brief Disagreeing headers coexist.
    @return None.
    @version 1
    """
    _, rows = _build(tmp_path)
    states = {(r[3], r[1]) for r in rows if r[0] == "FEATURE_PLATFORM_MEMORY"}
    assert ("include/proj_config.h", "off") in states
    assert ("profiles/tiny_config.h", "on") in states

Activity · 4 steps
lines 179–179_, rows = _build(tmp_path)lines 180–180states = {(r[3], r[1]) for r in rows if r[0] == "FEATURE_PLATFORM_MEMORY"}lines 181–181assert ("include/proj_config.h", "off") in stateslines 182–182assert ("profiles/tiny_config.h", "on") in states