ic-mops 0.8.10 → 0.8.11
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/commands/test.js +10 -5
- package/package.json +1 -1
- package/templates/mops-test.yml +0 -1
package/commands/test.js
CHANGED
|
@@ -21,6 +21,8 @@ let globConfig = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export async function test(filter = '', {watch = false} = {}) {
|
|
24
|
+
let rootDir = getRootDir();
|
|
25
|
+
|
|
24
26
|
if (watch) {
|
|
25
27
|
// todo: run only changed for *.test.mo?
|
|
26
28
|
// todo: run all for *.mo?
|
|
@@ -33,7 +35,7 @@ export async function test(filter = '', {watch = false} = {}) {
|
|
|
33
35
|
console.log(chalk.gray((`Press ${chalk.gray('Ctrl+C')} to exit.`)));
|
|
34
36
|
}, 200);
|
|
35
37
|
|
|
36
|
-
let watcher = chokidar.watch(path.join(
|
|
38
|
+
let watcher = chokidar.watch(path.join(rootDir, '**/*.mo'), {
|
|
37
39
|
ignored: ignore,
|
|
38
40
|
ignoreInitial: true,
|
|
39
41
|
});
|
|
@@ -55,6 +57,7 @@ let dfxCache;
|
|
|
55
57
|
|
|
56
58
|
export async function runAll(filter = '') {
|
|
57
59
|
let start = Date.now();
|
|
60
|
+
let rootDir = getRootDir();
|
|
58
61
|
|
|
59
62
|
let files = [];
|
|
60
63
|
let libFiles = glob.sync('**/test?(s)/lib.mo', globConfig);
|
|
@@ -66,7 +69,7 @@ export async function runAll(filter = '') {
|
|
|
66
69
|
if (filter) {
|
|
67
70
|
globStr = `**/test?(s)/**/*${filter}*`;
|
|
68
71
|
}
|
|
69
|
-
files = glob.sync(path.join(
|
|
72
|
+
files = glob.sync(path.join(rootDir, globStr), globConfig);
|
|
70
73
|
}
|
|
71
74
|
if (!files.length) {
|
|
72
75
|
if (filter) {
|
|
@@ -78,9 +81,11 @@ export async function runAll(filter = '') {
|
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
let absToRel = (p) => path.relative(rootDir, path.resolve(p));
|
|
85
|
+
|
|
81
86
|
console.log('Test files:');
|
|
82
87
|
for (let file of files) {
|
|
83
|
-
console.log(chalk.gray(`• ${file}`));
|
|
88
|
+
console.log(chalk.gray(`• ${absToRel(file)}`));
|
|
84
89
|
}
|
|
85
90
|
console.log('='.repeat(50));
|
|
86
91
|
|
|
@@ -97,7 +102,7 @@ export async function runAll(filter = '') {
|
|
|
97
102
|
|
|
98
103
|
await new Promise((resolve) => {
|
|
99
104
|
file !== files[0] && console.log('-'.repeat(50));
|
|
100
|
-
console.log(`Running ${chalk.gray(file)}`);
|
|
105
|
+
console.log(`Running ${chalk.gray(absToRel(file))}`);
|
|
101
106
|
|
|
102
107
|
let proc = spawn(`${dfxCache}/moc`, ['-r', '-wasi-system-api', '-ref-system-api', '--hide-warnings', '--error-detail=2', ...sourcesArr.join(' ').split(' '), file]);
|
|
103
108
|
|
|
@@ -116,7 +121,7 @@ export async function runAll(filter = '') {
|
|
|
116
121
|
let text = data.toString().trim();
|
|
117
122
|
// change absolute file path to relative
|
|
118
123
|
// change :line:col-line:col to :line:col to work in vscode
|
|
119
|
-
text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (m0, m1, m2, m3) => `${
|
|
124
|
+
text = text.replace(/([\w+._/-]+):(\d+).(\d+)(-\d+.\d+)/g, (m0, m1, m2, m3) => `${absToRel(m1)}:${m2}:${m3}`);
|
|
120
125
|
mmf1.fail(text);
|
|
121
126
|
});
|
|
122
127
|
|
package/package.json
CHANGED