fix: isolate CHRNX local integration state

This commit is contained in:
chrnx committed 2026-08-12 09:48:12 -05:00
1 parent 21da6da227
commit 6e93c0ad20
16 files changed
+536 -65

No files matched your search

+13 -2
View File
@@ -1,5 +1,5 @@
import assert from 'node:assert/strict';
import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync } from 'node:fs';
import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
@@ -77,10 +77,19 @@ test( 'the visual layer is separately enqueued and covers responsive accessible
} );
test( 'all approved portraits rebuild byte-identically within payload bounds', () => {
const output = mkdtempSync( join( tmpdir(), 'chrnx-image-test-' ) );
const readme = read( 'README.md' );
const documentedCommand = 'mktemp -d "${TMPDIR:-/tmp}/chrnx-responsive.XXXXXX"';
assert.ok( readme.includes( documentedCommand ) );
const output = execFileSync( 'sh', [ '-c', documentedCommand ], { encoding: 'utf8' } ).trim();
const unsafeOutput = join( output, 'unsafe-output' );
const external = mkdtempSync( join( tmpdir(), 'chrnx-external-' ) );
const symlink = join( tmpdir(), `chrnx-symlink-${ process.pid }` );
try {
assert.throws( () => execFileSync( './scripts/build-responsive-images.sh', [ unsafeOutput ], { cwd: new URL( '../..', import.meta.url ) } ) );
writeFileSync( join( external, 'sentinel' ), 'unchanged' );
symlinkSync( external, symlink );
assert.throws( () => execFileSync( './scripts/build-responsive-images.sh', [ symlink ], { cwd: new URL( '../..', import.meta.url ) } ) );
assert.deepEqual( readdirSync( external ), [ 'sentinel' ] );
execFileSync( './scripts/build-responsive-images.sh', [ output ], { cwd: new URL( '../..', import.meta.url ) } );
const names = readdirSync( output ).sort();
assert.equal( names.length, 35 );
@@ -107,6 +116,8 @@ test( 'all approved portraits rebuild byte-identically within payload bounds', (
assert.ok( total <= 1.7 * 1024 * 1024, `derivatives exceed 1.7 MiB: ${ total }` );
} finally {
rmSync( output, { recursive: true, force: true } );
rmSync( external, { recursive: true, force: true } );
rmSync( symlink, { force: true } );
}
} );