|
9 | 9 | """ |
10 | 10 | from __future__ import annotations |
11 | 11 |
|
| 12 | +import ast |
12 | 13 | import json |
13 | 14 | import os |
14 | 15 | from pathlib import Path |
@@ -3105,6 +3106,75 @@ def test_red_an_unreadable_pin_fails_the_exclusion_closed(self): |
3105 | 3106 | self.assertEqual(driver.stages[0]['name'], 'ctest-exclusion') |
3106 | 3107 |
|
3107 | 3108 |
|
| 3109 | +class FloorDocsPointAtTheTable(unittest.TestCase): |
| 3110 | + """N3: the floors have ONE source, and the prose says where it is. |
| 3111 | +
|
| 3112 | + KERNEL_MIN_TESTS / RELEASE_MIN_TESTS were a dead second copy: the |
| 3113 | + --min-tests help quoted 325 and 895 (false), and six doc places told |
| 3114 | + contributors to raise the constants. Both names now derive from |
| 3115 | + PRIVATE_FIXTURE_PROFILE_FLOORS, and this control fails when the help |
| 3116 | + text or a doc place goes back to a number of its own. |
| 3117 | + """ |
| 3118 | + |
| 3119 | + STALE_INSTRUCTIONS = ( |
| 3120 | + 'raise the floor in the same commit', |
| 3121 | + 'Raise the constant when a row lands', |
| 3122 | + 'Adding rows means raising the floor', |
| 3123 | + 'raise the floor', |
| 3124 | + ) |
| 3125 | + DOC_PLACES = ('CONTRIBUTING.md', 'docs/pages/contributing-llm.md', |
| 3126 | + 'docs/pages/native-engine.md', 'docs/ci.md', |
| 3127 | + '.github/workflows/ci.yml') |
| 3128 | + |
| 3129 | + def test_the_two_names_derive_from_the_table(self): |
| 3130 | + # AST teeth: the right-hand sides must subscript the table, so |
| 3131 | + # writing a number back into either name fails here. |
| 3132 | + module = ast.parse((ROOT / 'scripts' / 'ci_verify.py').read_text()) |
| 3133 | + assigned = {} |
| 3134 | + for node in module.body: |
| 3135 | + if isinstance(node, ast.Assign) and len(node.targets) == 1: |
| 3136 | + target = node.targets[0] |
| 3137 | + if isinstance(target, ast.Name) and target.id in ( |
| 3138 | + 'KERNEL_MIN_TESTS', 'RELEASE_MIN_TESTS'): |
| 3139 | + assigned[target.id] = node.value |
| 3140 | + self.assertEqual(set(assigned), {'KERNEL_MIN_TESTS', 'RELEASE_MIN_TESTS'}) |
| 3141 | + for name, value in assigned.items(): |
| 3142 | + with self.subTest(name=name): |
| 3143 | + self.assertIsInstance(value, ast.Subscript) |
| 3144 | + base = value |
| 3145 | + while isinstance(base, ast.Subscript): |
| 3146 | + base = base.value |
| 3147 | + self.assertIsInstance(base, ast.Name) |
| 3148 | + self.assertEqual(base.id, 'PRIVATE_FIXTURE_PROFILE_FLOORS') |
| 3149 | + self.assertEqual(ci_verify.KERNEL_MIN_TESTS, |
| 3150 | + ci_verify.PRIVATE_FIXTURE_PROFILE_FLOORS['kernel'][0]) |
| 3151 | + self.assertEqual(ci_verify.RELEASE_MIN_TESTS, |
| 3152 | + ci_verify.PRIVATE_FIXTURE_PROFILE_FLOORS['release'][0]) |
| 3153 | + |
| 3154 | + def test_the_help_text_names_the_table_and_no_stale_number(self): |
| 3155 | + result = subprocess.run( |
| 3156 | + [sys.executable, '-B', str(ROOT / 'scripts' / 'ci_verify.py'), '--help'], |
| 3157 | + capture_output=True, text=True, timeout=60) |
| 3158 | + self.assertEqual(result.returncode, 0, result.stderr) |
| 3159 | + self.assertIn('PRIVATE_FIXTURE_PROFILE_FLOORS', result.stdout) |
| 3160 | + self.assertNotIn('defaults to 325', result.stdout) |
| 3161 | + self.assertNotIn('895', result.stdout) |
| 3162 | + |
| 3163 | + def test_every_doc_place_points_at_the_table(self): |
| 3164 | + for rel in self.DOC_PLACES: |
| 3165 | + text = (ROOT / rel).read_text() |
| 3166 | + with self.subTest(place=rel): |
| 3167 | + self.assertIn('PRIVATE_FIXTURE_PROFILE_FLOORS', text) |
| 3168 | + for stale in self.STALE_INSTRUCTIONS: |
| 3169 | + self.assertNotIn(stale, text) |
| 3170 | + for rel in ('docs/pages/contributing-llm.md', 'docs/pages/native-engine.md', |
| 3171 | + 'CONTRIBUTING.md', '.github/workflows/ci.yml'): |
| 3172 | + with self.subTest(place=rel): |
| 3173 | + text = (ROOT / rel).read_text() |
| 3174 | + self.assertNotIn('KERNEL_MIN_TESTS', text) |
| 3175 | + self.assertNotIn('RELEASE_MIN_TESTS', text) |
| 3176 | + |
| 3177 | + |
3108 | 3178 | class ExamplesAssertLive(unittest.TestCase): |
3109 | 3179 | run_profile = DriverOrderingAndAggregation.run_profile |
3110 | 3180 |
|
|
0 commit comments