test_an_include_guard_is_not_an_option

Tests › tests/test_config_defaults.py

passed Passed in the packaged run.

What this test is for

Why it exists

`#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.

Given

  1. repo = tmp_path / "repo"
  2. (repo / "include").mkdir(parents=True)
7 more
  1. (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", )
  2. db = tmp_path / "guard.db"
  3. conn = sqlite3.connect(str(db))
  4. conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT)")
  5. conn.execute("INSERT INTO path (rowid, name) VALUES (1, 'include/guard_config.h')")
  6. conn.commit()
  7. conn.close()
→

When

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

Then

  1. ✓ names does not contain "PROJ_CONFIG_H"
  2. ✓ names contains "FEATURE_REAL_OPTION"
  3. ✓ names contains "FEATURE_OFF_OPTION"

What it exercises

The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.

clew — `main` (clew/cli.py) · 7 of 400 steps

… 70 earlier steps

command-line usercommand-line usercommand-line usercommand-line userother filesother filesother filesother filesloop (line 134)looploop (line 135)loopopt (line 385)optmain71–72. repo_source_files → _scandir71_scandir +1 more73. _ts_language_for → _grammar_available73_grammar_available74–75. _grammar_available → has_language74has_language +1 more76. _ts_language_for → _try_import_ts_module76_try_import_ts_module77–80. build_context → scope_membership77scope_membership +3 more81. _ast_parse_one_file → _ts_language_for81_ts_language_for▶ test enters82–85. _ast_parse_one_file → _cached_parser82_cached_parser +3 more86–87. _ast_parse_one_file → _disambiguate_header86_disambiguate_header +1 more

… 313 later steps

tests/test_config_defaults.py:229 · its file's page

What it checks (3)

  1. assert "PROJ_CONFIG_H" not in names, "an include guard is not a configuration option" not attributed
  2. assert "FEATURE_REAL_OPTION" in names not attributed
  3. assert "FEATURE_OFF_OPTION" in names not attributed

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_an_include_guard_is_not_an_option→import_config_defaults

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

test_an_include_guard_is_not_an_option · 3 checksimport_config_defaultsrun_harvestREQ-DDB-PIPE-003 · measuredimport_config_defaultsrun_harvest_harvest_one_file_parseable_fileREQ-DDB-PIPE-011 · measuredimport_config_defaults… 4 calls …has_languageREQ-DDB-PIPE-012 · inferredimport_config_defaultsREQ-DDB-PIPE-015 · measured
Also reaches 5 requirements

Its run touches their code; that is reach, not proof.