@@ -1077,6 +1077,104 @@ TEST(test_impact_engine_parse_gaps_reach_what_they_name) {
10771077 PASS ();
10781078}
10791079
1080+ /* A gap names only what its text can call or read: a reached function,
1081+ * variable or macro (user decision R155, 2026-11-11). The word of a changed
1082+ * struct field (`used`) or a very short name (`nn`) written in an unrelated
1083+ * function's gap names nothing, and a gap outside every definition reaches the
1084+ * definitions written on its own lines, never its whole file. Matching every
1085+ * reached name and seeding whole files fired hundreds of gaps per change in
1086+ * this repository and reached the runner's main through the memory core. */
1087+ static const char tie_gaps_main [] = "#include \"test_framework.h\"\n"
1088+ "int main(int argc, char **argv) {\n"
1089+ " RUN_SELECTED_SUITE(alpha);\n"
1090+ " RUN_SELECTED_SUITE(beta);\n"
1091+ " RUN_SELECTED_SUITE(gamma);\n"
1092+ " RUN_SELECTED_SUITE(delta);\n"
1093+ " RUN_SELECTED_SUITE(epsilon);\n"
1094+ " return 0;\n"
1095+ "}\n" ;
1096+
1097+ /* One test that calls `fn`, as the whole suite `suite`. */
1098+ static void tie_calling_suite (char * out , size_t cap , const char * suite , const char * fn ) {
1099+ snprintf (out , cap ,
1100+ "int %s(void);\n"
1101+ "TEST(%s_calls) {\n"
1102+ " return %s() == 0 ? 0 : 1;\n"
1103+ "}\n"
1104+ "SUITE(%s) {\n"
1105+ " RUN_TEST(%s_calls);\n"
1106+ "}\n" ,
1107+ fn , suite , fn , suite , suite );
1108+ }
1109+
1110+ TEST (test_impact_engine_parse_gaps_name_only_reached_functions ) {
1111+ static const char lib [] = "struct counts {\n int used;\n};\n"
1112+ "int nn = 1;\n"
1113+ "int lib_value(void) {\n return 1;\n}\n"
1114+ "int lib_other(void) {\n return 2;\n}\n" ;
1115+ static const char changed [] = "struct counts {\n long used;\n};\n"
1116+ "int nn = 2;\n"
1117+ "int lib_value(void) {\n return 1 + 0;\n}\n"
1118+ "int lib_other(void) {\n return 2;\n}\n" ;
1119+ static const char gapped [] = "int lib_value(void);\n"
1120+ "int helper_named(void) {\n"
1121+ " int x = 0;\n"
1122+ " x = (lib_value() ;\n"
1123+ " return x;\n"
1124+ "}\n"
1125+ "int helper_field(void) {\n"
1126+ " int used = 0;\n"
1127+ " used = (used + ;\n"
1128+ " return used;\n"
1129+ "}\n"
1130+ "int helper_short(void) {\n"
1131+ " int nn = 0;\n"
1132+ " nn = (nn + ;\n"
1133+ " return nn;\n"
1134+ "}\n" ;
1135+ /* The shape of src/foundation/mem_core.c:110: a declaration the parser
1136+ * cannot read, outside every definition (no node holds its line). */
1137+ static const char table [] = "int lib_value(void);\n"
1138+ "int far_away(void) {\n"
1139+ " return 0;\n"
1140+ "}\n"
1141+ "static _Thread_local int tl_x[lib_value];\n" ;
1142+ char beta [512 ];
1143+ char gamma [512 ];
1144+ char delta [512 ];
1145+ char epsilon [512 ];
1146+ tie_calling_suite (beta , sizeof (beta ), "beta" , "helper_named" );
1147+ tie_calling_suite (gamma , sizeof (gamma ), "gamma" , "far_away" );
1148+ tie_calling_suite (delta , sizeof (delta ), "delta" , "helper_field" );
1149+ tie_calling_suite (epsilon , sizeof (epsilon ), "epsilon" , "helper_short" );
1150+ const char * const files [] = {
1151+ "tests/test_main.c" , tie_gaps_main , "tests/test_beta.c" , beta ,
1152+ "tests/test_gamma.c" , gamma , "tests/test_delta.c" , delta ,
1153+ "tests/test_epsilon.c" , epsilon , "src/lib.c" , lib ,
1154+ "src/gapped.c" , gapped , "src/table.c" , table };
1155+ tie_fixture_t fx ;
1156+ ASSERT_TRUE (tie_open_files (& fx , files , 8 ));
1157+ ASSERT_TRUE (tie_write (& fx , "src/lib.c" , changed ));
1158+ ASSERT_TRUE (tie_commit (& fx , "change lib_value, the field, the short global" ));
1159+ char * json = tie_answer (& fx );
1160+ ASSERT_NOT_NULL (json );
1161+ bool want = tie_suite_has (json , "alpha" , "STATIC" ) && tie_suite_has (json , "beta" , "STATIC" ) &&
1162+ !tie_suite_has (json , "gamma" , "STATIC" ) &&
1163+ !tie_suite_has (json , "delta" , "STATIC" ) &&
1164+ !tie_suite_has (json , "epsilon" , "STATIC" );
1165+ if (!want ) {
1166+ printf (" note: %s\n %.2400s\n" , tie_last_note , json );
1167+ }
1168+ ASSERT_TRUE (tie_suite_has (json , "alpha" , "STATIC" )); /* calls lib_value */
1169+ ASSERT_TRUE (tie_suite_has (json , "beta" , "STATIC" )); /* its helper's gap names lib_value */
1170+ ASSERT_FALSE (tie_suite_has (json , "gamma" , "STATIC" )); /* a file-scope gap's file */
1171+ ASSERT_FALSE (tie_suite_has (json , "delta" , "STATIC" )); /* gap word = a changed field */
1172+ ASSERT_FALSE (tie_suite_has (json , "epsilon" , "STATIC" )); /* gap word = a 2-letter global */
1173+ free (json );
1174+ tie_close (& fx );
1175+ PASS ();
1176+ }
1177+
10801178/* The base commit's object id, read from the branch ref (never packed here). */
10811179static bool tie_base_sha (tie_fixture_t * fx , char sha [65 ]) {
10821180 char path [1200 ];
@@ -1378,6 +1476,7 @@ SUITE(test_impact_engine) {
13781476 RUN_TEST (test_impact_engine_reached_role_handler_is_no_way_into_main );
13791477 RUN_TEST (test_impact_engine_role_started_by_a_role_selects_its_spawners );
13801478 RUN_TEST (test_impact_engine_parse_gaps_reach_what_they_name );
1479+ RUN_TEST (test_impact_engine_parse_gaps_name_only_reached_functions );
13811480 RUN_TEST (test_impact_engine_admitted_coverage_narrows_only_when_verified );
13821481 RUN_TEST (test_impact_engine_coverage_reaches_unmapped_code_through_mapped_callers );
13831482}
0 commit comments