nomen-lang 0.6.6 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOMEN_AGENTS.md +12 -3
- package/core/System/Buffer.nm +38 -0
- package/dist/index.mjs +942 -229
- package/package.json +1 -1
- package/src/args.ts +1 -1
- package/src/index.ts +1 -0
- package/src/test.ts +40 -3
package/package.json
CHANGED
package/src/args.ts
CHANGED
|
@@ -160,7 +160,7 @@ export function print_help(): void {
|
|
|
160
160
|
" nomen check --in [file/folder] Parse and check only",
|
|
161
161
|
" nomen format [--in folder] Reformat every .nm file",
|
|
162
162
|
" nomen docs [--in file] Generate markdown documentation",
|
|
163
|
-
" nomen test [--in folder] Discover and run *.test.nm files",
|
|
163
|
+
" nomen test [--in folder] Discover and run *.test.nm files (binary CWD = --in folder)",
|
|
164
164
|
" nomen init <name> Scaffold a new project in ./<name>",
|
|
165
165
|
" nomen lib-path Print the bundled System library path",
|
|
166
166
|
"",
|
package/src/index.ts
CHANGED
package/src/test.ts
CHANGED
|
@@ -278,6 +278,8 @@ export function run_test_file(
|
|
|
278
278
|
arch: string,
|
|
279
279
|
audit = false,
|
|
280
280
|
audit_runtime?: string,
|
|
281
|
+
release = false,
|
|
282
|
+
cwd?: string,
|
|
281
283
|
): TestFileResult {
|
|
282
284
|
const start = performance.now();
|
|
283
285
|
const source_text = fs.readFileSync(entry_path, "utf8");
|
|
@@ -318,6 +320,7 @@ export function run_test_file(
|
|
|
318
320
|
const buildResult = build(parsed.root, {
|
|
319
321
|
arch: arch as "aarch64" | "c",
|
|
320
322
|
audit,
|
|
323
|
+
optimize: release,
|
|
321
324
|
});
|
|
322
325
|
if (buildResult.errors && buildResult.errors.length) {
|
|
323
326
|
result.ok = false;
|
|
@@ -363,11 +366,28 @@ export function run_test_file(
|
|
|
363
366
|
fs.writeFileSync(path.join(buildDir, "main.h"), buildResult.headers ?? "");
|
|
364
367
|
fs.writeFileSync(codefile, buildResult.code);
|
|
365
368
|
|
|
369
|
+
// Companion C (raw-block functions + the pool/fiber/file-scope C infra):
|
|
370
|
+
// `run`/`build` compile and link it next to the main TU. The aarch64 .s
|
|
371
|
+
// references its symbols via `bl` (spawn machinery), so dropping it makes
|
|
372
|
+
// companion-bearing test files fail to link. Same .m/.c rule as the
|
|
373
|
+
// run/build command's companion emission.
|
|
374
|
+
let companionfile: string | undefined;
|
|
375
|
+
if (buildResult.companion) {
|
|
376
|
+
const comp_ext = platform === "macos" || platform === "ios" ? ".m" : ".c";
|
|
377
|
+
companionfile = path.join(buildDir, path.basename(entry_path, ".nm") + "_companion" + comp_ext);
|
|
378
|
+
fs.writeFileSync(companionfile, buildResult.companion);
|
|
379
|
+
}
|
|
380
|
+
|
|
366
381
|
// Link the harness binary. Frameworks are passed on Apple platforms for
|
|
367
382
|
// the same reason as the run/build command: the joined source may reference
|
|
368
383
|
// ObjC runtime symbols even when the test body doesn't, and unused
|
|
369
|
-
// frameworks cost nothing at link time.
|
|
384
|
+
// frameworks cost nothing at link time. Release mode compiles the C (and
|
|
385
|
+
// companion C) with -O2, matching the run/build command; the aarch64 .s is
|
|
386
|
+
// assembled verbatim — its optimizations are the passes enabled via
|
|
387
|
+
// `optimize` above.
|
|
370
388
|
const link_args = ["-o", outfile, codefile];
|
|
389
|
+
if (companionfile) link_args.push(companionfile);
|
|
390
|
+
if (release) link_args.unshift("-O2");
|
|
371
391
|
if (audit_obj) link_args.push(audit_obj);
|
|
372
392
|
if (platform === "macos" || platform === "ios") {
|
|
373
393
|
link_args.push(
|
|
@@ -396,7 +416,11 @@ export function run_test_file(
|
|
|
396
416
|
|
|
397
417
|
// Run the binary and collect the records it streams over stdout. A
|
|
398
418
|
// non-zero exit (crash, abort) still surfaces whatever records were
|
|
399
|
-
// emitted before the crash; a timeout is treated as a crash.
|
|
419
|
+
// emitted before the crash; a timeout is treated as a crash. The
|
|
420
|
+
// documented CWD contract: the binary runs in the `--in` root (the
|
|
421
|
+
// folder `nomen test` scanned for *.test.nm files), so fixture paths in
|
|
422
|
+
// tests resolve against that folder regardless of where the CLI was
|
|
423
|
+
// invoked from.
|
|
400
424
|
let runStdout = "";
|
|
401
425
|
let crashed: string | undefined;
|
|
402
426
|
try {
|
|
@@ -405,6 +429,7 @@ export function run_test_file(
|
|
|
405
429
|
stdio: ["ignore", "pipe", "pipe"],
|
|
406
430
|
timeout: 30_000,
|
|
407
431
|
maxBuffer: 16 * 1024 * 1024,
|
|
432
|
+
cwd: cwd ?? process.cwd(),
|
|
408
433
|
});
|
|
409
434
|
} catch (err: any) {
|
|
410
435
|
runStdout = err.stdout ? err.stdout.toString() : "";
|
|
@@ -519,6 +544,7 @@ export interface RunTestsOptions {
|
|
|
519
544
|
filter?: RegExp;
|
|
520
545
|
audit?: boolean;
|
|
521
546
|
audit_runtime?: string;
|
|
547
|
+
release?: boolean;
|
|
522
548
|
}
|
|
523
549
|
|
|
524
550
|
/**
|
|
@@ -547,10 +573,21 @@ export function runTests(root: string, options: RunTestsOptions = {}): boolean {
|
|
|
547
573
|
console.log(`Found ${files.length} test file(s)\n`);
|
|
548
574
|
|
|
549
575
|
const startTime = performance.now();
|
|
576
|
+
// The CWD contract: test binaries run in the --in root, so relative
|
|
577
|
+
// fixture paths resolve there no matter where the CLI was invoked from.
|
|
578
|
+
const binary_cwd = path.resolve(root);
|
|
550
579
|
|
|
551
580
|
const results: TestFileResult[] = [];
|
|
552
581
|
for (const file of files) {
|
|
553
|
-
const result = run_test_file(
|
|
582
|
+
const result = run_test_file(
|
|
583
|
+
file,
|
|
584
|
+
lib,
|
|
585
|
+
arch,
|
|
586
|
+
options.audit,
|
|
587
|
+
options.audit_runtime,
|
|
588
|
+
options.release,
|
|
589
|
+
binary_cwd,
|
|
590
|
+
);
|
|
554
591
|
report_file(result);
|
|
555
592
|
results.push(result);
|
|
556
593
|
}
|