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
package/bin/wipc.js CHANGED
@@ -1,83 +1,80 @@
1
1
  export var MessageType;
2
2
  (function (MessageType) {
3
- MessageType[MessageType["OPEN"] = 0] = "OPEN";
4
- MessageType[MessageType["CLOSE"] = 1] = "CLOSE";
5
- MessageType[MessageType["CALL"] = 2] = "CALL";
6
- MessageType[MessageType["DATA"] = 3] = "DATA";
3
+ MessageType[(MessageType["OPEN"] = 0)] = "OPEN";
4
+ MessageType[(MessageType["CLOSE"] = 1)] = "CLOSE";
5
+ MessageType[(MessageType["CALL"] = 2)] = "CALL";
6
+ MessageType[(MessageType["DATA"] = 3)] = "DATA";
7
7
  })(MessageType || (MessageType = {}));
8
8
  export class Channel {
9
- constructor(input = process.stdin, output = process.stdout) {
10
- this.input = input;
11
- this.output = output;
12
- this.buffer = Buffer.alloc(0);
13
- this.input.on("data", (chunk) => this.onData(chunk));
14
- }
15
- send(type, payload) {
16
- const body = payload ?? Buffer.alloc(0);
17
- const header = Buffer.alloc(Channel.HEADER_SIZE);
18
- Channel.MAGIC.copy(header, 0);
19
- header.writeUInt8(type, 4);
20
- header.writeUInt32LE(body.length, 5);
21
- this.output.write(Buffer.concat([header, body]));
22
- }
23
- sendJSON(type, msg) {
24
- const json = Buffer.from(JSON.stringify(msg), "utf8");
25
- this.send(type, json);
26
- }
27
- onData(chunk) {
28
- this.buffer = Buffer.concat([this.buffer, chunk]);
29
- while (true) {
30
- if (this.buffer.length === 0)
31
- return;
32
- const idx = this.buffer.indexOf(Channel.MAGIC);
33
- if (idx === -1) {
34
- const keep = Math.min(this.buffer.length, Channel.MAGIC_PREFIX_MAX);
35
- const flushLength = this.buffer.length - keep;
36
- if (flushLength > 0) {
37
- this.onPassthrough(this.buffer.subarray(0, flushLength));
38
- this.buffer = this.buffer.subarray(flushLength);
39
- }
40
- return;
41
- }
42
- if (idx > 0) {
43
- this.onPassthrough(this.buffer.subarray(0, idx));
44
- this.buffer = this.buffer.subarray(idx);
45
- }
46
- if (this.buffer.length < Channel.HEADER_SIZE)
47
- return;
48
- const type = this.buffer.readUInt8(4);
49
- const length = this.buffer.readUInt32LE(5);
50
- const frameSize = Channel.HEADER_SIZE + length;
51
- if (this.buffer.length < frameSize)
52
- return;
53
- const payload = this.buffer.subarray(Channel.HEADER_SIZE, frameSize);
54
- this.buffer = this.buffer.subarray(frameSize);
55
- this.handleFrame(type, payload);
9
+ constructor(input = process.stdin, output = process.stdout) {
10
+ this.input = input;
11
+ this.output = output;
12
+ this.buffer = Buffer.alloc(0);
13
+ this.input.on("data", (chunk) => this.onData(chunk));
14
+ }
15
+ send(type, payload) {
16
+ const body = payload ?? Buffer.alloc(0);
17
+ const header = Buffer.alloc(Channel.HEADER_SIZE);
18
+ Channel.MAGIC.copy(header, 0);
19
+ header.writeUInt8(type, 4);
20
+ header.writeUInt32LE(body.length, 5);
21
+ this.output.write(Buffer.concat([header, body]));
22
+ }
23
+ sendJSON(type, msg) {
24
+ const json = Buffer.from(JSON.stringify(msg), "utf8");
25
+ this.send(type, json);
26
+ }
27
+ onData(chunk) {
28
+ this.buffer = Buffer.concat([this.buffer, chunk]);
29
+ while (true) {
30
+ if (this.buffer.length === 0) return;
31
+ const idx = this.buffer.indexOf(Channel.MAGIC);
32
+ if (idx === -1) {
33
+ const keep = Math.min(this.buffer.length, Channel.MAGIC_PREFIX_MAX);
34
+ const flushLength = this.buffer.length - keep;
35
+ if (flushLength > 0) {
36
+ this.onPassthrough(this.buffer.subarray(0, flushLength));
37
+ this.buffer = this.buffer.subarray(flushLength);
56
38
  }
39
+ return;
40
+ }
41
+ if (idx > 0) {
42
+ this.onPassthrough(this.buffer.subarray(0, idx));
43
+ this.buffer = this.buffer.subarray(idx);
44
+ }
45
+ if (this.buffer.length < Channel.HEADER_SIZE) return;
46
+ const type = this.buffer.readUInt8(4);
47
+ const length = this.buffer.readUInt32LE(5);
48
+ const frameSize = Channel.HEADER_SIZE + length;
49
+ if (this.buffer.length < frameSize) return;
50
+ const payload = this.buffer.subarray(Channel.HEADER_SIZE, frameSize);
51
+ this.buffer = this.buffer.subarray(frameSize);
52
+ this.handleFrame(type, payload);
57
53
  }
58
- handleFrame(type, payload) {
59
- switch (type) {
60
- case MessageType.OPEN:
61
- this.onOpen();
62
- break;
63
- case MessageType.CLOSE:
64
- this.onClose();
65
- break;
66
- case MessageType.CALL:
67
- this.onCall(JSON.parse(payload.toString("utf8")));
68
- break;
69
- case MessageType.DATA:
70
- this.onDataMessage(payload);
71
- break;
72
- default:
73
- throw new Error(`Unknown frame type: ${type}`);
74
- }
54
+ }
55
+ handleFrame(type, payload) {
56
+ switch (type) {
57
+ case MessageType.OPEN:
58
+ this.onOpen();
59
+ break;
60
+ case MessageType.CLOSE:
61
+ this.onClose();
62
+ break;
63
+ case MessageType.CALL:
64
+ this.onCall(JSON.parse(payload.toString("utf8")));
65
+ break;
66
+ case MessageType.DATA:
67
+ this.onDataMessage(payload);
68
+ break;
69
+ default:
70
+ throw new Error(`Unknown frame type: ${type}`);
75
71
  }
76
- onPassthrough(_data) { }
77
- onOpen() { }
78
- onClose() { }
79
- onCall(_msg) { }
80
- onDataMessage(_data) { }
72
+ }
73
+ onPassthrough(_data) {}
74
+ onOpen() {}
75
+ onClose() {}
76
+ onCall(_msg) {}
77
+ onDataMessage(_data) {}
81
78
  }
82
79
  Channel.MAGIC = Buffer.from("WIPC");
83
80
  Channel.HEADER_SIZE = 9;
@@ -1 +1,3 @@
1
- export declare function instantiate(imports: WebAssembly.Imports): Promise<WebAssembly.Instance>;
1
+ export declare function instantiate(
2
+ imports: WebAssembly.Imports,
3
+ ): Promise<WebAssembly.Instance>;