MCPcopy
hub / github.com/github/awesome-copilot / check_test_file_extension

Function check_test_file_extension

skills/quality-playbook/quality_gate.py:1272–1317  ·  view source on GitHub ↗

Test file extension matches project language (benchmark 47).

(repo_dir, q)

Source from the content-addressed store, hash-verified

1270
1271
1272def check_test_file_extension(repo_dir, q):
1273 """Test file extension matches project language (benchmark 47)."""
1274 print("[Test File Extension]")
1275 func_test = first_file_matching(q, ["test_functional.*", "functional_test.*",
1276 "FunctionalSpec.*", "FunctionalTest.*",
1277 "functional.test.*"])
1278 reg_test = first_file_matching(q, ["test_regression.*"])
1279
1280 if func_test is None:
1281 warn("No functional test file found across the supported naming matrix")
1282 return
1283
1284 ext = func_test.suffix.lstrip(".") if func_test.suffix else ""
1285 detected_lang = detect_project_language(repo_dir) if repo_dir.is_dir() else ""
1286
1287 if not detected_lang:
1288 info(f"Cannot detect project language — skipping extension check (test_functional.{ext})")
1289 return
1290
1291 lang_to_valid = {
1292 "go": "go",
1293 "py": "py",
1294 "java": "java",
1295 "kt": "kt java",
1296 "rs": "rs",
1297 "ts": "ts",
1298 "js": "js ts",
1299 "scala": "scala",
1300 "c": "c py sh",
1301 "agc": "py sh",
1302 }
1303 valid_ext = lang_to_valid.get(detected_lang, "")
1304 valid_list = valid_ext.split()
1305 primary = valid_list[0] if valid_list else ""
1306
1307 if ext in valid_list:
1308 pass_(f"{func_test.name} matches project language ({detected_lang})")
1309 else:
1310 fail(f"{func_test.name} does not match project language ({detected_lang}) — expected .{primary}")
1311
1312 if reg_test is not None:
1313 reg_ext = reg_test.suffix.lstrip(".") if reg_test.suffix else ""
1314 if reg_ext in valid_list:
1315 pass_(f"test_regression.{reg_ext} matches project language ({detected_lang})")
1316 else:
1317 fail(f"test_regression.{reg_ext} does not match project language ({detected_lang}) — expected .{primary}")
1318
1319
1320def check_terminal_gate(q):

Callers 1

check_repoFunction · 0.85

Calls 6

first_file_matchingFunction · 0.85
detect_project_languageFunction · 0.85
pass_Function · 0.85
failFunction · 0.85
warnFunction · 0.70
infoFunction · 0.70

Tested by

no test coverage detected