ic-mops 0.45.3 → 1.0.0-pre.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/.eslintrc.json +0 -0
- package/.gitignore +0 -0
- package/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/api/actors.ts +25 -17
- package/api/downloadPackageFiles.ts +0 -0
- package/api/getHighestVersion.ts +0 -0
- package/api/index.ts +0 -0
- package/api/network.ts +0 -0
- package/api/resolveVersion.ts +0 -0
- package/cache.ts +20 -8
- package/cli.ts +28 -27
- package/commands/add.ts +4 -0
- package/commands/bench/bench-canister.mo +34 -8
- package/commands/bench/user-bench.mo +0 -0
- package/commands/bench-replica.ts +11 -6
- package/commands/bench.ts +31 -5
- package/commands/bump.ts +0 -0
- package/commands/docs.ts +0 -0
- package/commands/outdated.ts +0 -0
- package/commands/publish.ts +1 -1
- package/commands/replica.ts +237 -0
- package/commands/search.ts +0 -0
- package/commands/sources.ts +2 -3
- package/commands/sync.ts +0 -0
- package/commands/template.ts +0 -0
- package/commands/test/mmf1.ts +5 -5
- package/commands/test/reporters/compact-reporter.ts +2 -1
- package/commands/test/reporters/files-reporter.ts +3 -2
- package/commands/test/reporters/reporter.ts +2 -1
- package/commands/test/reporters/silent-reporter.ts +2 -1
- package/commands/test/reporters/verbose-reporter.ts +14 -4
- package/commands/test/test.ts +213 -74
- package/commands/test/utils.ts +0 -0
- package/commands/toolchain/moc.ts +0 -0
- package/commands/toolchain/pocket-ic.ts +0 -0
- package/commands/toolchain/toolchain-utils.ts +0 -0
- package/commands/toolchain/wasmtime.ts +0 -0
- package/commands/transfer-ownership.ts +0 -0
- package/commands/update.ts +0 -0
- package/commands/user.ts +71 -1
- package/declarations/bench/bench.did +8 -4
- package/declarations/bench/bench.did.d.ts +4 -0
- package/declarations/bench/bench.did.js +4 -0
- package/declarations/storage/index.d.ts +0 -0
- package/declarations/storage/index.js +0 -0
- package/declarations/storage/storage.did +0 -0
- package/declarations/storage/storage.did.d.ts +0 -0
- package/declarations/storage/storage.did.js +0 -0
- package/dist/api/actors.js +19 -13
- package/dist/cache.js +17 -8
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +24 -27
- package/dist/commands/add.js +3 -0
- package/dist/commands/bench/bench-canister.mo +34 -8
- package/dist/commands/bench/user-bench.mo +0 -0
- package/dist/commands/bench-replica.d.ts +2 -1
- package/dist/commands/bench-replica.js +10 -6
- package/dist/commands/bench.js +29 -5
- package/dist/commands/publish.js +1 -1
- package/dist/commands/replica.d.ts +59 -0
- package/dist/commands/replica.js +193 -0
- package/dist/commands/sources.d.ts +2 -2
- package/dist/commands/sources.js +2 -3
- package/dist/commands/test/mmf1.d.ts +2 -2
- package/dist/commands/test/mmf1.js +4 -4
- package/dist/commands/test/reporters/compact-reporter.d.ts +2 -1
- package/dist/commands/test/reporters/compact-reporter.js +1 -1
- package/dist/commands/test/reporters/files-reporter.d.ts +2 -1
- package/dist/commands/test/reporters/files-reporter.js +2 -2
- package/dist/commands/test/reporters/reporter.d.ts +2 -1
- package/dist/commands/test/reporters/silent-reporter.d.ts +2 -1
- package/dist/commands/test/reporters/silent-reporter.js +1 -1
- package/dist/commands/test/reporters/verbose-reporter.d.ts +3 -1
- package/dist/commands/test/reporters/verbose-reporter.js +12 -4
- package/dist/commands/test/test.d.ts +10 -8
- package/dist/commands/test/test.js +170 -71
- package/dist/commands/user.d.ts +6 -0
- package/dist/commands/user.js +59 -1
- package/dist/declarations/bench/bench.did +8 -4
- package/dist/declarations/bench/bench.did.d.ts +4 -0
- package/dist/declarations/bench/bench.did.js +4 -0
- package/dist/declarations/storage/index.d.ts +0 -0
- package/dist/declarations/storage/index.js +0 -0
- package/dist/declarations/storage/storage.did +0 -0
- package/dist/declarations/storage/storage.did.d.ts +0 -0
- package/dist/declarations/storage/storage.did.js +0 -0
- package/dist/mops.d.ts +1 -1
- package/dist/mops.js +4 -28
- package/dist/package.json +4 -3
- package/dist/resolve-packages.d.ts +2 -2
- package/dist/resolve-packages.js +29 -7
- package/dist/templates/README.md +0 -0
- package/dist/templates/licenses/Apache-2.0 +0 -0
- package/dist/templates/licenses/Apache-2.0-NOTICE +0 -0
- package/dist/templates/licenses/MIT +0 -0
- package/dist/templates/mops-publish.yml +0 -0
- package/dist/templates/mops-test.yml +0 -0
- package/dist/templates/src/lib.mo +0 -0
- package/dist/templates/test/lib.test.mo +0 -0
- package/dist/types.d.ts +1 -0
- package/global.d.ts +0 -0
- package/helpers/get-dfx-version.ts +0 -0
- package/helpers/get-moc-path.ts +0 -0
- package/helpers/get-moc-version.ts +0 -0
- package/mops.ts +4 -31
- package/package.json +4 -3
- package/parallel.ts +0 -0
- package/resolve-packages.ts +39 -8
- package/templates/README.md +0 -0
- package/templates/licenses/Apache-2.0 +0 -0
- package/templates/licenses/Apache-2.0-NOTICE +0 -0
- package/templates/licenses/MIT +0 -0
- package/templates/mops-publish.yml +0 -0
- package/templates/mops-test.yml +0 -0
- package/templates/src/lib.mo +0 -0
- package/templates/test/lib.test.mo +0 -0
- package/types.ts +3 -1
- package/.DS_Store +0 -0
- package/bundle/bench/bench-canister.mo +0 -87
- package/bundle/bench/user-bench.mo +0 -14
- package/bundle/bin/moc-wrapper.sh +0 -40
- package/bundle/bin/mops.js +0 -3
- package/bundle/cli.js +0 -163
- package/bundle/cli.tgz +0 -0
- package/bundle/declarations/bench/bench.did +0 -26
- package/bundle/declarations/bench/bench.did.d.ts +0 -29
- package/bundle/declarations/bench/bench.did.js +0 -26
- package/bundle/declarations/bench/index.d.ts +0 -50
- package/bundle/declarations/bench/index.js +0 -40
- package/bundle/declarations/main/index.d.ts +0 -50
- package/bundle/declarations/main/index.js +0 -40
- package/bundle/declarations/main/main.did +0 -438
- package/bundle/declarations/main/main.did.d.ts +0 -360
- package/bundle/declarations/main/main.did.js +0 -412
- package/bundle/declarations/storage/index.d.ts +0 -50
- package/bundle/declarations/storage/index.js +0 -30
- package/bundle/declarations/storage/storage.did +0 -46
- package/bundle/declarations/storage/storage.did.d.ts +0 -40
- package/bundle/declarations/storage/storage.did.js +0 -38
- package/bundle/package.json +0 -31
- package/bundle/templates/README.md +0 -13
- package/bundle/templates/licenses/Apache-2.0 +0 -202
- package/bundle/templates/licenses/Apache-2.0-NOTICE +0 -13
- package/bundle/templates/licenses/MIT +0 -21
- package/bundle/templates/mops-publish.yml +0 -17
- package/bundle/templates/mops-test.yml +0 -22
- package/bundle/templates/src/lib.mo +0 -15
- package/bundle/templates/test/lib.test.mo +0 -4
- package/commands/import-identity.ts +0 -62
- package/commands/whoami.ts +0 -12
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { execSync, spawn } from 'node:child_process';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import { PassThrough } from 'node:stream';
|
|
6
|
+
import { Actor, HttpAgent } from '@dfinity/agent';
|
|
7
|
+
import { PocketIc, PocketIcServer } from 'pic-ic';
|
|
8
|
+
import { readConfig } from '../mops.js';
|
|
9
|
+
import { toolchain } from './toolchain/index.js';
|
|
10
|
+
export class Replica {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.type = 'dfx';
|
|
13
|
+
this.verbose = false;
|
|
14
|
+
this.canisters = {};
|
|
15
|
+
this.dir = ''; // absolute path (/.../.mops/.test/)
|
|
16
|
+
this.ttl = 60;
|
|
17
|
+
}
|
|
18
|
+
async start({ type, dir, verbose, silent } = {}) {
|
|
19
|
+
this.type = type ?? this.type;
|
|
20
|
+
this.verbose = verbose ?? this.verbose;
|
|
21
|
+
this.dir = dir ?? this.dir;
|
|
22
|
+
silent || console.log(`Starting ${this.type} replica...`);
|
|
23
|
+
if (this.type == 'dfx') {
|
|
24
|
+
fs.mkdirSync(this.dir, { recursive: true });
|
|
25
|
+
fs.writeFileSync(path.join(this.dir, 'dfx.json'), JSON.stringify(this.dfxJson(''), null, 2));
|
|
26
|
+
fs.writeFileSync(path.join(this.dir, 'canister.did'), 'service : { runTests: () -> (); }');
|
|
27
|
+
await this.stop();
|
|
28
|
+
this.dfxProcess = spawn('dfx', ['start', '--clean', '--artificial-delay', '0', (this.verbose ? '' : '-qqqq')].filter(x => x), { cwd: this.dir });
|
|
29
|
+
// process canister logs
|
|
30
|
+
this._attachCanisterLogHandler(this.dfxProcess);
|
|
31
|
+
this.dfxProcess.stdout.on('data', (data) => {
|
|
32
|
+
console.log('DFX:', data.toString());
|
|
33
|
+
});
|
|
34
|
+
// await for dfx to start
|
|
35
|
+
let ok = false;
|
|
36
|
+
while (!ok) {
|
|
37
|
+
await fetch('http://127.0.0.1:4945/api/v2/status')
|
|
38
|
+
.then(res => {
|
|
39
|
+
if (res.status === 200) {
|
|
40
|
+
ok = true;
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
.catch(() => { })
|
|
44
|
+
.finally(() => {
|
|
45
|
+
return new Promise(resolve => setTimeout(resolve, 1000));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
let pocketIcBin = await toolchain.bin('pocket-ic');
|
|
51
|
+
// eslint-disable-next-line
|
|
52
|
+
let config = readConfig();
|
|
53
|
+
if (config.toolchain?.['pocket-ic'] !== '4.0.0') {
|
|
54
|
+
console.error('Current Mops CLI only supports pocket-ic 4.0.0');
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
this.pocketIcServer = await PocketIcServer.start({
|
|
58
|
+
showRuntimeLogs: false,
|
|
59
|
+
showCanisterLogs: false,
|
|
60
|
+
binPath: pocketIcBin,
|
|
61
|
+
ttl: this.ttl,
|
|
62
|
+
});
|
|
63
|
+
this.pocketIc = await PocketIc.create(this.pocketIcServer.getUrl());
|
|
64
|
+
// process canister logs
|
|
65
|
+
this._attachCanisterLogHandler(this.pocketIcServer.serverProcess);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
_attachCanisterLogHandler(proc) {
|
|
69
|
+
let curData = '';
|
|
70
|
+
proc.stderr.on('data', (data) => {
|
|
71
|
+
curData = curData + data.toString();
|
|
72
|
+
if (curData.includes('\n')) {
|
|
73
|
+
let m = curData.match(/\[Canister ([a-z0-9-]+)\] (.*)/);
|
|
74
|
+
if (!m) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let [, canisterId, msg] = m;
|
|
78
|
+
let stream = this.getCanisterStream(canisterId || '');
|
|
79
|
+
if (stream) {
|
|
80
|
+
stream.write(msg);
|
|
81
|
+
}
|
|
82
|
+
curData = '';
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async stop(sigint = false) {
|
|
87
|
+
if (this.type == 'dfx') {
|
|
88
|
+
this.dfxProcess?.kill();
|
|
89
|
+
// execSync('dfx stop' + (this.verbose ? '' : ' -qqqq'), {cwd: this.dir, timeout: 10_000, stdio: ['pipe', this.verbose ? 'inherit' : 'ignore', 'pipe']});
|
|
90
|
+
}
|
|
91
|
+
else if (this.pocketIc && this.pocketIcServer) {
|
|
92
|
+
if (!sigint) {
|
|
93
|
+
await this.pocketIc.tearDown(); // error 'fetch failed' if run on SIGINT
|
|
94
|
+
}
|
|
95
|
+
await this.pocketIcServer.stop();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async deploy(name, wasm, idlFactory, cwd = process.cwd()) {
|
|
99
|
+
if (this.type === 'dfx') {
|
|
100
|
+
// prepare dfx.json for current canister
|
|
101
|
+
let dfxJson = path.join(this.dir, 'dfx.json');
|
|
102
|
+
let oldDfxJsonData;
|
|
103
|
+
if (fs.existsSync(dfxJson)) {
|
|
104
|
+
oldDfxJsonData = JSON.parse(fs.readFileSync(dfxJson).toString());
|
|
105
|
+
}
|
|
106
|
+
let newDfxJsonData = this.dfxJson(name, name + '.wasm');
|
|
107
|
+
if (oldDfxJsonData.canisters) {
|
|
108
|
+
newDfxJsonData.canisters = Object.assign(oldDfxJsonData.canisters, newDfxJsonData.canisters);
|
|
109
|
+
}
|
|
110
|
+
fs.mkdirSync(this.dir, { recursive: true });
|
|
111
|
+
fs.writeFileSync(dfxJson, JSON.stringify(newDfxJsonData, null, 2));
|
|
112
|
+
execSync(`dfx deploy ${name} --mode reinstall --yes --identity anonymous`, { cwd: this.dir, stdio: this.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] });
|
|
113
|
+
execSync(`dfx ledger fabricate-cycles --canister ${name} --t 100`, { cwd: this.dir, stdio: this.verbose ? 'pipe' : ['pipe', 'ignore', 'pipe'] });
|
|
114
|
+
let canisterId = execSync(`dfx canister id ${name}`, { cwd: this.dir }).toString().trim();
|
|
115
|
+
let actor = Actor.createActor(idlFactory, {
|
|
116
|
+
agent: await HttpAgent.create({
|
|
117
|
+
host: 'http://127.0.0.1:4945',
|
|
118
|
+
shouldFetchRootKey: true,
|
|
119
|
+
}),
|
|
120
|
+
canisterId,
|
|
121
|
+
});
|
|
122
|
+
this.canisters[name] = {
|
|
123
|
+
cwd,
|
|
124
|
+
canisterId,
|
|
125
|
+
actor,
|
|
126
|
+
stream: new PassThrough(),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
else if (this.pocketIc) {
|
|
130
|
+
// let {canisterId, actor} = await this.pocketIc.setupCanister(idlFactory, wasm);
|
|
131
|
+
let { canisterId, actor } = await this.pocketIc.setupCanister({
|
|
132
|
+
idlFactory,
|
|
133
|
+
wasm,
|
|
134
|
+
});
|
|
135
|
+
await this.pocketIc.addCycles(canisterId, 1_000_000_000_000);
|
|
136
|
+
this.canisters[name] = {
|
|
137
|
+
cwd,
|
|
138
|
+
canisterId: canisterId.toText(),
|
|
139
|
+
actor,
|
|
140
|
+
stream: new PassThrough(),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (!this.canisters[name]) {
|
|
144
|
+
throw new Error(`Canister ${name} not found`);
|
|
145
|
+
}
|
|
146
|
+
return this.canisters[name];
|
|
147
|
+
}
|
|
148
|
+
getActor(name) {
|
|
149
|
+
if (!this.canisters[name]) {
|
|
150
|
+
throw new Error(`Canister ${name} not found`);
|
|
151
|
+
}
|
|
152
|
+
return this.canisters[name]?.actor;
|
|
153
|
+
}
|
|
154
|
+
getCanister(name) {
|
|
155
|
+
return this.canisters[name];
|
|
156
|
+
}
|
|
157
|
+
getCanisterId(name) {
|
|
158
|
+
return this.canisters[name]?.canisterId || '';
|
|
159
|
+
}
|
|
160
|
+
getCanisterStream(canisterId) {
|
|
161
|
+
for (let canister of Object.values(this.canisters)) {
|
|
162
|
+
if (canister.canisterId === canisterId) {
|
|
163
|
+
return canister.stream;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
dfxJson(canisterName, wasmPath = 'canister.wasm', didPath = 'canister.did') {
|
|
169
|
+
let canisters = {};
|
|
170
|
+
if (canisterName) {
|
|
171
|
+
canisters[canisterName] = {
|
|
172
|
+
type: 'custom',
|
|
173
|
+
wasm: wasmPath,
|
|
174
|
+
candid: didPath,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
version: 1,
|
|
179
|
+
canisters,
|
|
180
|
+
defaults: {
|
|
181
|
+
build: {
|
|
182
|
+
packtool: 'mops sources',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
networks: {
|
|
186
|
+
local: {
|
|
187
|
+
type: 'ephemeral',
|
|
188
|
+
bind: '127.0.0.1:4945',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
package/dist/commands/sources.js
CHANGED
|
@@ -3,12 +3,11 @@ import path from 'node:path';
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import { checkConfigFile, formatDir, formatGithubDir, getDependencyType, readConfig } from '../mops.js';
|
|
5
5
|
import { resolvePackages } from '../resolve-packages.js';
|
|
6
|
-
|
|
7
|
-
export async function sources({ verbose = false, cwd = process.cwd() } = {}) {
|
|
6
|
+
export async function sources({ conflicts = 'ignore', cwd = process.cwd() } = {}) {
|
|
8
7
|
if (!checkConfigFile()) {
|
|
9
8
|
return [];
|
|
10
9
|
}
|
|
11
|
-
let resolvedPackages = await resolvePackages({
|
|
10
|
+
let resolvedPackages = await resolvePackages({ conflicts });
|
|
12
11
|
// sources
|
|
13
12
|
return Object.entries(resolvedPackages).map(([name, version]) => {
|
|
14
13
|
let depType = getDependencyType(version);
|
|
@@ -8,14 +8,14 @@ export declare class MMF1 {
|
|
|
8
8
|
failed: number;
|
|
9
9
|
passed: number;
|
|
10
10
|
skipped: number;
|
|
11
|
-
|
|
11
|
+
strategy: Strategy;
|
|
12
12
|
output: {
|
|
13
13
|
type: MessageType;
|
|
14
14
|
message: string;
|
|
15
15
|
}[];
|
|
16
16
|
nestingSymbol: string;
|
|
17
17
|
passedNamesFlat: string[];
|
|
18
|
-
constructor(
|
|
18
|
+
constructor(strategy: Strategy, file: string);
|
|
19
19
|
_log(type: MessageType, ...args: string[]): void;
|
|
20
20
|
flush(messageType?: MessageType): void;
|
|
21
21
|
parseLine(line: string): void;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// mops:1:skip
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
export class MMF1 {
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(strategy, file) {
|
|
8
8
|
this.stack = [];
|
|
9
9
|
this.currSuite = '';
|
|
10
10
|
this.failed = 0;
|
|
@@ -17,17 +17,17 @@ export class MMF1 {
|
|
|
17
17
|
// or <file> › <suite> › <test>
|
|
18
18
|
// or <file> › <suite> › <test> › <nested-test>...
|
|
19
19
|
this.passedNamesFlat = [];
|
|
20
|
-
this.
|
|
20
|
+
this.strategy = strategy;
|
|
21
21
|
this.file = file;
|
|
22
22
|
}
|
|
23
23
|
_log(type, ...args) {
|
|
24
|
-
if (this.
|
|
24
|
+
if (this.strategy === 'store') {
|
|
25
25
|
this.output.push({
|
|
26
26
|
type,
|
|
27
27
|
message: args.join(' '),
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
else if (this.
|
|
30
|
+
else if (this.strategy === 'print') {
|
|
31
31
|
console.log(...args);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MMF1 } from '../mmf1.js';
|
|
2
2
|
import { Reporter } from './reporter.js';
|
|
3
|
+
import { TestMode } from '../../../types.js';
|
|
3
4
|
export declare class CompactReporter implements Reporter {
|
|
4
5
|
#private;
|
|
5
6
|
passed: number;
|
|
@@ -8,6 +9,6 @@ export declare class CompactReporter implements Reporter {
|
|
|
8
9
|
passedFiles: number;
|
|
9
10
|
failedFiles: number;
|
|
10
11
|
addFiles(files: string[]): void;
|
|
11
|
-
addRun(file: string, mmf: MMF1, state: Promise<void>,
|
|
12
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, _mode: TestMode): void;
|
|
12
13
|
done(): boolean;
|
|
13
14
|
}
|
|
@@ -33,7 +33,7 @@ export class CompactReporter {
|
|
|
33
33
|
__classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
|
|
34
34
|
__classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_startTimer).call(this);
|
|
35
35
|
}
|
|
36
|
-
addRun(file, mmf, state,
|
|
36
|
+
addRun(file, mmf, state, _mode) {
|
|
37
37
|
__classPrivateFieldGet(this, _CompactReporter_runningFiles, "f").add(file);
|
|
38
38
|
__classPrivateFieldGet(this, _CompactReporter_instances, "m", _CompactReporter_log).call(this);
|
|
39
39
|
state.then(() => {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MMF1 } from '../mmf1.js';
|
|
2
2
|
import { Reporter } from './reporter.js';
|
|
3
|
+
import { TestMode } from '../../../types.js';
|
|
3
4
|
export declare class FilesReporter implements Reporter {
|
|
4
5
|
#private;
|
|
5
6
|
passed: number;
|
|
6
7
|
failed: number;
|
|
7
8
|
skipped: number;
|
|
8
9
|
addFiles(files: string[]): void;
|
|
9
|
-
addRun(file: string, mmf: MMF1, state: Promise<void>,
|
|
10
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, mode: TestMode): void;
|
|
10
11
|
done(): boolean;
|
|
11
12
|
}
|
|
@@ -17,7 +17,7 @@ export class FilesReporter {
|
|
|
17
17
|
console.log(`Test files: ${files.length}`);
|
|
18
18
|
console.log('='.repeat(50));
|
|
19
19
|
}
|
|
20
|
-
addRun(file, mmf, state,
|
|
20
|
+
addRun(file, mmf, state, mode) {
|
|
21
21
|
state.then(() => {
|
|
22
22
|
this.passed += Number(mmf.failed === 0);
|
|
23
23
|
this.failed += Number(mmf.failed !== 0);
|
|
@@ -28,7 +28,7 @@ export class FilesReporter {
|
|
|
28
28
|
console.log('-'.repeat(50));
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
|
-
console.log(`${chalk.green('✓')} ${absToRel(file)} ${
|
|
31
|
+
console.log(`${chalk.green('✓')} ${absToRel(file)} ${mode === 'interpreter' ? '' : chalk.gray(`(${mode})`)}`);
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { TestMode } from '../../../types.js';
|
|
1
2
|
import { MMF1 } from '../mmf1.js';
|
|
2
3
|
export interface Reporter {
|
|
3
4
|
addFiles(files: string[]): void;
|
|
4
|
-
addRun(file: string, mmf: MMF1, state: Promise<void>,
|
|
5
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, mode: TestMode, progressive?: boolean): void;
|
|
5
6
|
done(): boolean;
|
|
6
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MMF1 } from '../mmf1.js';
|
|
2
2
|
import { Reporter } from './reporter.js';
|
|
3
|
+
import { TestMode } from '../../../types.js';
|
|
3
4
|
export declare class SilentReporter implements Reporter {
|
|
4
5
|
passed: number;
|
|
5
6
|
failed: number;
|
|
@@ -8,6 +9,6 @@ export declare class SilentReporter implements Reporter {
|
|
|
8
9
|
failedFiles: number;
|
|
9
10
|
passedNamesFlat: string[];
|
|
10
11
|
addFiles(_files: string[]): void;
|
|
11
|
-
addRun(file: string, mmf: MMF1, state: Promise<void>,
|
|
12
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, _mode: TestMode): void;
|
|
12
13
|
done(): boolean;
|
|
13
14
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { MMF1 } from '../mmf1.js';
|
|
2
2
|
import { Reporter } from './reporter.js';
|
|
3
|
+
import { TestMode } from '../../../types.js';
|
|
3
4
|
export declare class VerboseReporter implements Reporter {
|
|
4
5
|
#private;
|
|
5
6
|
passed: number;
|
|
6
7
|
failed: number;
|
|
7
8
|
skipped: number;
|
|
8
9
|
addFiles(files: string[]): void;
|
|
9
|
-
addRun(file: string, mmf: MMF1, state: Promise<void>,
|
|
10
|
+
addRun(file: string, mmf: MMF1, state: Promise<void>, mode: TestMode, progressive?: boolean): void;
|
|
10
11
|
done(): boolean;
|
|
12
|
+
_printStart(file: string, mode: TestMode): void;
|
|
11
13
|
}
|
|
@@ -27,17 +27,20 @@ export class VerboseReporter {
|
|
|
27
27
|
}
|
|
28
28
|
console.log('='.repeat(50));
|
|
29
29
|
}
|
|
30
|
-
addRun(file, mmf, state,
|
|
30
|
+
addRun(file, mmf, state, mode, progressive = false) {
|
|
31
|
+
if (progressive) {
|
|
32
|
+
this._printStart(file, mode);
|
|
33
|
+
}
|
|
31
34
|
state.then(() => {
|
|
32
|
-
var _a, _b;
|
|
33
35
|
this.passed += mmf.passed;
|
|
34
36
|
this.failed += mmf.failed;
|
|
35
37
|
this.skipped += mmf.skipped;
|
|
36
38
|
if (mmf.passed === 0 && mmf.failed === 0) {
|
|
37
39
|
this.passed++;
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
if (!progressive) {
|
|
42
|
+
this._printStart(file, mode);
|
|
43
|
+
}
|
|
41
44
|
mmf.flush();
|
|
42
45
|
});
|
|
43
46
|
}
|
|
@@ -55,5 +58,10 @@ export class VerboseReporter {
|
|
|
55
58
|
+ (this.failed ? `, failed ${chalk[this.failed ? 'redBright' : 'gray'](this.failed)}` : ''));
|
|
56
59
|
return this.failed === 0;
|
|
57
60
|
}
|
|
61
|
+
_printStart(file, mode) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
(__classPrivateFieldSet(this, _VerboseReporter_curFileIndex, (_b = __classPrivateFieldGet(this, _VerboseReporter_curFileIndex, "f"), _a = _b++, _b), "f"), _a) && console.log('-'.repeat(50));
|
|
64
|
+
console.log(`Running ${chalk.gray(absToRel(file))} ${mode === 'interpreter' ? '' : chalk.gray(`(${mode})`)}`);
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
67
|
_VerboseReporter_startTime = new WeakMap(), _VerboseReporter_curFileIndex = new WeakMap();
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Reporter } from './reporters/reporter.js';
|
|
2
|
+
import { TestMode } from '../../types.js';
|
|
2
3
|
type ReporterName = 'verbose' | 'files' | 'compact' | 'silent';
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
watch
|
|
6
|
-
reporter
|
|
7
|
-
mode
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare function
|
|
4
|
+
type ReplicaName = 'dfx' | 'pocket-ic';
|
|
5
|
+
type TestOptions = {
|
|
6
|
+
watch: boolean;
|
|
7
|
+
reporter: ReporterName;
|
|
8
|
+
mode: TestMode;
|
|
9
|
+
replica: ReplicaName;
|
|
10
|
+
};
|
|
11
|
+
export declare function test(filter?: string, options?: Partial<TestOptions>): Promise<void>;
|
|
12
|
+
export declare function testWithReporter(reporterName: ReporterName | Reporter | undefined, filter: string | undefined, defaultMode: TestMode | undefined, replicaType: ReplicaName, watch?: boolean): Promise<boolean>;
|
|
11
13
|
export {};
|