Connects scan + lock + pack + write into the full pipeline. CLI entry parses args, dispatches to bake(), prints summary or error. Five integration tests cover fresh bake, lock-aware ID preservation, deleted-tile tracking, oversize hard-fail, and bit-identical determinism across re-bakes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert');
|
|
const path = require('node:path');
|
|
const fs = require('node:fs');
|
|
const os = require('node:os');
|
|
const crypto = require('node:crypto');
|
|
const { bake } = require('../src/bake');
|
|
|
|
const FIX = path.resolve(__dirname, 'fixtures/small-fresh');
|
|
|
|
function hashFile(p) {
|
|
return crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
|
|
}
|
|
|
|
test('bake-determinism: two fresh bakes produce identical outputs', async () => {
|
|
const out1 = fs.mkdtempSync(path.join(os.tmpdir(), 'atlas-det1-'));
|
|
const out2 = fs.mkdtempSync(path.join(os.tmpdir(), 'atlas-det2-'));
|
|
try {
|
|
await bake({ inDir: FIX, outDir: out1, atlasId: 'd', tileSize: 32 });
|
|
await bake({ inDir: FIX, outDir: out2, atlasId: 'd', tileSize: 32 });
|
|
const files = ['tiles.diffuse.atlas.png', 'tiles.height.atlas.png',
|
|
'tiles.atlas.json', 'tiles.atlas.lock.json'];
|
|
for (const f of files) {
|
|
assert.strictEqual(
|
|
hashFile(path.join(out1, f)),
|
|
hashFile(path.join(out2, f)),
|
|
`${f} not bit-identical`,
|
|
);
|
|
}
|
|
} finally {
|
|
fs.rmSync(out1, { recursive: true, force: true });
|
|
fs.rmSync(out2, { recursive: true, force: true });
|
|
}
|
|
});
|