@feigi/fleet-ctl 3.22.1 → 3.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/reap.test.mjs +34 -2
package/package.json
CHANGED
package/scripts/reap.test.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import assert from "node:assert/strict";
|
|
|
13
13
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
14
14
|
import { chmodSync, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
15
15
|
import { tmpdir } from "node:os";
|
|
16
|
-
import { join } from "node:path";
|
|
16
|
+
import { dirname, join } from "node:path";
|
|
17
17
|
import { fileURLToPath } from "node:url";
|
|
18
18
|
import { slowTransport, SSH_URL } from "./slow-transport.mjs";
|
|
19
19
|
import { writeExecStub } from "./exec-stub.mjs";
|
|
@@ -41,8 +41,14 @@ const ENV = {
|
|
|
41
41
|
GIT_CONFIG_SYSTEM: "/dev/null",
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
// `maintenance.auto=false` on every fixture call: fetch, commit and merge start
|
|
45
|
+
// a detached `git maintenance run --auto`, whose `worktree-prune` task can erase
|
|
46
|
+
// a deliberately faulted `gitdir` before the script under test reads the
|
|
47
|
+
// registry, leaving the test to check a consistent registry instead of the
|
|
48
|
+
// fault. Kept out of ENV, which also reaches reap.sh's own git calls and would
|
|
49
|
+
// hide a lapse in net_git's own suppression.
|
|
44
50
|
const git = (cwd, ...args) =>
|
|
45
|
-
execFileSync("git", args, { cwd, env: ENV, encoding: "utf8" }).trim();
|
|
51
|
+
execFileSync("git", ["-c", "maintenance.auto=false", ...args], { cwd, env: ENV, encoding: "utf8" }).trim();
|
|
46
52
|
|
|
47
53
|
/** worktreeNames() of `w`'s listing: never its paths, which carry TMPDIR (#2531). */
|
|
48
54
|
const listedNames = (w) => worktreeNames(git(w, "worktree", "list", "--porcelain"));
|
|
@@ -4398,3 +4404,29 @@ for (const m of SIBLING_MUTATIONS) {
|
|
|
4398
4404
|
assert.equal(branchExists(w, "feature/free"), false);
|
|
4399
4405
|
});
|
|
4400
4406
|
}
|
|
4407
|
+
|
|
4408
|
+
// The `maintenance.auto=false` the `git` helper carries (see the comment above
|
|
4409
|
+
// it) cannot be pinned by the gitdir fault fixtures: the race it prevents is
|
|
4410
|
+
// timing-dependent, so those stay green with the flag gone. What is
|
|
4411
|
+
// deterministic is the spawn itself — a commit or a fetch through the helper
|
|
4412
|
+
// must leave no `git maintenance run` in a GIT_TRACE. The trace is switched on
|
|
4413
|
+
// through ENV, the object the helper hands its child, because the helper takes
|
|
4414
|
+
// no env of its own; node:test runs a file's tests one at a time, so nothing
|
|
4415
|
+
// else spawns git while it is set. The first two assertions are the positive
|
|
4416
|
+
// control: without them a trace the child never wrote would pass the last.
|
|
4417
|
+
test("the fixture git() helper suppresses the detached auto-maintenance run", (t) => {
|
|
4418
|
+
const w = repo(t);
|
|
4419
|
+
const trace = join(dirname(w), "trace.txt");
|
|
4420
|
+
writeFileSync(trace, "");
|
|
4421
|
+
ENV.GIT_TRACE = trace;
|
|
4422
|
+
try {
|
|
4423
|
+
commit(w, "probe");
|
|
4424
|
+
git(w, "fetch", "-q", "--prune", "origin");
|
|
4425
|
+
} finally {
|
|
4426
|
+
delete ENV.GIT_TRACE;
|
|
4427
|
+
}
|
|
4428
|
+
const traced = readFileSync(trace, "utf8");
|
|
4429
|
+
assert.match(traced, /built-in: git commit/, "the trace reached the commit");
|
|
4430
|
+
assert.match(traced, /built-in: git fetch/, "the trace reached the fetch");
|
|
4431
|
+
assert.doesNotMatch(traced, /maintenance run/);
|
|
4432
|
+
});
|