dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Compare Notes Search Review guide test: sweep stale fixture homes c6ea3f87995b5804afe8c1a579bbb66d25461f3e
Oliver Jan Krylow <oliver@bugabinga.net > · 18 Sep 2026
SSH signature · not checked
Browse files Compare with HEAD
runs that die before the finally block leave dotfiles-*-<random> homes behind. mark fixtures, delete them on shutdown, and sweep marked leftovers at startup for non-child suites.
Changed files (1) scripts/dotfiles_integration_test.java Modified 9 9 static final Path SETSID = findExecutable(
"setsid" );
10 10 static final Path KILL = findExecutable(
"kill" );
11 11 static final Set <
Long >
ACTIVE_PROCESS_GROUPS = java .
util .
concurrent .
ConcurrentHashMap .newKeySet();
12 + static final Set <
Path >
ACTIVE_FIXTURES = java .
util .
concurrent .
ConcurrentHashMap .newKeySet();
13 + static final String FIXTURE_MARKER = ".dotfiles-test-fixture" ;
14 + static final Set <
String >
CHILD_SUITES = Set .of(
"--process-cancellation-child" ,
"--process-inherit-cancellation-child" );
14 - Runtime .getRuntime().addShutdownHook(
new Thread (()
-> ACTIVE_PROCESS_GROUPS .forEach(dotfiles_integration_test::killGroup),
"dotfiles-test-process-cleanup" ));
17 + Runtime .getRuntime().addShutdownHook(
new Thread (()
-> {
18 + ACTIVE_PROCESS_GROUPS .forEach(dotfiles_integration_test::killGroup);
19 + ACTIVE_FIXTURES .forEach(dotfiles_integration_test::deleteTreeQuietly);
20 + },
"dotfiles-test-cleanup" ));
17 23 public static void main(
String [] args) throws
Exception {
18 24 root
= Path .of(run(
null ,
"git" ,
"rev-parse" ,
"--show-toplevel" ).trim());
26 + if (args.length
== 0 || ! CHILD_SUITES .contains(args[
0 ])) sweepStaleFixtures();
19 27 if (args.length
== 0 ) host();
20 28 else switch (args[
0 ]) {
21 29 case "--inside" -> inside();
392 400 static void withFixture(
String name,
FixtureCheck check) throws
Exception {
393 401 var home
= Files .createTempDirectory(
Path .of(
System .getProperty(
"user.home" )),
"dotfiles-" + name
+ "-" );
402 + Files .writeString(home.resolve(
FIXTURE_MARKER ), name
+ "\n" );
403 + ACTIVE_FIXTURES .add(home);
394 404 var started
= System .nanoTime();
396 406 check.run(createFixture(home));
397 407 ok(name
+ ":" + Duration .ofNanos(
System .nanoTime()
- started).toMillis()
+ "ms" );
409 + ACTIVE_FIXTURES .remove(home);
399 410 deleteTree(home);
1000 + static void deleteTreeQuietly(
Path p) {
1003 + }
catch (
IOException e) {
1004 + log(
"cleanup-failed:" + p
+ ":" + e.getMessage());
1009 + static void sweepStaleFixtures() throws
IOException {
1010 + var home
= Path .of(
System .getProperty(
"user.home" ));
1011 + try (
var entries
= Files .list(home)) {
1012 + for (
var stale
: entries.filter(entry
-> Files .isRegularFile(entry.resolve(
FIXTURE_MARKER ))).toList()) {
1013 + log(
"sweep:" + stale.getFileName());
1014 + deleteTreeQuietly(stale);
989 1019 static void step(
String what) { log(
"step:" + what); }
990 1020 static void ok(
String what) { log(
"ok:" + what); }
991 1021 static void log(
String message) {
System .out.println(message);
System .out.flush(); }