Wire bake orchestrator and CLI
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>
This commit is contained in:
43
tests/bake-fresh.test.js
Normal file
43
tests/bake-fresh.test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
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 { bake } = require('../src/bake');
|
||||
|
||||
const FIX = path.resolve(__dirname, 'fixtures/small-fresh');
|
||||
|
||||
test('bake-fresh: 3 sources, no lock, IDs 1..3', async () => {
|
||||
const outDir = fs.mkdtempSync(path.join(os.tmpdir(), 'atlas-bake-fresh-'));
|
||||
try {
|
||||
const result = await bake({
|
||||
inDir: FIX,
|
||||
outDir,
|
||||
atlasId: 'small_demo',
|
||||
tileSize: 32,
|
||||
});
|
||||
assert.strictEqual(result.tileCount, 3);
|
||||
|
||||
const atlas = JSON.parse(fs.readFileSync(path.join(outDir, 'tiles.atlas.json'), 'utf8'));
|
||||
assert.strictEqual(atlas.atlas_id, 'small_demo');
|
||||
assert.strictEqual(atlas.tiles.length, 3);
|
||||
// Alphabetical sort: grass < stone < water
|
||||
assert.strictEqual(atlas.tiles[0].name, 'grass');
|
||||
assert.strictEqual(atlas.tiles[0].id, 1);
|
||||
assert.strictEqual(atlas.tiles[1].name, 'stone');
|
||||
assert.strictEqual(atlas.tiles[1].id, 2);
|
||||
assert.strictEqual(atlas.tiles[2].name, 'water');
|
||||
assert.strictEqual(atlas.tiles[2].id, 3);
|
||||
|
||||
const lock = JSON.parse(fs.readFileSync(path.join(outDir, 'tiles.atlas.lock.json'), 'utf8'));
|
||||
assert.strictEqual(lock.bindings.grass, 1);
|
||||
assert.strictEqual(lock.bindings.water, 3);
|
||||
assert.strictEqual(lock.next_id, 4);
|
||||
assert.deepStrictEqual(lock.deleted, []);
|
||||
|
||||
assert.ok(fs.existsSync(path.join(outDir, 'tiles.diffuse.atlas.png')));
|
||||
assert.ok(fs.existsSync(path.join(outDir, 'tiles.height.atlas.png')));
|
||||
} finally {
|
||||
fs.rmSync(outDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user