mirror of
https://github.com/gittrahan/support-fins.git
synced 2026-10-19 02:10:52 -05:00
tests: build file paths with fileURLToPath so the suite runs on Windows (#230)
URL.pathname gives '/C:/dir%20with%20space/...' on Windows, so every test that reads a model or fixture failed there (75 of 265). import() specifiers keep the URL; disk reads take a filesystem path.
This commit is contained in:
1 parent
8ada90d498
commit
0887505092
7 files changed
+17
-9
No files matched your search
@@ -12,6 +12,7 @@
|
||||
// file is exit 1 and the other files still get their fins.
|
||||
//
|
||||
// deno test -A plugins/cli/tests/
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { run, pose, rotationMatrix, parseArgs } from '../cli.js';
|
||||
import { computeFins, ENGINE_DEFAULTS } from '../../shared/engine/fins_entry.js';
|
||||
import { reportLine } from '../../shared/engine/report.js';
|
||||
@@ -251,7 +252,7 @@ Deno.test('cli: the summary line says what was left unsupported, word for word w
|
||||
py = new Deno.Command('python3', {
|
||||
args: ['-c', 'import sys, json; sys.path.insert(0, sys.argv[1]); from supportfins_host import host_report; '
|
||||
+ 'print(json.dumps([host_report(s) for s in json.loads(sys.argv[2])]))',
|
||||
new URL('../../shared/py/', import.meta.url).pathname, JSON.stringify(samples)],
|
||||
fileURLToPath(new URL('../../shared/py/', import.meta.url)), JSON.stringify(samples)],
|
||||
stdout: 'piped', stderr: 'piped',
|
||||
}).outputSync();
|
||||
} catch { return; } // no python3 here: the JS line is still pinned above
|
||||
|
||||
+6
-2
@@ -2,8 +2,12 @@
|
||||
// --allow-read tests/` runs offline. The support engine is pure geometry, so
|
||||
// every test is: build some geometry, assert an invariant on the triangle soup.
|
||||
|
||||
export const WEB = new URL('../web/', import.meta.url).pathname;
|
||||
export const MODELS = new URL('../prototype/stress/models/', import.meta.url).pathname;
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
// WEB is used in import(): keep it a URL string. MODELS is read from disk: make it a
|
||||
// filesystem path. URL.pathname is neither on Windows (leading slash, %20 for spaces).
|
||||
export const WEB = new URL('../web/', import.meta.url).href;
|
||||
export const MODELS = fileURLToPath(new URL('../prototype/stress/models/', import.meta.url));
|
||||
|
||||
export const { buildTopology, analyze } = await import(`${WEB}overhangs.js`);
|
||||
export const fins = await import(`${WEB}fins.js`);
|
||||
|
||||
@@ -12,7 +12,7 @@ const DIR = new URL('../web/calibration/', import.meta.url);
|
||||
const PROTO = new URL('../prototype/calibration/', import.meta.url);
|
||||
|
||||
// calibrate.js touches the DOM on import, so read its file list from the source
|
||||
const src = await Deno.readTextFile(`${WEB}ui/calibrate.js`);
|
||||
const src = await Deno.readTextFile(new URL('ui/calibrate.js', WEB));
|
||||
const files = [...src.matchAll(/file: '([^']+)'/g)].map((m) => m[1]);
|
||||
const est = JSON.parse(await Deno.readTextFile(new URL('coupons.json', DIR)));
|
||||
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
// (fins.js applyTunables), so reading defaults back from FIN / PAD / PROP would carry
|
||||
// one scene's material into the next -- the PETG scene did, into four PLA goldens.
|
||||
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { r3, run } from './_scene.js';
|
||||
|
||||
const DIR = new URL('./golden/', import.meta.url).pathname;
|
||||
const DIR = fileURLToPath(new URL('./golden/', import.meta.url));
|
||||
const UPDATE = Deno.env.get('UPDATE_GOLDEN') === '1';
|
||||
|
||||
const SCENES = [
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
// curved underside the tube route gave nothing), it never costs grip or wedges,
|
||||
// and `raster: false` builds the normal pass alone. The short-wall last resort
|
||||
// (fins/shortwalls.js) is off throughout: it fills what raster:false leaves bare.
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { buildTopology, analyze, fins, prop, assert, readSTL, rotX, loadModel } from './_util.js';
|
||||
import { gripRise } from '../web/prop/raster.js';
|
||||
|
||||
const FIXTURES = new URL('./fixtures/', import.meta.url).pathname; // gen_curved.py
|
||||
const FIXTURES = fileURLToPath(new URL('./fixtures/', import.meta.url)); // gen_curved.py
|
||||
const example = (name) => {
|
||||
const pos = readSTL(Deno.readFileSync(`${FIXTURES}${name}.stl`));
|
||||
return buildTopology({ getAttribute: (k) => (k === 'position' ? { array: pos } : null) });
|
||||
|
||||
+3
-2
@@ -14,12 +14,13 @@
|
||||
// bracket next to a separate 10 mm peg.
|
||||
|
||||
import { createRequire } from 'node:module';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { WEB, fins, buildTopology, analyze, rotX, isClosed, assert, assertClose } from './_util.js';
|
||||
|
||||
const { isStep, stepObjects, STEP_PARAMS } = await import(`${WEB}step.js`);
|
||||
|
||||
const FIX = new URL('./fixtures/', import.meta.url).pathname;
|
||||
const OCCT = `${WEB}vendor/occt-import-js-0.0.23/`;
|
||||
const FIX = fileURLToPath(new URL('./fixtures/', import.meta.url));
|
||||
const OCCT = fileURLToPath(new URL('../web/vendor/occt-import-js-0.0.23/', import.meta.url));
|
||||
|
||||
const occtimportjs = createRequire(import.meta.url)(`${OCCT}occt-import-js.js`);
|
||||
const occt = await occtimportjs({ wasmBinary: Deno.readFileSync(`${OCCT}occt-import-js.wasm`) });
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import { block, blockTopo, buildTopology, analyze, fins, insideCount, isClosed,
|
||||
|
||||
const topoOf = (pos) => buildTopology({ getAttribute: (k) => (k === 'position' ? { array: pos } : null) });
|
||||
|
||||
const WEB = new URL('../web/', import.meta.url).pathname;
|
||||
const WEB = new URL('../web/', import.meta.url).href;
|
||||
const sway = await import(`${WEB}sway.js`);
|
||||
const { insidePart } = await import(`${WEB}inside.js`);
|
||||
|
||||
|
||||
Reference in new issue
Block a user