test: add standalone area fixtures

This commit is contained in:
2026-08-26 09:13:44 +08:00
parent 208df9e6af
commit 90400d967f
3 changed files with 30 additions and 4 deletions

View File

@@ -8,4 +8,4 @@ npx road-compiler --input /absolute/path/road-compiler.input.json
The compiler does not read host area configuration. The caller owns configuration normalization and creates the input JSON. Successful compilation writes exactly one `NATIVE_ROAD_COMPILE_DONE` JSON marker to stdout.
Run `npm test` and `npm run test:road-parity` after `npm ci` to validate the package without the host repository.
Run `npm test` after `npm ci` to validate the package and its two self-contained area fixtures without the host repository. The migrated baselines remain upgrade corpus; the host repository owns the strict path-normalized parity gate.

View File

@@ -1,6 +1,6 @@
{
"name": "@osm-asset/road-compiler",
"version": "0.1.0",
"version": "0.1.2",
"private": false,
"type": "commonjs",
"main": "src/index.js",
@@ -8,8 +8,7 @@
"road-compiler": "bin/road-compiler.js"
},
"scripts": {
"test": "node test/index.js",
"test:road-parity": "node test/road-parity.js",
"test": "node test/index.js && node test/fixtures.js",
"road:workbench": "node bin/road-workbench.js"
},
"dependencies": {

27
test/fixtures.js Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
const assert = require("assert/strict");
const fs = require("fs");
const path = require("path");
const { compiler } = require("../src");
const root = path.resolve(__dirname, "..");
for (const areaId of ["fengshu-er-road", "nantaizi-lake-innovation-valley"]) {
const isFengshu = areaId === "fengshu-er-road";
const outputRoot = path.join(root, "outputs", areaId);
const input = {
areaId,
osmFile: path.join(root, "inputs", "osm", isFengshu ? "枫树二路.osm" : "南台子湖创新谷OSM.osm"),
outDir: path.join(outputRoot, "native-road"),
stagingDir: path.join(outputRoot, "_pipeline"),
overridesFile: path.join(outputRoot, "native-road-overrides.json"),
trafficSignalsFile: path.join(outputRoot, "native-traffic-signals.json"),
comparisonDir: path.join(outputRoot, "osm2streets_web_out"),
options: { edgeLines: false, junctionTemplates: { enabled: false, references: [] } },
};
assert.ok(fs.existsSync(path.join(root, "test", "baseline", `${areaId}.json`)));
const { result } = compiler.compileInput(input);
assert.equal(result.areaId, areaId);
assert.ok(fs.existsSync(path.join(input.outDir, "compiled.json")));
}
console.log("road compiler fixture tests passed");