Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

test: correct Windows path fixtures without relaxing contracts

sunsunsunff8845e55c9e
diff --git a/archify/test/delivery-sidecar-path.test.mjs b/archify/test/delivery-sidecar-path.test.mjs
index 31a8a62b..21fc3bad 100644
--- a/archify/test/delivery-sidecar-path.test.mjs
+++ b/archify/test/delivery-sidecar-path.test.mjs
@@ -1110,11 +1110,25 @@ test('Windows delivery accepts an existing 8.3 artifact alias and keeps strict p
const redelivered = run(['deliver', 'workflow', input, shortOutput, '--json'], cwd);
assert.equal(redelivered.status, 0, redelivered.stderr || redelivered.stdout);
- for (const artifact of [output, shortOutput]) {
- const checked = run(['check', artifact, '--require-provenance'], cwd);
- assert.equal(checked.status, 0, checked.stderr || checked.stdout);
- assert.equal(JSON.parse(checked.stdout).provenance, 'current');
- }
+ const checkedOutput = run(['check', output, '--require-provenance'], cwd);
+ assert.equal(checkedOutput.status, 0, checkedOutput.stderr || checkedOutput.stdout);
+ assert.equal(JSON.parse(checkedOutput.stdout).provenance, 'current');
+
+ // Publication replaces the directory entry. NTFS need not transfer an
+ // explicitly assigned short name from the retired entry to its successor.
+ // Exercise the current artifact's alias, not the old entry's cached name.
+ const currentShortOutput = controlledRoot
+ ? assignWindowsShortName(output, 'ARCHDL~2.HTM')
+ : windowsShortPath(output);
+ assert.ok(currentShortOutput, 'the current artifact must expose a distinct 8.3 alias');
+ assert.equal(path.win32.extname(currentShortOutput).toLowerCase(), '.htm');
+ const checkedAlias = run(['check', currentShortOutput, '--require-provenance'], cwd);
+ assert.equal(checkedAlias.status, 0, checkedAlias.stderr || checkedAlias.stdout);
+ assert.equal(JSON.parse(checkedAlias.stdout).provenance, 'current');
+ assert.deepEqual(fs.readdirSync(directory).sort(), [
+ path.basename(output),
+ path.basename(output).replace(/\.html$/u, '.delivery.json'),
+ ].sort(), 'redelivery through an alias must keep one canonical artifact and provenance pair');
});
test('normalization aliases contend for one future long-stem delivery lock', async (t) => {
diff --git a/archify/test/output-path.test.mjs b/archify/test/output-path.test.mjs
index 31478fd1..54c35233 100644
--- a/archify/test/output-path.test.mjs
+++ b/archify/test/output-path.test.mjs
@@ -345,9 +345,7 @@ console.log(JSON.stringify({
await new Promise((resolve) => setTimeout(resolve, 20));
}
assert.equal(fs.existsSync(marker), true, `renderer did not start; stderr=${stderr}`);
- const candidatePath = fs.readFileSync(marker, 'utf8');
- const candidateRelative = path.relative(linkedDirectory, candidatePath);
- fs.mkdirSync(path.dirname(path.join(inputDirectory, candidateRelative)), { recursive: true });
+ // Staging stays in the physical output directory when this alias is retargeted.
fs.unlinkSync(linkedDirectory);
fs.symlinkSync(inputDirectory, linkedDirectory, 'dir');
@@ -1087,9 +1085,7 @@ export const validateArchitectureDeltaHtml = () => ({ checksPassed: 1, checkCoun
await new Promise((resolve) => setTimeout(resolve, 20));
}
assert.equal(fs.existsSync(marker), true, `renderer did not start; stderr=${stderr}`);
- const candidatePath = fs.readFileSync(marker, 'utf8');
- const candidateRelative = path.relative(linkedDirectory, candidatePath);
- fs.mkdirSync(path.dirname(path.join(inputDirectory, candidateRelative)), { recursive: true });
+ // Staging stays in the physical output directory when this alias is retargeted.
fs.unlinkSync(linkedDirectory);
fs.symlinkSync(inputDirectory, linkedDirectory, 'dir');
diff --git a/archify/test/release-package-gates.test.mjs b/archify/test/release-package-gates.test.mjs
index 3baefcb5..988c7f2a 100644
--- a/archify/test/release-package-gates.test.mjs
+++ b/archify/test/release-package-gates.test.mjs
@@ -20,20 +20,34 @@ const canonicalZipTest = (name, fn) => test(name, {
function spawnBuildZip(outputPath, options = {}) {
const script = path.join(repoRoot, 'scripts', 'build-zip.sh');
- const { cwd = repoRoot, ...rest } = options;
- if (process.platform === 'win32') {
- const bashCandidates = [
+ const { cwd = repoRoot, env = process.env, ...rest } = options;
+ const bashCandidates = process.platform === 'win32'
+ ? [
process.env.BASH,
'C:\\Program Files\\Git\\bin\\bash.exe',
'bash',
- ].filter(Boolean);
- for (const bash of bashCandidates) {
- if (bash.includes('\\') && !fs.existsSync(bash)) continue;
- const result = spawnSync(bash, [script, outputPath], { cwd, encoding: 'utf8', ...rest });
- if (result.status !== 127) return result;
- }
+ ].filter(Boolean)
+ : ['bash'];
+ for (const bash of bashCandidates) {
+ if (bash.includes('\\') && !fs.existsSync(bash)) continue;
+ // Native Windows argv decoding and MSYS path conversion must not alter
+ // the deliberately unsafe raw spelling before the validator sees it.
+ const result = spawnSync(bash, [
+ '-c', 'exec bash "$ARCHIFY_ZIP_BUILD_SCRIPT" "$ARCHIFY_ZIP_BUILD_OUTPUT"',
+ ], {
+ cwd,
+ encoding: 'utf8',
+ ...rest,
+ env: {
+ ...env,
+ ARCHIFY_ZIP_BUILD_SCRIPT: script,
+ ARCHIFY_ZIP_BUILD_OUTPUT: outputPath,
+ MSYS2_ARG_CONV_EXCL: outputPath,
+ },
+ });
+ if (result.status !== 127) return result;
}
- return spawnSync(script, [outputPath], { cwd, encoding: 'utf8', ...rest });
+ return spawnSync(script, [outputPath], { cwd, env, encoding: 'utf8', ...rest });
}
function preparePackageIndex(indexPath, extraPaths) {
@@ -497,6 +511,8 @@ test('archive build rejects unsafe native output paths before creating files', (
assert.equal(build.status, 2, `${build.stdout}\n${build.stderr}`);
assert.match(build.stderr, /archive output is not a valid native filesystem path/);
assert.match(build.stderr, expectedReason);
+ assert.ok(build.stderr.includes(JSON.stringify(output)),
+ 'the archive validator must receive the exact raw output spelling');
assert.deepEqual(fs.readdirSync(fixture), [], 'a rejected output spelling must not create files');
}
} finally {
diff --git a/archify/test/sidecar-path-length.test.mjs b/archify/test/sidecar-path-length.test.mjs
index 4d5d06ba..15fdfd4b 100644
--- a/archify/test/sidecar-path-length.test.mjs
+++ b/archify/test/sidecar-path-length.test.mjs
@@ -81,10 +81,12 @@ function controlledWindowsShortRoot(required) {
return { root, shortRoot };
}
-test('visual-check deterministically bounds every derived sidecar component', () => {
+test('visual-check deterministically bounds every derived sidecar component', (t) => {
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-bounded-'));
+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
const stem = 'é'.repeat(120);
- const first = sidecarPaths(`/tmp/${stem}.html`);
- const second = sidecarPaths(`/tmp/${stem}.html`);
+ const first = sidecarPaths(path.join(directory, `${stem}.html`));
+ const second = sidecarPaths(path.join(directory, `${stem}.html`));
const files = [first.receipt, first.contactSheet, ...first.screenshots.map(({ path: file }) => file)];
assert.deepEqual(first, second);
@@ -92,15 +94,19 @@ test('visual-check deterministically bounds every derived sidecar component', ()
assert.match(path.basename(first.receipt), /\.~archify-[0-9a-f]{64}\.visual-check\.json$/);
});
-test('different overlong artifact stems do not collapse to one visual-check sidecar name', () => {
- const left = sidecarPaths(`/tmp/${'x'.repeat(260)}-left.html`);
- const right = sidecarPaths(`/tmp/${'x'.repeat(260)}-right.html`);
+test('different overlong artifact stems do not collapse to one visual-check sidecar name', (t) => {
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-distinct-'));
+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
+ const left = sidecarPaths(path.join(directory, `${'x'.repeat(260)}-left.html`));
+ const right = sidecarPaths(path.join(directory, `${'x'.repeat(260)}-right.html`));
assert.notEqual(path.basename(left.receipt), path.basename(right.receipt));
});
-test('html and htm artifacts use distinct visual-check sidecar namespaces', () => {
- const html = sidecarPaths('/tmp/diagram.html');
- const htm = sidecarPaths('/tmp/diagram.htm');
+test('html and htm artifacts use distinct visual-check sidecar namespaces', (t) => {
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-extensions-'));
+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
+ const html = sidecarPaths(path.join(directory, 'diagram.html'));
+ const htm = sidecarPaths(path.join(directory, 'diagram.htm'));
assert.notEqual(html.receipt, htm.receipt);
assert.equal(path.basename(html.receipt), 'diagram.visual-check.json');
@@ -130,20 +136,24 @@ test('HTML extension case follows the containing filesystem semantics', (t) => {
}
});
-test('bounded html and htm artifacts retain distinct hash namespaces', () => {
+test('bounded html and htm artifacts retain distinct hash namespaces', (t) => {
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-bounded-extensions-'));
+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
const stem = 'x'.repeat(225);
- const html = sidecarPaths(`/tmp/${stem}.html`);
- const htm = sidecarPaths(`/tmp/${stem}.htm`);
+ const html = sidecarPaths(path.join(directory, `${stem}.html`));
+ const htm = sidecarPaths(path.join(directory, `${stem}.htm`));
assert.notEqual(html.receipt, htm.receipt);
assert.match(path.basename(html.receipt), /\.~archify-[0-9a-f]{64}\.visual-check\.json$/u);
assert.match(path.basename(htm.receipt), /\.~archify-[0-9a-f]{64}\.visual-check\.json$/u);
});
-test('a crafted bounded stem cannot enter another artifact visual-check namespace', () => {
- const long = sidecarPaths(`/tmp/${'x'.repeat(245)}.html`);
+test('a crafted bounded stem cannot enter another artifact visual-check namespace', (t) => {
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-crafted-stem-'));
+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));
+ const long = sidecarPaths(path.join(directory, `${'x'.repeat(245)}.html`));
const encodedStem = path.basename(long.base).replace(/\.visual-check$/u, '');
- const crafted = sidecarPaths(`/tmp/${encodedStem}.html`);
+ const crafted = sidecarPaths(path.join(directory, `${encodedStem}.html`));
const allPaths = (value) => [
value.receipt,
value.contactSheet,
diff --git a/scripts/run-windows-path-tests.mjs b/scripts/run-windows-path-tests.mjs
index 5626bdbe..b04d698a 100644
--- a/scripts/run-windows-path-tests.mjs
+++ b/scripts/run-windows-path-tests.mjs
@@ -616,6 +616,5 @@ for (const args of groups) {
}
if (result.status !== 0) {
process.exitCode = result.status ?? 1;
- break;
}
}