mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-09-05 08:51:53 +02:00
The example/suite runners discarded e.stack via console.error(e.message ?? e), hiding the wasm-function offsets that emsymbolizer needs to map an abort back to C source. A failing test only printed a terse message like "memory access out of bounds" with no trace. - Add reportError() to helpers.js/helpers-tcl.js; print the full stack (falling back to the message). - Wrap command execution in runScript() to name the command that aborted before the error propagates. - Use reportError() in all standalone runners and in all.js/all-tcl.js (full stack to stderr, one-line PASS/FAIL summary kept; tests still run independently). - build.sh: run the --test step in a subshell so its cd does not leak into the --pack step.
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
// drc.js — Run design rule checking and report violations.
|
|
//
|
|
// Usage: node examples/drc.js [magFile [tech]]
|
|
import { createMagic, loadCell, loadScript,
|
|
DEFAULT_TECH, DEFAULT_MAG, reportError } from './helpers.js';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
export async function run({ magFile = DEFAULT_MAG, tech = DEFAULT_TECH } = {}) {
|
|
const output = [];
|
|
const { magic } = await createMagic({
|
|
onPrint: msg => { output.push(msg); console.log('[magic]', msg); },
|
|
onPrintErr: msg => { output.push(msg); console.error('[magic]', msg); },
|
|
});
|
|
const { FS } = magic;
|
|
const { tech: techName, cell } = loadCell(FS, tech, magFile);
|
|
|
|
magic.runScript(loadScript('drc.tcl', techName, cell));
|
|
|
|
// Magic prints "Total DRC errors found: N" at the end of drc listall.
|
|
const summary = output.find(l => /Total DRC errors/i.test(l));
|
|
const match = summary?.match(/(\d+)/);
|
|
const violations = match ? parseInt(match[1], 10) : null;
|
|
|
|
return { violations, output };
|
|
}
|
|
|
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
const { violations } = await run().catch(e => { reportError(e); process.exit(1); });
|
|
console.log(`\nDRC violations: ${violations ?? '(count not found in output)'}`);
|
|
console.log('Done.');
|
|
}
|