Skip to content

Read the EXPECT lines in the xfail driver, when the test runs - #112

Merged
steve-downey merged 1 commit into
bemanproject:mainfrom
steve-downey:xfail-driver-reads-expect
Nov 2, 2026
Merged

steve-downey merged 1 commit into
bemanproject:mainfrom
steve-downey:xfail-driver-reads-expect

Conversation

@steve-downey

Copy link
Copy Markdown
Member

Summary

  • The driver now receives the source path (-DBEMAN_XFAIL_EXPECT_FILE) and reads the // EXPECT: "<regex>" lines when the test runs, instead of the regex being read at configure time and baked into the test command. ctest loads test definitions at startup, so after editing an EXPECT line the first bare ctest run matched the old regex even though the nested build regenerated the test file. Edits now take effect on the next run with no reconfigure or rebuild, and the source is no longer a configure dependency.
  • The scan moves to cmake/beman-xfail-compile-expect.cmake, shared by the driver and by beman_add_xfail_compile_test(), which still rejects a source with no EXPECT line at configure time.
  • The scan uses string operations instead of file(STRINGS) and a list. A regex with an unbalanced [ (such as \[with R = .+foo) stops CMake splitting the list at the next ;, so two EXPECT lines merged and the module rejected them for containing a semicolon. beman.transcode hit this on its first use of the module (Register negative compile tests through beman_add_xfail_compile_test steve-downey/transcode#138).
  • An EXPECT passed as an argument keeps its no-semicolon rule; one read from the source may contain ;.

No registration in tests/beman/expected/CMakeLists.txt changes. The three files are identical to the copies now in beman.transcode.

Test plan

  • ctest -L xfail-compile under gcc-16 (Asan): 59/59 pass
  • ctest -L xfail-compile under clang-23 (Asan): 59/59 pass
  • In beman.transcode with the same files: 27/27 under both compilers, and a broken EXPECT line fails the next bare ctest run without a reconfigure
  • pre-commit run -a passes (gersemi 0.29.2)

The regex for a negative compile test was read from the source at
configure time and baked into the test command. ctest loads the test
definitions when it starts, so after editing an EXPECT line the first bare
`ctest` run still matched the old regex: the nested build regenerated the
test file, but under a ctest that had already read it. Only a build before
ctest, as `make test` does, got the new one first time.

The driver now receives the source path (-DBEMAN_XFAIL_EXPECT_FILE) and
reads the EXPECT lines itself when the test runs, so an edit takes effect
on the next run with neither a reconfigure nor a rebuild, and the source
is no longer a configure dependency. The scan lives in
cmake/beman-xfail-compile-expect.cmake, shared by the driver and by the
registration function, which still rejects a source with no EXPECT line at
configure time.

The scan also stops going through file(STRINGS) and a list. A regex may
contain an unbalanced "[" (as in "\[with R = .+foo"), and CMake does not
split a list at a ";" that follows an unmatched "[", so two EXPECT lines
merged into one that the module then rejected for containing a semicolon.
beman.transcode hit this on its first use of the module. String operations
over the file contents have no such rule. An EXPECT passed as an argument
still travels as -DBEMAN_XFAIL_EXPECT and keeps its no-semicolon rule; a
regex read from the source may contain one.
@steve-downey
steve-downey merged commit 396d94d into bemanproject:main Nov 2, 2026
79 checks passed
@steve-downey
steve-downey deleted the xfail-driver-reads-expect branch November 2, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant