ic-mops 0.20.2 → 0.21.0
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/cli.ts +2 -1
- package/commands/{mmf1.ts → test/mmf1.ts} +23 -13
- package/commands/test/reporters/compact-reporter.ts +95 -0
- package/commands/test/reporters/files-reporter.ts +52 -0
- package/commands/test/reporters/reporter.ts +7 -0
- package/commands/test/reporters/verbose-reporter.ts +51 -0
- package/commands/{test.ts → test/test.ts} +63 -79
- package/commands/test/utils.ts +7 -0
- package/dist/cli.js +2 -1
- package/dist/commands/test/mmf1.d.ts +26 -0
- package/dist/commands/test/mmf1.js +98 -0
- package/dist/commands/test/reporter-files.d.ts +10 -0
- package/dist/commands/test/reporter-files.js +48 -0
- package/dist/commands/test/reporter-verbose.d.ts +10 -0
- package/dist/commands/test/reporter-verbose.js +56 -0
- package/dist/commands/test/reporters/compact-reporter.d.ts +13 -0
- package/dist/commands/test/reporters/compact-reporter.js +92 -0
- package/dist/commands/test/reporters/files-reporter.d.ts +11 -0
- package/dist/commands/test/reporters/files-reporter.js +50 -0
- package/dist/commands/test/reporters/reporter.d.ts +6 -0
- package/dist/commands/test/reporters/reporter.js +1 -0
- package/dist/commands/test/reporters/verbose-reporter.d.ts +11 -0
- package/dist/commands/test/reporters/verbose-reporter.js +56 -0
- package/dist/commands/test/test.d.ts +5 -0
- package/dist/commands/test/test.js +189 -0
- package/dist/commands/test/utils.d.ts +1 -0
- package/dist/commands/test/utils.js +6 -0
- package/dist/commands/test.js +43 -58
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// mops message format v1
|
|
2
|
+
// mops:1:start
|
|
3
|
+
// mops:1:end
|
|
4
|
+
// mops:1:skip
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
export class MMF1 {
|
|
7
|
+
constructor(srategy) {
|
|
8
|
+
this.stack = [];
|
|
9
|
+
this.currSuite = '';
|
|
10
|
+
this.failed = 0;
|
|
11
|
+
this.passed = 0;
|
|
12
|
+
this.skipped = 0;
|
|
13
|
+
this.output = [];
|
|
14
|
+
this.srategy = srategy;
|
|
15
|
+
}
|
|
16
|
+
_log(type, ...args) {
|
|
17
|
+
if (this.srategy === 'store') {
|
|
18
|
+
this.output.push({
|
|
19
|
+
type,
|
|
20
|
+
message: args.join(' ')
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else if (this.srategy === 'print') {
|
|
24
|
+
console.log(...args);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
flush(messageType) {
|
|
28
|
+
for (let out of this.output) {
|
|
29
|
+
if (!messageType || out.type === messageType) {
|
|
30
|
+
console.log(out.message);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
this.output = [];
|
|
34
|
+
}
|
|
35
|
+
parseLine(line) {
|
|
36
|
+
if (line.startsWith('mops:1:start ')) {
|
|
37
|
+
this._testStart(line.split('mops:1:start ')[1] || '');
|
|
38
|
+
}
|
|
39
|
+
else if (line.startsWith('mops:1:end ')) {
|
|
40
|
+
this._testEnd(line.split('mops:1:end ')[1] || '');
|
|
41
|
+
}
|
|
42
|
+
else if (line.startsWith('mops:1:skip ')) {
|
|
43
|
+
this._testSkip(line.split('mops:1:skip ')[1] || '');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this._log('stdout', ' '.repeat(this.stack.length * 2), chalk.gray('stdout'), line);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
_testStart(name) {
|
|
50
|
+
let suite = this.stack[this.stack.length - 1];
|
|
51
|
+
if (suite) {
|
|
52
|
+
if (this.currSuite !== suite) {
|
|
53
|
+
this.currSuite = suite;
|
|
54
|
+
this._log('suite', ' '.repeat((this.stack.length - 1) * 2), (chalk.gray('•')) + '', suite);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this.stack.push(name);
|
|
58
|
+
}
|
|
59
|
+
_testEnd(name) {
|
|
60
|
+
if (name !== this.stack.pop()) {
|
|
61
|
+
throw 'mmf1._testEnd: start and end test mismatch';
|
|
62
|
+
}
|
|
63
|
+
this._status(name, 'pass');
|
|
64
|
+
}
|
|
65
|
+
_testSkip(name) {
|
|
66
|
+
this._status(name, 'skip');
|
|
67
|
+
}
|
|
68
|
+
_status(name, status) {
|
|
69
|
+
if (status === 'pass') {
|
|
70
|
+
// do not print suite at the end
|
|
71
|
+
if (name === this.currSuite) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.passed++;
|
|
75
|
+
this._log(status, ' '.repeat(this.stack.length * 2), chalk.green('✓'), name);
|
|
76
|
+
}
|
|
77
|
+
else if (status === 'fail') {
|
|
78
|
+
this.failed++;
|
|
79
|
+
this._log(status, ' '.repeat(this.stack.length * 2), chalk.red('✖'), name);
|
|
80
|
+
}
|
|
81
|
+
else if (status === 'skip') {
|
|
82
|
+
this.skipped++;
|
|
83
|
+
this._log(status, ' '.repeat(this.stack.length * 2), chalk.yellow('−'), name);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
fail(stderr) {
|
|
87
|
+
let name = this.stack.pop() || '';
|
|
88
|
+
this._status(name, 'fail');
|
|
89
|
+
this._log('fail', ' '.repeat(this.stack.length * 2), chalk.red('FAIL'), stderr);
|
|
90
|
+
}
|
|
91
|
+
pass() {
|
|
92
|
+
let name = this.stack.pop();
|
|
93
|
+
if (name) {
|
|
94
|
+
this._status(name, 'pass');
|
|
95
|
+
}
|
|
96
|
+
this._log('pass', ' '.repeat(this.stack.length * 2), chalk.green('PASS'));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MMF1 } from './mmf1.js';
|
|
2
|
+
export declare class FilesReporter {
|
|
3
|
+
#private;
|
|
4
|
+
passed: number;
|
|
5
|
+
failed: number;
|
|
6
|
+
skipped: number;
|
|
7
|
+
addFiles(files: string[]): void;
|
|
8
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, wasiMode: boolean): void;
|
|
9
|
+
done(): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _FilesReporter_startTime;
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { absToRel } from './utils.js';
|
|
9
|
+
export class FilesReporter {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.passed = 0;
|
|
12
|
+
this.failed = 0;
|
|
13
|
+
this.skipped = 0;
|
|
14
|
+
_FilesReporter_startTime.set(this, Date.now());
|
|
15
|
+
}
|
|
16
|
+
addFiles(files) {
|
|
17
|
+
console.log(`Test files: ${files.length}`);
|
|
18
|
+
console.log('='.repeat(50));
|
|
19
|
+
}
|
|
20
|
+
addRun(file, mmf, state, wasiMode) {
|
|
21
|
+
state.then(() => {
|
|
22
|
+
this.passed += mmf.passed;
|
|
23
|
+
this.failed += mmf.failed;
|
|
24
|
+
this.skipped += mmf.skipped;
|
|
25
|
+
if (this.failed) {
|
|
26
|
+
mmf.flush();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log(`${chalk.green('✓')} ${absToRel(file)} ${wasiMode ? chalk.gray('(wasi)') : ''}`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
done() {
|
|
34
|
+
console.log('='.repeat(50));
|
|
35
|
+
if (this.failed) {
|
|
36
|
+
console.log(chalk.redBright('Tests failed'));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.log(chalk.greenBright('Tests passed'));
|
|
40
|
+
}
|
|
41
|
+
console.log(`Done in ${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _FilesReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
|
|
42
|
+
+ `, passed ${chalk.greenBright(this.passed)}`
|
|
43
|
+
+ (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)}` : '')
|
|
44
|
+
+ (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)}` : ''));
|
|
45
|
+
return this.failed === 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
_FilesReporter_startTime = new WeakMap();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MMF1 } from './mmf1.js';
|
|
2
|
+
export declare class VerboseReporter {
|
|
3
|
+
#private;
|
|
4
|
+
passed: number;
|
|
5
|
+
failed: number;
|
|
6
|
+
skipped: number;
|
|
7
|
+
addFiles(files: string[]): void;
|
|
8
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, wasiMode: boolean): void;
|
|
9
|
+
done(): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _VerboseReporter_startTime, _VerboseReporter_curFileIndex;
|
|
13
|
+
import chalk from 'chalk';
|
|
14
|
+
import { absToRel } from './utils.js';
|
|
15
|
+
export class VerboseReporter {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.passed = 0;
|
|
18
|
+
this.failed = 0;
|
|
19
|
+
this.skipped = 0;
|
|
20
|
+
_VerboseReporter_startTime.set(this, Date.now());
|
|
21
|
+
_VerboseReporter_curFileIndex.set(this, 0);
|
|
22
|
+
}
|
|
23
|
+
addFiles(files) {
|
|
24
|
+
console.log('Test files:');
|
|
25
|
+
for (let file of files) {
|
|
26
|
+
console.log(chalk.gray(`• ${absToRel(file)}`));
|
|
27
|
+
}
|
|
28
|
+
console.log('='.repeat(50));
|
|
29
|
+
}
|
|
30
|
+
addRun(file, mmf, state, wasiMode) {
|
|
31
|
+
state.then(() => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
this.passed += mmf.passed;
|
|
34
|
+
this.failed += mmf.failed;
|
|
35
|
+
this.skipped += mmf.skipped;
|
|
36
|
+
(__classPrivateFieldSet(this, _VerboseReporter_curFileIndex, (_b = __classPrivateFieldGet(this, _VerboseReporter_curFileIndex, "f"), _a = _b++, _b), "f"), _a) && console.log('-'.repeat(50));
|
|
37
|
+
console.log(`Running ${chalk.gray(absToRel(file))} ${wasiMode ? chalk.gray('(wasi)') : ''}`);
|
|
38
|
+
mmf.flush();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
done() {
|
|
42
|
+
console.log('='.repeat(50));
|
|
43
|
+
if (this.failed) {
|
|
44
|
+
console.log(chalk.redBright('Tests failed'));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log(chalk.greenBright('Tests passed'));
|
|
48
|
+
}
|
|
49
|
+
console.log(`Done in ${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _VerboseReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
|
|
50
|
+
+ `, passed ${chalk.greenBright(this.passed)}`
|
|
51
|
+
+ (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)}` : '')
|
|
52
|
+
+ (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)}` : ''));
|
|
53
|
+
return this.failed === 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
_VerboseReporter_startTime = new WeakMap(), _VerboseReporter_curFileIndex = new WeakMap();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MMF1 } from '../mmf1.js';
|
|
2
|
+
import { Reporter } from './reporter.js';
|
|
3
|
+
export declare class CompactReporter implements Reporter {
|
|
4
|
+
#private;
|
|
5
|
+
passed: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
skipped: number;
|
|
8
|
+
passedFiles: number;
|
|
9
|
+
failedFiles: number;
|
|
10
|
+
addFiles(files: string[]): void;
|
|
11
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, _wasiMode: boolean): void;
|
|
12
|
+
done(): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _CompactReporter_instances, _CompactReporter_allFiles, _CompactReporter_runningFiles, _CompactReporter_failedFiles, _CompactReporter_finishedFiles, _CompactReporter_startTime, _CompactReporter_timerId, _CompactReporter_startTimer, _CompactReporter_clearTimer, _CompactReporter_log;
|
|
13
|
+
import chalk from 'chalk';
|
|
14
|
+
import logUpdate from 'log-update';
|
|
15
|
+
import { absToRel } from '../utils.js';
|
|
16
|
+
export class CompactReporter {
|
|
17
|
+
constructor() {
|
|
18
|
+
_CompactReporter_instances.add(this);
|
|
19
|
+
this.passed = 0;
|
|
20
|
+
this.failed = 0;
|
|
21
|
+
this.skipped = 0;
|
|
22
|
+
this.passedFiles = 0;
|
|
23
|
+
this.failedFiles = 0;
|
|
24
|
+
_CompactReporter_allFiles.set(this, new Set());
|
|
25
|
+
_CompactReporter_runningFiles.set(this, new Set());
|
|
26
|
+
_CompactReporter_failedFiles.set(this, new Set());
|
|
27
|
+
_CompactReporter_finishedFiles.set(this, new Set());
|
|
28
|
+
_CompactReporter_startTime.set(this, Date.now());
|
|
29
|
+
_CompactReporter_timerId.set(this, null);
|
|
30
|
+
}
|
|
31
|
+
addFiles(files) {
|
|
32
|
+
__classPrivateFieldSet(this, _CompactReporter_allFiles, new Set(files), "f");
|
|
33
|
+
__classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
|
|
34
|
+
__classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_startTimer).call(this);
|
|
35
|
+
}
|
|
36
|
+
addRun(file, mmf, state, _wasiMode) {
|
|
37
|
+
__classPrivateFieldGet(this, _CompactReporter_runningFiles, "f").add(file);
|
|
38
|
+
__classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
|
|
39
|
+
state.then(() => {
|
|
40
|
+
this.passed += mmf.passed;
|
|
41
|
+
this.failed += mmf.failed;
|
|
42
|
+
this.skipped += mmf.skipped;
|
|
43
|
+
this.passedFiles += Number(mmf.failed === 0);
|
|
44
|
+
this.failedFiles += Number(mmf.failed !== 0);
|
|
45
|
+
if (mmf.failed) {
|
|
46
|
+
__classPrivateFieldGet(this, _CompactReporter_failedFiles, "f").add(file);
|
|
47
|
+
logUpdate.clear();
|
|
48
|
+
console.log(chalk.red('✖'), absToRel(file));
|
|
49
|
+
mmf.flush('fail');
|
|
50
|
+
console.log('-'.repeat(50));
|
|
51
|
+
}
|
|
52
|
+
__classPrivateFieldGet(this, _CompactReporter_runningFiles, "f").delete(file);
|
|
53
|
+
__classPrivateFieldGet(this, _CompactReporter_finishedFiles, "f").add(file);
|
|
54
|
+
__classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
done() {
|
|
58
|
+
__classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
|
|
59
|
+
logUpdate.done();
|
|
60
|
+
__classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_clearTimer).call(this);
|
|
61
|
+
return this.failed === 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
_CompactReporter_allFiles = new WeakMap(), _CompactReporter_runningFiles = new WeakMap(), _CompactReporter_failedFiles = new WeakMap(), _CompactReporter_finishedFiles = new WeakMap(), _CompactReporter_startTime = new WeakMap(), _CompactReporter_timerId = new WeakMap(), _CompactReporter_instances = new WeakSet(), _CompactReporter_startTimer = function _CompactReporter_startTimer() {
|
|
65
|
+
__classPrivateFieldSet(this, _CompactReporter_timerId, setInterval(() => __classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this), 55), "f");
|
|
66
|
+
}, _CompactReporter_clearTimer = function _CompactReporter_clearTimer() {
|
|
67
|
+
if (__classPrivateFieldGet(this, _CompactReporter_timerId, "f")) {
|
|
68
|
+
clearInterval(__classPrivateFieldGet(this, _CompactReporter_timerId, "f"));
|
|
69
|
+
}
|
|
70
|
+
}, _CompactReporter_log = function _CompactReporter_log() {
|
|
71
|
+
let res = [];
|
|
72
|
+
let i = 0;
|
|
73
|
+
for (let file of __classPrivateFieldGet(this, _CompactReporter_allFiles, "f")) {
|
|
74
|
+
if (__classPrivateFieldGet(this, _CompactReporter_runningFiles, "f").has(file)) {
|
|
75
|
+
res[Number(i)] = '.';
|
|
76
|
+
}
|
|
77
|
+
else if (__classPrivateFieldGet(this, _CompactReporter_finishedFiles, "f").has(file)) {
|
|
78
|
+
res[Number(i)] = __classPrivateFieldGet(this, _CompactReporter_failedFiles, "f").has(file) ? chalk.red(':') : ':';
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
res[Number(i)] = ' ';
|
|
82
|
+
}
|
|
83
|
+
i++;
|
|
84
|
+
}
|
|
85
|
+
let output = `[${res.join('')}]\n`
|
|
86
|
+
+ `${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _CompactReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
|
|
87
|
+
+ `, total ${__classPrivateFieldGet(this, _CompactReporter_allFiles, "f").size} files`
|
|
88
|
+
+ `, passed ${chalk.greenBright(this.passedFiles)} files`
|
|
89
|
+
+ (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)} cases` : '')
|
|
90
|
+
+ (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)} cases` : '');
|
|
91
|
+
logUpdate(output);
|
|
92
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MMF1 } from '../mmf1.js';
|
|
2
|
+
import { Reporter } from './reporter.js';
|
|
3
|
+
export declare class FilesReporter implements Reporter {
|
|
4
|
+
#private;
|
|
5
|
+
passed: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
skipped: number;
|
|
8
|
+
addFiles(files: string[]): void;
|
|
9
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, wasiMode: boolean): void;
|
|
10
|
+
done(): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _FilesReporter_startTime;
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { absToRel } from '../utils.js';
|
|
9
|
+
export class FilesReporter {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.passed = 0;
|
|
12
|
+
this.failed = 0;
|
|
13
|
+
this.skipped = 0;
|
|
14
|
+
_FilesReporter_startTime.set(this, Date.now());
|
|
15
|
+
}
|
|
16
|
+
addFiles(files) {
|
|
17
|
+
console.log(`Test files: ${files.length}`);
|
|
18
|
+
console.log('='.repeat(50));
|
|
19
|
+
}
|
|
20
|
+
addRun(file, mmf, state, wasiMode) {
|
|
21
|
+
state.then(() => {
|
|
22
|
+
this.passed += Number(mmf.failed === 0);
|
|
23
|
+
this.failed += Number(mmf.failed !== 0);
|
|
24
|
+
this.skipped += mmf.skipped;
|
|
25
|
+
if (mmf.failed) {
|
|
26
|
+
console.log(chalk.red('✖'), absToRel(file));
|
|
27
|
+
mmf.flush('fail');
|
|
28
|
+
console.log('-'.repeat(50));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.log(`${chalk.green('✓')} ${absToRel(file)} ${wasiMode ? chalk.gray('(wasi)') : ''}`);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
done() {
|
|
36
|
+
console.log('='.repeat(50));
|
|
37
|
+
if (this.failed) {
|
|
38
|
+
console.log(chalk.redBright('Tests failed'));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.log(chalk.greenBright('Tests passed'));
|
|
42
|
+
}
|
|
43
|
+
console.log(`Done in ${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _FilesReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
|
|
44
|
+
+ `, passed ${chalk.greenBright(this.passed)} files`
|
|
45
|
+
+ (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)} cases` : '')
|
|
46
|
+
+ (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)} files` : ''));
|
|
47
|
+
return this.failed === 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
_FilesReporter_startTime = new WeakMap();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MMF1 } from '../mmf1.js';
|
|
2
|
+
import { Reporter } from './reporter.js';
|
|
3
|
+
export declare class VerboseReporter implements Reporter {
|
|
4
|
+
#private;
|
|
5
|
+
passed: number;
|
|
6
|
+
failed: number;
|
|
7
|
+
skipped: number;
|
|
8
|
+
addFiles(files: string[]): void;
|
|
9
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, wasiMode: boolean): void;
|
|
10
|
+
done(): boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _VerboseReporter_startTime, _VerboseReporter_curFileIndex;
|
|
13
|
+
import chalk from 'chalk';
|
|
14
|
+
import { absToRel } from '../utils.js';
|
|
15
|
+
export class VerboseReporter {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.passed = 0;
|
|
18
|
+
this.failed = 0;
|
|
19
|
+
this.skipped = 0;
|
|
20
|
+
_VerboseReporter_startTime.set(this, Date.now());
|
|
21
|
+
_VerboseReporter_curFileIndex.set(this, 0);
|
|
22
|
+
}
|
|
23
|
+
addFiles(files) {
|
|
24
|
+
console.log('Test files:');
|
|
25
|
+
for (let file of files) {
|
|
26
|
+
console.log(chalk.gray(`• ${absToRel(file)}`));
|
|
27
|
+
}
|
|
28
|
+
console.log('='.repeat(50));
|
|
29
|
+
}
|
|
30
|
+
addRun(file, mmf, state, wasiMode) {
|
|
31
|
+
state.then(() => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
this.passed += mmf.passed;
|
|
34
|
+
this.failed += mmf.failed;
|
|
35
|
+
this.skipped += mmf.skipped;
|
|
36
|
+
(__classPrivateFieldSet(this, _VerboseReporter_curFileIndex, (_b = __classPrivateFieldGet(this, _VerboseReporter_curFileIndex, "f"), _a = _b++, _b), "f"), _a) && console.log('-'.repeat(50));
|
|
37
|
+
console.log(`Running ${chalk.gray(absToRel(file))} ${wasiMode ? chalk.gray('(wasi)') : ''}`);
|
|
38
|
+
mmf.flush();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
done() {
|
|
42
|
+
console.log('='.repeat(50));
|
|
43
|
+
if (this.failed) {
|
|
44
|
+
console.log(chalk.redBright('Tests failed'));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log(chalk.greenBright('Tests passed'));
|
|
48
|
+
}
|
|
49
|
+
console.log(`Done in ${chalk.gray(((Date.now() - __classPrivateFieldGet(this, _VerboseReporter_startTime, "f")) / 1000).toFixed(2) + 's')}`
|
|
50
|
+
+ `, passed ${chalk.greenBright(this.passed)}`
|
|
51
|
+
+ (this.skipped ? `, skipped ${chalk[this.skipped ? 'yellowBright' : 'gray'](this.skipped)}` : '')
|
|
52
|
+
+ (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)}` : ''));
|
|
53
|
+
return this.failed === 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
_VerboseReporter_startTime = new WeakMap(), _VerboseReporter_curFileIndex = new WeakMap();
|