Commit graph Crafter.Build/tests/TestTemporaryDirectory
Author SHA1 Message Date
ab8935826d
test: what a test leaves in its TMPDIR, kept when it fails, else gone
TestTemporaryDirectory runs a probe through RunTests that records the
TMPDIR it was given and the directory fs::temp_directory_path() names,
leaves a file there and exits as it is told. Two configurations each
declare a passing test named probe, built differently so that the run
does not refuse them, and the second also a failing one and one for
another target, the host's own triple without its vendor and with x32
after it, which is never the host's and makes a second pass after the
host's, and is skipped before it is built. The run takes one test at a
time, so the failing one comes last in the host's pass, and it dates
the run's directory, and a directory beside it that looks like one a
run let go of, two minutes back before it fails, as a test that ran
that long leaves them. Each test's fs::temp_directory_path() is the
TMPDIR it was given: <run>/<name>, in a directory made for the run in
the temp directory, and probe-2 for the second probe. What the passing
tests left is removed; what the failing one left is kept, named in its
output and its log, and so is the run's directory. A second run gets a
directory of its own, removes it since every test passed, and leaves
the first run's alone; a third, once that one is dated past the minute,
removes it. The other target's pass makes no directory of its own: the
one dated back beside the run's is still there when the run ends. A
fourth run, whose pass for the other target throws, as one does where
CRAFTER_BUILD_RUNNER_ names that target's runner wrong, keeps what its
first pass kept.

The runs make their directories in a temp directory the test makes for
them and names with TMPDIR. The test removes only its own scratch
directory, which holds that one, and the fixture's bin/ and build/, and
dates a directory a probe reports only when it is a run's directory in
that temp directory.

HeadlessCompositor checks that a test that sets wayland and is given a
TMPDIR runs with both: the TMPDIR it is given and its compositor's
display alone, and that one under `host` and given a TMPDIR has it
beside the session's display. Two failing tests of one name each have a
log of their own, twin.log and twin-2.log, that says where what each
left is kept. RunSingleTestExit runs a script whose path has an '=' in
it, given a TMPDIR, which has to run and whose exit decides the
outcome.

Without TMPDIR on the test's command, 13 of TestTemporaryDirectory's
checks fail; with a test's log named after the test alone, the two on
the logs of the tests of one name do; without the date a kept directory
gets as it is let go of, the one on the second run leaving the first
run's alone does; with a directory of its own for a later pass, beside
the run's, the one on the other target's pass does; and with the
directory kept only once RunTests returns, the one on the fourth run
does. With the test's own words as env's command, the two of
RunSingleTestExit on the script whose path has an '=' fail.
2026-11-28 11:05:51 +01:00