|
19 | 19 | import unittest |
20 | 20 |
|
21 | 21 | import check_abi_receipt_skips as skips |
| 22 | +from ci_verify import ctest_rows |
22 | 23 | from prepare_settlement_cpp_abi_base import PROVIDERS |
23 | 24 |
|
24 | 25 | # The ctest the CTest row passes with --ctest (CMAKE_CTEST_COMMAND), else PATH's. |
@@ -73,6 +74,9 @@ def test_a_missing_receipt_fails_a_row_registered_to_require_it(self): |
73 | 74 | class AgainstRealCTest(unittest.TestCase): |
74 | 75 | """Rows written to a CTestTestfile.cmake and listed by the real ctest.""" |
75 | 76 |
|
| 77 | + # The gated rows build_tree registers, in the order ctest lists them. |
| 78 | + GATED = ('test_gated_pair', 'test_gated_settlement', 'test_gated_budget') |
| 79 | + |
76 | 80 | @classmethod |
77 | 81 | def setUpClass(cls): |
78 | 82 | if not CTEST: |
@@ -124,7 +128,17 @@ def test_ctest_passes_a_run_in_which_gated_rows_skipped_and_the_check_names_them |
124 | 128 | build = self.build_tree(export_compile_commands=True) |
125 | 129 | run = subprocess.run([CTEST, '--test-dir', str(build)], capture_output=True, text=True) |
126 | 130 | self.assertEqual(run.returncode, 0, run.stdout) |
127 | | - self.assertIn('100% tests passed out of 4', run.stdout) |
| 131 | + # The summary wording is CMake's, not this tree's: 3.28 always spells |
| 132 | + # the failed count, 4.x drops the clause when nothing failed (see |
| 133 | + # CTestSummarySpelling below). Read the counts with ci_verify's parser, |
| 134 | + # the one the CI floor reads the same line with, rather than matching |
| 135 | + # one host's wording. |
| 136 | + # expectation corrected: literal '100% tests passed out of 4' -> |
| 137 | + # ctest_rows() counts, because that string is the CMake >= 4 wording |
| 138 | + # only and ubuntu-24.04 CI runs CMake 3.28. |
| 139 | + rows = ctest_rows(run.stdout.encode()) |
| 140 | + self.assertEqual((rows.total, rows.ran), (4, 1), run.stdout) |
| 141 | + self.assertEqual(rows.skipped, self.GATED, run.stdout) |
128 | 142 | self.assertIn('test_gated_pair (Skipped)', run.stdout) |
129 | 143 | code, out = self.check(build) |
130 | 144 | self.assertEqual(code, 1, out) |
@@ -176,6 +190,45 @@ def test_a_directory_that_is_no_build_tree_is_refused(self): |
176 | 190 | self.assertIn('not a configured CMake build tree', err.getvalue()) |
177 | 191 |
|
178 | 192 |
|
| 193 | +class CTestSummarySpelling(unittest.TestCase): |
| 194 | + """Both wordings CTest prints for the summary the row above reads. |
| 195 | +
|
| 196 | + Verbatim runs of the four rows build_tree registers, three of them |
| 197 | + skipped, on the two CMake generations in use: 3.28.3 is ubuntu-24.04's |
| 198 | + apt cmake, which the kernel-only CI job runs; 4.4.0 is the local macOS |
| 199 | + one. Only the summary line differs, and a row that matched one of them |
| 200 | + literally passed on that host alone -- so the fixtures keep both readable |
| 201 | + from either host. |
| 202 | + """ |
| 203 | + |
| 204 | + ROWS = ('Test project BUILD\n' |
| 205 | + ' Start 1: test_plain_python_row\n' |
| 206 | + '1/4 Test #1: test_plain_python_row ............ Passed 0.01 sec\n' |
| 207 | + ' Start 2: test_gated_pair\n' |
| 208 | + '2/4 Test #2: test_gated_pair ..................***Skipped 0.01 sec\n' |
| 209 | + ' Start 3: test_gated_settlement\n' |
| 210 | + '3/4 Test #3: test_gated_settlement ............***Skipped 0.01 sec\n' |
| 211 | + ' Start 4: test_gated_budget\n' |
| 212 | + '4/4 Test #4: test_gated_budget ................***Skipped 0.01 sec\n') |
| 213 | + DID_NOT_RUN = ('\nTotal Test time (real) = 0.04 sec\n' |
| 214 | + '\nThe following tests did not run:\n' |
| 215 | + '\t 2 - test_gated_pair (Skipped)\n' |
| 216 | + '\t 3 - test_gated_settlement (Skipped)\n' |
| 217 | + '\t 4 - test_gated_budget (Skipped)\n') |
| 218 | + SUMMARIES = { |
| 219 | + 'cmake 3.28.3 (ubuntu-24.04)': '\n100% tests passed, 0 tests failed out of 4\n', |
| 220 | + 'cmake 4.4.0 (macOS)': '\n100% tests passed out of 4\n', |
| 221 | + } |
| 222 | + |
| 223 | + def test_either_wording_reads_as_four_rows_of_which_the_three_gated_skipped(self): |
| 224 | + for spelling, summary in self.SUMMARIES.items(): |
| 225 | + with self.subTest(spelling): |
| 226 | + rows = ctest_rows((self.ROWS + summary + self.DID_NOT_RUN).encode()) |
| 227 | + self.assertEqual((rows.total, rows.ran), (4, 1)) |
| 228 | + self.assertEqual(rows.skipped, AgainstRealCTest.GATED) |
| 229 | + self.assertEqual((rows.not_run, rows.disabled), ((), ())) |
| 230 | + |
| 231 | + |
179 | 232 | class Preparation(unittest.TestCase): |
180 | 233 | """--prepare: the six providers, in ci_verify's order, never over an existing one.""" |
181 | 234 |
|
|
0 commit comments