as-test 1.0.1 → 1.0.3
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/CHANGELOG.md +112 -1
- package/README.md +138 -406
- package/as-test.config.schema.json +210 -17
- package/assembly/__fuzz__/array.fuzz.ts +10 -0
- package/assembly/__fuzz__/bytes.fuzz.ts +8 -0
- package/assembly/__fuzz__/math.fuzz.ts +9 -0
- package/assembly/__fuzz__/string.fuzz.ts +21 -0
- package/assembly/index.ts +141 -86
- package/assembly/src/expectation.ts +104 -19
- package/assembly/src/fuzz.ts +723 -0
- package/assembly/src/log.ts +6 -1
- package/assembly/src/suite.ts +45 -3
- package/assembly/util/json.ts +38 -4
- package/assembly/util/wipc.ts +35 -26
- package/bin/build-worker-pool.js +149 -0
- package/bin/build-worker.js +43 -0
- package/bin/commands/build-core.js +214 -28
- package/bin/commands/build.js +1 -0
- package/bin/commands/fuzz-core.js +306 -0
- package/bin/commands/fuzz.js +10 -0
- package/bin/commands/init-core.js +129 -24
- package/bin/commands/run-core.js +525 -123
- package/bin/commands/run.js +4 -1
- package/bin/commands/test.js +8 -3
- package/bin/commands/web-runner-source.js +634 -0
- package/bin/crash-store.js +64 -0
- package/bin/index.js +1484 -169
- package/bin/reporters/default.js +281 -49
- package/bin/reporters/tap.js +83 -2
- package/bin/types.js +19 -2
- package/bin/util.js +315 -33
- package/bin/wipc.js +79 -0
- package/package.json +19 -9
- package/transform/lib/coverage.js +1 -2
- package/transform/lib/index.js +3 -3
- package/transform/lib/log.js +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync } from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
export function persistCrashRecord(rootDir, record) {
|
|
4
|
+
const entry = crashEntryKey(record.file);
|
|
5
|
+
const dir = path.resolve(process.cwd(), rootDir);
|
|
6
|
+
mkdirSync(dir, { recursive: true });
|
|
7
|
+
const jsonPath = path.join(dir, `${entry}.json`);
|
|
8
|
+
const logPath = path.join(dir, `${entry}.log`);
|
|
9
|
+
const payload = {
|
|
10
|
+
timestamp: new Date().toISOString(),
|
|
11
|
+
...record,
|
|
12
|
+
};
|
|
13
|
+
const log = buildCrashLog(payload);
|
|
14
|
+
writeFileSync(jsonPath, JSON.stringify(payload, null, 2));
|
|
15
|
+
writeFileSync(logPath, log);
|
|
16
|
+
return { jsonPath, logPath };
|
|
17
|
+
}
|
|
18
|
+
function crashEntryKey(file) {
|
|
19
|
+
return path.basename(file).replace(/\.ts$/, "");
|
|
20
|
+
}
|
|
21
|
+
function buildCrashLog(payload) {
|
|
22
|
+
const lines = [
|
|
23
|
+
`timestamp: ${payload.timestamp}`,
|
|
24
|
+
`kind: ${payload.kind}`,
|
|
25
|
+
`stage: ${payload.stage ?? "run"}`,
|
|
26
|
+
`file: ${payload.file}`,
|
|
27
|
+
];
|
|
28
|
+
if (payload.mode)
|
|
29
|
+
lines.push(`mode: ${payload.mode}`);
|
|
30
|
+
if (typeof payload.seed == "number")
|
|
31
|
+
lines.push(`seed: ${payload.seed}`);
|
|
32
|
+
if (payload.cwd)
|
|
33
|
+
lines.push(`cwd: ${payload.cwd}`);
|
|
34
|
+
if (payload.buildCommand)
|
|
35
|
+
lines.push(`build: ${payload.buildCommand}`);
|
|
36
|
+
if (payload.runCommand)
|
|
37
|
+
lines.push(`run: ${payload.runCommand}`);
|
|
38
|
+
if (payload.reproCommand)
|
|
39
|
+
lines.push(`repro: ${payload.reproCommand}`);
|
|
40
|
+
lines.push("");
|
|
41
|
+
lines.push("[error]");
|
|
42
|
+
lines.push(payload.error);
|
|
43
|
+
if (payload.failure) {
|
|
44
|
+
lines.push("");
|
|
45
|
+
lines.push("[failure]");
|
|
46
|
+
if (payload.failure.instr)
|
|
47
|
+
lines.push(`instr: ${payload.failure.instr}`);
|
|
48
|
+
if (payload.failure.left)
|
|
49
|
+
lines.push(`left: ${payload.failure.left}`);
|
|
50
|
+
if (payload.failure.right)
|
|
51
|
+
lines.push(`right: ${payload.failure.right}`);
|
|
52
|
+
if (payload.failure.message) {
|
|
53
|
+
lines.push(`message: ${payload.failure.message}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
lines.push("");
|
|
57
|
+
lines.push("[stdout]");
|
|
58
|
+
lines.push(payload.stdout ?? "");
|
|
59
|
+
lines.push("");
|
|
60
|
+
lines.push("[stderr]");
|
|
61
|
+
lines.push(payload.stderr ?? "");
|
|
62
|
+
lines.push("");
|
|
63
|
+
return lines.join("\n");
|
|
64
|
+
}
|