as-test 1.1.5 → 1.1.7

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/README.md +4 -9
  3. package/assembly/index.ts +10 -15
  4. package/assembly/src/expectation.ts +11 -11
  5. package/assembly/src/fuzz.ts +11 -7
  6. package/assembly/src/log.ts +2 -2
  7. package/assembly/src/suite.ts +5 -5
  8. package/assembly/src/tests.ts +8 -8
  9. package/assembly/util/wipc.ts +5 -1
  10. package/bin/build-worker-pool.js +146 -142
  11. package/bin/build-worker.js +37 -34
  12. package/bin/commands/build-core.js +577 -465
  13. package/bin/commands/build.js +49 -29
  14. package/bin/commands/clean-core.js +120 -113
  15. package/bin/commands/clean.js +14 -8
  16. package/bin/commands/doctor-core.js +288 -289
  17. package/bin/commands/doctor.js +1 -1
  18. package/bin/commands/fuzz-core.js +467 -414
  19. package/bin/commands/fuzz.js +27 -10
  20. package/bin/commands/init-core.js +905 -794
  21. package/bin/commands/init.js +2 -2
  22. package/bin/commands/run-core.js +2675 -2344
  23. package/bin/commands/run.js +43 -25
  24. package/bin/commands/test.js +56 -32
  25. package/bin/commands/web-runner-source.js +1 -1
  26. package/bin/commands/web-session.js +516 -525
  27. package/bin/coverage-points.js +363 -341
  28. package/bin/crash-store.js +56 -66
  29. package/bin/index.js +4092 -3150
  30. package/bin/reporters/default.js +1090 -890
  31. package/bin/reporters/tap.js +319 -325
  32. package/bin/types.js +67 -67
  33. package/bin/util.js +1290 -1239
  34. package/bin/wipc.js +70 -73
  35. package/lib/build/index.d.ts +3 -1
  36. package/lib/build/index.js +1039 -1034
  37. package/lib/build/web-runner/client.js +1 -1
  38. package/lib/build/web-runner/html.js +1 -1
  39. package/lib/build/web-runner/worker.js +1 -1
  40. package/package.json +6 -3
  41. package/transform/lib/coverage.js +4 -4
  42. package/transform/lib/log.js +9 -5
  43. package/assembly/util/json.ts +0 -112
@@ -1,77 +1,67 @@
1
1
  import { mkdirSync, writeFileSync } from "fs";
2
2
  import * as path from "path";
3
3
  export function persistCrashRecord(rootDir, record) {
4
- const entry = record.entryKey?.length
5
- ? record.entryKey
6
- : crashEntryKey(record.file);
7
- const dir = path.resolve(process.cwd(), rootDir);
8
- mkdirSync(dir, { recursive: true });
9
- const jsonPath = path.join(dir, `${entry}.json`);
10
- const logPath = path.join(dir, `${entry}.log`);
11
- const payload = {
12
- timestamp: new Date().toISOString(),
13
- ...record,
14
- };
15
- const log = buildCrashLog(payload);
16
- writeFileSync(jsonPath, JSON.stringify(payload, null, 2));
17
- writeFileSync(logPath, log);
18
- return { jsonPath, logPath };
4
+ const entry = record.entryKey?.length
5
+ ? record.entryKey
6
+ : crashEntryKey(record.file);
7
+ const dir = path.resolve(process.cwd(), rootDir);
8
+ mkdirSync(dir, { recursive: true });
9
+ const jsonPath = path.join(dir, `${entry}.json`);
10
+ const logPath = path.join(dir, `${entry}.log`);
11
+ const payload = {
12
+ timestamp: new Date().toISOString(),
13
+ ...record,
14
+ };
15
+ const log = buildCrashLog(payload);
16
+ writeFileSync(jsonPath, JSON.stringify(payload, null, 2));
17
+ writeFileSync(logPath, log);
18
+ return { jsonPath, logPath };
19
19
  }
20
20
  function crashEntryKey(file) {
21
- return path.basename(file).replace(/\.ts$/, "");
21
+ return path.basename(file).replace(/\.ts$/, "");
22
22
  }
23
23
  function buildCrashLog(payload) {
24
- const lines = [
25
- `timestamp: ${payload.timestamp}`,
26
- `kind: ${payload.kind}`,
27
- `stage: ${payload.stage ?? "run"}`,
28
- `file: ${payload.file}`,
29
- ];
30
- if (payload.mode)
31
- lines.push(`mode: ${payload.mode}`);
32
- if (typeof payload.seed == "number")
33
- lines.push(`seed: ${payload.seed}`);
34
- if (payload.cwd)
35
- lines.push(`cwd: ${payload.cwd}`);
36
- if (payload.buildCommand)
37
- lines.push(`build: ${payload.buildCommand}`);
38
- if (payload.runCommand)
39
- lines.push(`run: ${payload.runCommand}`);
40
- if (payload.reproCommand)
41
- lines.push(`repro: ${payload.reproCommand}`);
24
+ const lines = [
25
+ `timestamp: ${payload.timestamp}`,
26
+ `kind: ${payload.kind}`,
27
+ `stage: ${payload.stage ?? "run"}`,
28
+ `file: ${payload.file}`,
29
+ ];
30
+ if (payload.mode) lines.push(`mode: ${payload.mode}`);
31
+ if (typeof payload.seed == "number") lines.push(`seed: ${payload.seed}`);
32
+ if (payload.cwd) lines.push(`cwd: ${payload.cwd}`);
33
+ if (payload.buildCommand) lines.push(`build: ${payload.buildCommand}`);
34
+ if (payload.runCommand) lines.push(`run: ${payload.runCommand}`);
35
+ if (payload.reproCommand) lines.push(`repro: ${payload.reproCommand}`);
36
+ lines.push("");
37
+ lines.push("[error]");
38
+ lines.push(payload.error);
39
+ if (payload.failure) {
42
40
  lines.push("");
43
- lines.push("[error]");
44
- lines.push(payload.error);
45
- if (payload.failure) {
46
- lines.push("");
47
- lines.push("[failure]");
48
- if (payload.failure.instr)
49
- lines.push(`instr: ${payload.failure.instr}`);
50
- if (payload.failure.left)
51
- lines.push(`left: ${payload.failure.left}`);
52
- if (payload.failure.right)
53
- lines.push(`right: ${payload.failure.right}`);
54
- if (payload.failure.message) {
55
- lines.push(`message: ${payload.failure.message}`);
56
- }
41
+ lines.push("[failure]");
42
+ if (payload.failure.instr) lines.push(`instr: ${payload.failure.instr}`);
43
+ if (payload.failure.left) lines.push(`left: ${payload.failure.left}`);
44
+ if (payload.failure.right) lines.push(`right: ${payload.failure.right}`);
45
+ if (payload.failure.message) {
46
+ lines.push(`message: ${payload.failure.message}`);
57
47
  }
58
- if (payload.failures?.length) {
59
- lines.push("");
60
- lines.push("[fuzz-failures]");
61
- for (const failure of payload.failures) {
62
- lines.push(`run: ${failure.run}`);
63
- lines.push(`seed: ${failure.seed}`);
64
- if (failure.input)
65
- lines.push(`input: ${JSON.stringify(failure.input)}`);
66
- lines.push("");
67
- }
68
- }
69
- lines.push("");
70
- lines.push("[stdout]");
71
- lines.push(payload.stdout ?? "");
48
+ }
49
+ if (payload.failures?.length) {
72
50
  lines.push("");
73
- lines.push("[stderr]");
74
- lines.push(payload.stderr ?? "");
75
- lines.push("");
76
- return lines.join("\n");
51
+ lines.push("[fuzz-failures]");
52
+ for (const failure of payload.failures) {
53
+ lines.push(`run: ${failure.run}`);
54
+ lines.push(`seed: ${failure.seed}`);
55
+ if (failure.input) lines.push(`input: ${JSON.stringify(failure.input)}`);
56
+ lines.push("");
57
+ }
58
+ }
59
+ lines.push("");
60
+ lines.push("[stdout]");
61
+ lines.push(payload.stdout ?? "");
62
+ lines.push("");
63
+ lines.push("[stderr]");
64
+ lines.push(payload.stderr ?? "");
65
+ lines.push("");
66
+ return lines.join("\n");
77
67
  }