@camperaid/watest 2.4.7 → 2.4.8
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/.prettierrc.js +1 -3
- package/.watestrc.js +1 -3
- package/bin/watest.js +3 -8
- package/core/base.js +60 -59
- package/core/core.js +25 -46
- package/core/format.js +96 -56
- package/core/process_args.js +1 -5
- package/core/series.js +60 -56
- package/core/settings.js +27 -32
- package/core/spawn.js +14 -21
- package/core/util.js +12 -19
- package/eslint.config.js +27 -0
- package/index.js +11 -17
- package/interfaces/logger.js +1 -3
- package/interfaces/servicer.js +1 -3
- package/logging/filestream.js +3 -7
- package/logging/logging.js +5 -11
- package/logging/logpipe.js +21 -21
- package/package.json +12 -11
- package/tests/base/t_api.js +3 -6
- package/tests/base/t_contains.js +12 -12
- package/tests/base/t_core.js +11 -8
- package/tests/base/t_format.js +13 -14
- package/tests/base/t_is.js +9 -11
- package/tests/base/t_is_object.js +23 -25
- package/tests/base/t_is_primitive.js +12 -14
- package/tests/base/t_is_string.js +6 -8
- package/tests/base/t_ok.js +4 -6
- package/tests/base/t_stringify.js +6 -8
- package/tests/base/t_test_.js +3 -5
- package/tests/base/t_throws.js +10 -12
- package/tests/base/test.js +8 -18
- package/tests/e2e/samples/{loader/.watestrc.cjs → folder/.watestrc.js} +1 -1
- package/tests/e2e/samples/folder/package-lock.json +1019 -5940
- package/tests/e2e/samples/folder/package.json +3 -2
- package/tests/e2e/samples/folder/tests/meta.js +1 -1
- package/tests/e2e/samples/folder/tests/unit/t_test.js +3 -3
- package/tests/e2e/samples/{loader_mixed/.watestrc.cjs → loader/.watestrc.js} +1 -1
- package/tests/e2e/samples/loader/package-lock.json +1751 -28
- package/tests/e2e/samples/loader/package.json +2 -2
- package/tests/e2e/samples/{folder/.watestrc.cjs → loader_mixed/.watestrc.js} +1 -1
- package/tests/e2e/samples/loader_mixed/package-lock.json +1751 -28
- package/tests/e2e/samples/loader_multiple/{.watestrc.cjs → .watestrc.js} +1 -1
- package/tests/e2e/samples/loader_multiple/package-lock.json +1751 -28
- package/tests/e2e/samples/loader_multiple/package.json +2 -2
- package/tests/e2e/samples/single/.watestrc.js +5 -0
- package/tests/e2e/samples/single/package-lock.json +1017 -5938
- package/tests/e2e/samples/single/package.json +5 -2
- package/tests/e2e/samples/wd_mixed/{.watestrc.cjs → .watestrc.js} +1 -1
- package/tests/e2e/samples/wd_mixed/package-lock.json +779 -4862
- package/tests/e2e/samples/wd_mixed/package.json +2 -2
- package/tests/e2e/samples/wd_single/{.watestrc.cjs → .watestrc.js} +1 -1
- package/tests/e2e/samples/wd_single/package-lock.json +779 -4862
- package/tests/e2e/samples/wd_single/package.json +2 -2
- package/tests/e2e/t_folder.js +4 -6
- package/tests/e2e/t_loader.js +4 -6
- package/tests/e2e/t_loader_mixed.js +4 -6
- package/tests/e2e/t_loader_multiple.js +4 -6
- package/tests/e2e/t_loader_multiple_patterns.js +4 -6
- package/tests/e2e/t_single.js +4 -6
- package/tests/e2e/t_wd_firefox.js +4 -6
- package/tests/e2e/t_wd_firefox_chrome.js +4 -6
- package/tests/e2e/t_wd_firefox_chrome_pattern.js +4 -6
- package/tests/e2e/t_wd_mixed_firefox.js +4 -6
- package/tests/e2e/t_wd_mixed_firefox_chrome.js +4 -6
- package/tests/e2e/test.js +15 -16
- package/tests/meta.js +1 -3
- package/tests/series/build/t_adjust_names.js +4 -6
- package/tests/series/build/t_adjust_names_webdriver.js +6 -10
- package/tests/series/build/t_expected_failures.js +4 -6
- package/tests/series/build/t_loader.js +4 -6
- package/tests/series/build/t_loader_mixed.js +4 -6
- package/tests/series/build/t_mixed.js +4 -6
- package/tests/series/build/t_nested.js +4 -6
- package/tests/series/build/t_patterns_loader.js +4 -6
- package/tests/series/build/t_patterns_webdriver.js +4 -6
- package/tests/series/build/t_webdriver.js +4 -6
- package/tests/series/build/t_webdriver_firefox_mixed.js +4 -6
- package/tests/series/build/t_webdriver_nested.js +4 -6
- package/tests/series/build/t_webdriver_services.js +4 -6
- package/tests/series/generic/t_failures_info.js +9 -12
- package/tests/series/logging/t_failures.js +18 -20
- package/tests/series/logging/t_success.js +15 -17
- package/tests/series/logging/t_verify.js +17 -14
- package/tests/series/meta.js +1 -3
- package/tests/series/mock_series.js +7 -13
- package/tests/series/perform/t_failure.js +4 -6
- package/tests/series/perform/t_failure_notest.js +4 -6
- package/tests/series/perform/t_intermittent.js +5 -7
- package/tests/series/perform/t_intermittent_global.js +4 -6
- package/tests/series/perform/t_missing_perma.js +5 -7
- package/tests/series/perform/t_nested.js +4 -10
- package/tests/series/perform/t_perma.js +4 -6
- package/tests/series/perform/t_success.js +5 -11
- package/tests/series/run/t_debunk_failure.js +7 -6
- package/tests/series/run/t_debunk_success.js +7 -6
- package/tests/series/run/t_nested.js +7 -6
- package/tests/series/run/t_verify.js +7 -6
- package/tests/series/run/t_verify_webdriver.js +7 -6
- package/tests/series/test.js +29 -40
- package/tests/webdriver/meta.js +1 -3
- package/tests/webdriver/t_app_driver.js +3 -5
- package/tests/webdriver/t_app_driver_selectors.js +3 -5
- package/tests/webdriver/t_attribute.js +5 -7
- package/tests/webdriver/t_attribute_all.js +6 -8
- package/tests/webdriver/t_doubleclick.js +3 -5
- package/tests/webdriver/t_doubleclickat.js +3 -5
- package/tests/webdriver/t_execute.js +4 -6
- package/tests/webdriver/t_if_has_elements.js +6 -8
- package/tests/webdriver/t_if_no_elements.js +6 -8
- package/tests/webdriver/t_no_elements_or_not_visible.js +7 -9
- package/tests/webdriver/t_properties.js +11 -13
- package/tests/webdriver/t_script.js +8 -10
- package/tests/webdriver/t_select_all.js +6 -11
- package/tests/webdriver/t_selection.js +4 -6
- package/tests/webdriver/t_text.js +12 -14
- package/tests/webdriver/t_text_all.js +6 -8
- package/tests/webdriver/test.js +32 -41
- package/webdriver/app_driver.js +15 -19
- package/webdriver/control_driver.js +4 -8
- package/webdriver/driver.js +58 -61
- package/webdriver/driver_base.js +50 -60
- package/webdriver/session.js +6 -11
- package/webdriver/util.js +7 -8
- package/.eslintrc.js +0 -45
- package/index.mjs +0 -5
- package/tests/e2e/samples/folder/node_modules/.package-lock.json +0 -3871
- package/tests/e2e/samples/loader/node_modules/.package-lock.json +0 -36
- package/tests/e2e/samples/loader_mixed/node_modules/.package-lock.json +0 -36
- package/tests/e2e/samples/loader_multiple/node_modules/.package-lock.json +0 -36
- package/tests/e2e/samples/single/.watestrc.cjs +0 -5
- package/tests/e2e/samples/single/node_modules/.package-lock.json +0 -3871
- package/tests/e2e/samples/wd_mixed/node_modules/.package-lock.json +0 -3586
- package/tests/e2e/samples/wd_single/node_modules/.package-lock.json +0 -3586
package/.prettierrc.js
CHANGED
package/.watestrc.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const cfg = {
|
|
4
2
|
/**
|
|
5
3
|
* Test run and invocation. If not set, then the testuiste will generate them.
|
|
@@ -61,4 +59,4 @@ const cfg = {
|
|
|
61
59
|
ignore_pattern: process.env.WATEST_IGNORE_PATTERN,
|
|
62
60
|
};
|
|
63
61
|
|
|
64
|
-
|
|
62
|
+
export default cfg;
|
package/bin/watest.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { ProcessArgs } from '../core/process_args.js';
|
|
4
|
+
import '../core/settings.js';
|
|
5
|
+
import { runSeries } from '../core/series.js';
|
|
6
6
|
|
|
7
7
|
const args = ProcessArgs.asObject();
|
|
8
8
|
if (args.showHelp) {
|
|
@@ -19,9 +19,4 @@ Options:
|
|
|
19
19
|
process.exit();
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// Initalize config.
|
|
23
|
-
require('../core/settings.js');
|
|
24
|
-
|
|
25
|
-
// Run tests.
|
|
26
|
-
const { runSeries } = require('../core/series.js');
|
|
27
22
|
runSeries(args.patterns, args).then(failures => failures && process.exit(1));
|
package/core/base.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { log, log_error } = require('../logging/logging.js');
|
|
7
|
-
const { format_failure } = require('./format.js');
|
|
8
|
-
const { stringify } = require('./util.js');
|
|
1
|
+
import { success, fail, failed } from './core.js';
|
|
2
|
+
import { format_failure, stderr_unwrap } from './format.js';
|
|
3
|
+
import { stringify } from './util.js';
|
|
4
|
+
import { log, log_error } from '../logging/logging.js';
|
|
9
5
|
|
|
10
6
|
const limit = 100;
|
|
11
7
|
|
|
@@ -36,7 +32,7 @@ function test_is(got, expected, options = {}) {
|
|
|
36
32
|
Object.assign(options, {
|
|
37
33
|
fail_: dummy,
|
|
38
34
|
success_: dummy,
|
|
39
|
-
})
|
|
35
|
+
}),
|
|
40
36
|
);
|
|
41
37
|
}
|
|
42
38
|
|
|
@@ -51,7 +47,7 @@ function test_contains(got, expected, options = {}) {
|
|
|
51
47
|
Object.assign(options, {
|
|
52
48
|
fail_: dummy,
|
|
53
49
|
success_: dummy,
|
|
54
|
-
})
|
|
50
|
+
}),
|
|
55
51
|
);
|
|
56
52
|
}
|
|
57
53
|
|
|
@@ -69,7 +65,7 @@ function contains(
|
|
|
69
65
|
got,
|
|
70
66
|
expected,
|
|
71
67
|
msg,
|
|
72
|
-
{ ignore_unexpected, fail_ = fail, success_ = success } = {}
|
|
68
|
+
{ ignore_unexpected, fail_ = fail, success_ = success } = {},
|
|
73
69
|
) {
|
|
74
70
|
if (typeof got == 'string' || typeof expected == 'string') {
|
|
75
71
|
if (typeof got != 'string') {
|
|
@@ -79,8 +75,8 @@ function contains(
|
|
|
79
75
|
if (typeof expected != 'string') {
|
|
80
76
|
fail_(
|
|
81
77
|
`${msg}, got string, expected ${typeof expected}: ${stringify(
|
|
82
|
-
expected
|
|
83
|
-
)}
|
|
78
|
+
expected,
|
|
79
|
+
)}`,
|
|
84
80
|
);
|
|
85
81
|
return false;
|
|
86
82
|
}
|
|
@@ -90,15 +86,15 @@ function contains(
|
|
|
90
86
|
}
|
|
91
87
|
fail_(
|
|
92
88
|
`${msg}, got string doesn't contain expected string, got: ${stringify(
|
|
93
|
-
got
|
|
94
|
-
)}, expected: ${stringify(expected)}
|
|
89
|
+
got,
|
|
90
|
+
)}, expected: ${stringify(expected)}`,
|
|
95
91
|
);
|
|
96
92
|
return false;
|
|
97
93
|
}
|
|
98
94
|
|
|
99
95
|
if (!(expected instanceof Array)) {
|
|
100
96
|
fail_(
|
|
101
|
-
`${msg}, expected value is not array, expected: ${stringify(expected)}
|
|
97
|
+
`${msg}, expected value is not array, expected: ${stringify(expected)}`,
|
|
102
98
|
);
|
|
103
99
|
return false;
|
|
104
100
|
}
|
|
@@ -110,7 +106,7 @@ function contains(
|
|
|
110
106
|
|
|
111
107
|
if (got.length < expected.length) {
|
|
112
108
|
fail_(
|
|
113
|
-
`${msg}, array is lesser than expected, ${got.length} vs ${expected.length}
|
|
109
|
+
`${msg}, array is lesser than expected, ${got.length} vs ${expected.length}`,
|
|
114
110
|
);
|
|
115
111
|
return false;
|
|
116
112
|
}
|
|
@@ -120,13 +116,13 @@ function contains(
|
|
|
120
116
|
!got.find(g =>
|
|
121
117
|
test_is(g, e, {
|
|
122
118
|
ignore_unexpected,
|
|
123
|
-
})
|
|
119
|
+
}),
|
|
124
120
|
)
|
|
125
121
|
) {
|
|
126
122
|
fail_(
|
|
127
123
|
`${msg}, array has no expected item ${stringify(e)}, got: ${stringify(
|
|
128
|
-
got
|
|
129
|
-
)}
|
|
124
|
+
got,
|
|
125
|
+
)}`,
|
|
130
126
|
);
|
|
131
127
|
return false;
|
|
132
128
|
}
|
|
@@ -140,14 +136,14 @@ function is_string(
|
|
|
140
136
|
got,
|
|
141
137
|
expected,
|
|
142
138
|
msg,
|
|
143
|
-
{ fail_ = fail, success_ = success } = {}
|
|
139
|
+
{ fail_ = fail, success_ = success } = {},
|
|
144
140
|
) {
|
|
145
141
|
// Different types.
|
|
146
142
|
if (typeof got != 'string' || typeof expected != 'string') {
|
|
147
143
|
fail_(
|
|
148
144
|
`${msg} type mismatch, ` +
|
|
149
145
|
`got type: ${typeof got}, expected type: ${typeof expected}, ` +
|
|
150
|
-
`got value: ${stringify(got)}, expected value: ${stringify(expected)}
|
|
146
|
+
`got value: ${stringify(got)}, expected value: ${stringify(expected)}`,
|
|
151
147
|
);
|
|
152
148
|
return false;
|
|
153
149
|
}
|
|
@@ -161,7 +157,7 @@ function is_string(
|
|
|
161
157
|
fail_(
|
|
162
158
|
`${msg};\ngot:\n${got}\nexpected:\n${expected}\n` +
|
|
163
159
|
`unexpected character: '${got.charAt(i)}' at ${i} pos, ` +
|
|
164
|
-
`expected: '${expected.charAt(i)}' at '${line}' line
|
|
160
|
+
`expected: '${expected.charAt(i)}' at '${line}' line`,
|
|
165
161
|
);
|
|
166
162
|
return false;
|
|
167
163
|
}
|
|
@@ -178,7 +174,7 @@ function is_string(
|
|
|
178
174
|
let expected_str = `expected: '${expected}' of ${expected.length} chars`;
|
|
179
175
|
let diff_str = `diff: '${expected.substring(got.length)}'`;
|
|
180
176
|
fail_(
|
|
181
|
-
`${msg}, string longer than expected, ${got_str}, ${expected_str}, ${diff_str}
|
|
177
|
+
`${msg}, string longer than expected, ${got_str}, ${expected_str}, ${diff_str}`,
|
|
182
178
|
);
|
|
183
179
|
return false;
|
|
184
180
|
}
|
|
@@ -187,7 +183,7 @@ function is_primitive(
|
|
|
187
183
|
got,
|
|
188
184
|
expected,
|
|
189
185
|
msg,
|
|
190
|
-
{ enrich_failure_msg, fail_ = fail, success_ = success } = {}
|
|
186
|
+
{ enrich_failure_msg, fail_ = fail, success_ = success } = {},
|
|
191
187
|
) {
|
|
192
188
|
const enrichmsg = (enrich_failure_msg && `${msg} value mismatch`) || msg;
|
|
193
189
|
|
|
@@ -206,7 +202,7 @@ function is_primitive(
|
|
|
206
202
|
return true;
|
|
207
203
|
}
|
|
208
204
|
fail_(
|
|
209
|
-
`${enrichmsg}, got: ${printable_got}, expected: ${expected.toString()}
|
|
205
|
+
`${enrichmsg}, got: ${printable_got}, expected: ${expected.toString()}`,
|
|
210
206
|
);
|
|
211
207
|
return false;
|
|
212
208
|
}
|
|
@@ -232,7 +228,7 @@ function is_primitive(
|
|
|
232
228
|
fail_(
|
|
233
229
|
`${msg} type mismatch, ` +
|
|
234
230
|
`got type: ${typeof got}, expected type: ${typeof expected}, ` +
|
|
235
|
-
`got value: ${stringify(got)}, expected value: ${stringify(expected)}
|
|
231
|
+
`got value: ${stringify(got)}, expected value: ${stringify(expected)}`,
|
|
236
232
|
);
|
|
237
233
|
return false;
|
|
238
234
|
}
|
|
@@ -256,7 +252,7 @@ function is_object(
|
|
|
256
252
|
do_not_print_got_on_success,
|
|
257
253
|
fail_ = fail,
|
|
258
254
|
success_ = success,
|
|
259
|
-
} = {}
|
|
255
|
+
} = {},
|
|
260
256
|
) {
|
|
261
257
|
// Primitive values.
|
|
262
258
|
if (!(got instanceof Object)) {
|
|
@@ -281,13 +277,12 @@ function is_object(
|
|
|
281
277
|
return false;
|
|
282
278
|
}
|
|
283
279
|
|
|
284
|
-
// eslint-disable-next-line complexity
|
|
285
280
|
function is_object_impl(
|
|
286
281
|
got,
|
|
287
282
|
expected,
|
|
288
283
|
msg,
|
|
289
284
|
fieldpath,
|
|
290
|
-
{ ignore_unexpected, fail_, success_ }
|
|
285
|
+
{ ignore_unexpected, fail_, success_ },
|
|
291
286
|
) {
|
|
292
287
|
const contextmsg = `${msg}${(fieldpath && ` '${fieldpath}' field`) || ''}`;
|
|
293
288
|
|
|
@@ -324,7 +319,7 @@ function is_object_impl(
|
|
|
324
319
|
) {
|
|
325
320
|
fail_(
|
|
326
321
|
`${contextmsg} class mismatch, got: ${got.constructor.name}, ` +
|
|
327
|
-
`expected: ${(expected && expected.constructor.name) || expected}
|
|
322
|
+
`expected: ${(expected && expected.constructor.name) || expected}`,
|
|
328
323
|
);
|
|
329
324
|
return false;
|
|
330
325
|
}
|
|
@@ -355,7 +350,7 @@ function is_object_impl(
|
|
|
355
350
|
expected.length
|
|
356
351
|
}.
|
|
357
352
|
Got: ${stringify(got)}
|
|
358
|
-
Expected: ${stringify(expected)}
|
|
353
|
+
Expected: ${stringify(expected)}`,
|
|
359
354
|
);
|
|
360
355
|
return false;
|
|
361
356
|
}
|
|
@@ -369,8 +364,8 @@ Expected: ${stringify(expected)}`
|
|
|
369
364
|
let fpath = (fieldpath && `${fieldpath}->${field}`) || field;
|
|
370
365
|
fail_(
|
|
371
366
|
`${msg} '${fpath}' field was not expected, got: ${stringify(
|
|
372
|
-
got[field]
|
|
373
|
-
)}
|
|
367
|
+
got[field],
|
|
368
|
+
)}`,
|
|
374
369
|
);
|
|
375
370
|
isok = false;
|
|
376
371
|
}
|
|
@@ -422,7 +417,7 @@ async function is_test_output(func, out, err, msg) {
|
|
|
422
417
|
func,
|
|
423
418
|
out.map(expected => got => got.trim().startsWith(expected)),
|
|
424
419
|
err.map(expected => got => got.trim().startsWith(expected)),
|
|
425
|
-
msg
|
|
420
|
+
msg,
|
|
426
421
|
);
|
|
427
422
|
|
|
428
423
|
if (!stdout_matched || !stderr_matched) {
|
|
@@ -465,6 +460,9 @@ async function capture_output(func) {
|
|
|
465
460
|
fail(expection);
|
|
466
461
|
}
|
|
467
462
|
|
|
463
|
+
// Adjust stderr.
|
|
464
|
+
stderr = stderr.map(stderr_unwrap);
|
|
465
|
+
|
|
468
466
|
return {
|
|
469
467
|
stdout,
|
|
470
468
|
stderr,
|
|
@@ -528,8 +526,8 @@ function is_out(got, expected, msg) {
|
|
|
528
526
|
log_error(
|
|
529
527
|
format_failure(
|
|
530
528
|
`got: ${stringify(got_i)}, expected: ${exp_i}`,
|
|
531
|
-
`Unexpected output at index ${i}
|
|
532
|
-
)
|
|
529
|
+
`Unexpected output at index ${i},`,
|
|
530
|
+
),
|
|
533
531
|
);
|
|
534
532
|
}
|
|
535
533
|
continue;
|
|
@@ -544,25 +542,11 @@ function is_out(got, expected, msg) {
|
|
|
544
542
|
`got: ${stringify(got_i)}, expected: ${exp_i}, got len: ${
|
|
545
543
|
got_i.length
|
|
546
544
|
}, expected len: ${exp_i.length}`,
|
|
547
|
-
`Unexpected output at index ${i}
|
|
548
|
-
)
|
|
549
|
-
);
|
|
550
|
-
log_error(
|
|
551
|
-
`index\tgot\texpected\tequal ${Math.min(got_i.length, exp_i.length)}`
|
|
545
|
+
`Unexpected output at index ${i},`,
|
|
546
|
+
),
|
|
552
547
|
);
|
|
553
548
|
|
|
554
|
-
|
|
555
|
-
for (let j = 0; j < min; j++) {
|
|
556
|
-
log_error(`${j}\t'${got_i[j]}'\t'${exp_i[j]}'\t${exp_i[j] == got_i[j]}`);
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
for (let j = min; j < got_i.length; j++) {
|
|
560
|
-
log_error(`${j}\t'${got_i[j]}'`);
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
for (let j = min; j < exp_i.length; j++) {
|
|
564
|
-
log_error(`${j}\t\t'${exp_i[j]}'`);
|
|
565
|
-
}
|
|
549
|
+
print_string_diff(got_i, exp_i);
|
|
566
550
|
}
|
|
567
551
|
return false;
|
|
568
552
|
}
|
|
@@ -586,11 +570,31 @@ function no_throws(func, msg) {
|
|
|
586
570
|
}
|
|
587
571
|
}
|
|
588
572
|
|
|
589
|
-
|
|
573
|
+
function print_string_diff(got, expected) {
|
|
574
|
+
log_error(`index\tgot\texpected\tgot\texpected`);
|
|
575
|
+
|
|
576
|
+
let min = Math.min(got.length, expected.length);
|
|
577
|
+
for (let j = 0; j < min; j++) {
|
|
578
|
+
log_error(
|
|
579
|
+
`${j}\t'${got[j]}'\t'${expected[j]}'\t${
|
|
580
|
+
expected[j] == got[j] ? '' : 'false'
|
|
581
|
+
}\t${got[j].charCodeAt(0)}\t${expected[j].charCodeAt(0)}`,
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
for (let j = min; j < got.length; j++) {
|
|
586
|
+
log_error(`${j}\t'${got[j]}'`);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
for (let j = min; j < expected.length; j++) {
|
|
590
|
+
log_error(`${j}\t\t'${expected[j]}'`);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export {
|
|
590
595
|
success,
|
|
591
596
|
fail,
|
|
592
597
|
failed,
|
|
593
|
-
|
|
594
598
|
ok,
|
|
595
599
|
is,
|
|
596
600
|
contains,
|
|
@@ -599,13 +603,10 @@ module.exports = {
|
|
|
599
603
|
is_object,
|
|
600
604
|
is_primitive,
|
|
601
605
|
is_string,
|
|
602
|
-
|
|
603
606
|
throws,
|
|
604
607
|
no_throws,
|
|
605
|
-
|
|
606
608
|
test_is,
|
|
607
609
|
test_contains,
|
|
608
|
-
|
|
609
610
|
capture_output,
|
|
610
611
|
capture_test_output,
|
|
611
612
|
format_test_output,
|
package/core/core.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { log, log_error, log_trace } = require('../logging/logging.js');
|
|
4
|
-
const {
|
|
1
|
+
import { log, log_error, log_trace } from '../logging/logging.js';
|
|
2
|
+
import {
|
|
5
3
|
format_failure,
|
|
6
4
|
format_intermittent,
|
|
7
5
|
format_ok,
|
|
8
6
|
format_warning,
|
|
9
7
|
colorify,
|
|
10
|
-
}
|
|
11
|
-
|
|
8
|
+
} from './format.js';
|
|
9
|
+
import { inspect, initTmpStorage } from './util.js';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Tracks testing flow, all the failures, intermittents, successes etc.
|
|
15
13
|
*/
|
|
16
14
|
class Core {
|
|
17
|
-
constructor() {
|
|
15
|
+
constructor(timeout) {
|
|
18
16
|
this.kcnt = 0;
|
|
19
17
|
this.fcnt = 0;
|
|
20
18
|
this.todocnt = 0;
|
|
21
19
|
this.intermittentcnt = 0;
|
|
22
20
|
this.warningcnt = 0;
|
|
23
21
|
|
|
24
|
-
this.timeout = 0;
|
|
22
|
+
this.timeout = timeout ?? 0;
|
|
25
23
|
|
|
26
24
|
// Current group.
|
|
27
25
|
this.currgroup = null;
|
|
@@ -142,7 +140,7 @@ class Core {
|
|
|
142
140
|
|
|
143
141
|
failIfExpectedFailurePass() {
|
|
144
142
|
let has_expected_failure = this.expectedFailures.some(f =>
|
|
145
|
-
f.list.every(li => li[1] > 0)
|
|
143
|
+
f.list.every(li => li[1] > 0),
|
|
146
144
|
);
|
|
147
145
|
if (!has_expected_failure) {
|
|
148
146
|
for (let f of this.expectedFailures) {
|
|
@@ -150,7 +148,7 @@ class Core {
|
|
|
150
148
|
let mf = f.list.find(f => f[1] == 0);
|
|
151
149
|
if (mf) {
|
|
152
150
|
this.unconditional_fail(
|
|
153
|
-
`Perma failure '${mf[0]}' has never been hit
|
|
151
|
+
`Perma failure '${mf[0]}' has never been hit`,
|
|
154
152
|
);
|
|
155
153
|
}
|
|
156
154
|
}
|
|
@@ -192,7 +190,7 @@ class Core {
|
|
|
192
190
|
if (
|
|
193
191
|
!this.timeout &&
|
|
194
192
|
this.expectedFailures.find(
|
|
195
|
-
v => v.group == this.currgroup && v.type == 'perma'
|
|
193
|
+
v => v.group == this.currgroup && v.type == 'perma',
|
|
196
194
|
)
|
|
197
195
|
) {
|
|
198
196
|
return 1;
|
|
@@ -204,45 +202,26 @@ class Core {
|
|
|
204
202
|
let primeCore = new Core();
|
|
205
203
|
let currentCore = primeCore;
|
|
206
204
|
|
|
207
|
-
|
|
208
|
-
Core,
|
|
205
|
+
export { Core };
|
|
209
206
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
assert(...args) {
|
|
214
|
-
return currentCore.assert(...args);
|
|
215
|
-
},
|
|
216
|
-
not_reached(...args) {
|
|
217
|
-
return currentCore.not_reached(...args);
|
|
218
|
-
},
|
|
219
|
-
group(...args) {
|
|
220
|
-
return currentCore.group(...args);
|
|
221
|
-
},
|
|
222
|
-
fail(...args) {
|
|
223
|
-
return currentCore.fail(...args);
|
|
207
|
+
export const testflow = {
|
|
208
|
+
lock({ core, timeout } = {}) {
|
|
209
|
+
currentCore = core || new Core(timeout);
|
|
224
210
|
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
},
|
|
228
|
-
warn(...args) {
|
|
229
|
-
return currentCore.warn(...args);
|
|
230
|
-
},
|
|
231
|
-
success(...args) {
|
|
232
|
-
return currentCore.success(...args);
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
failed() {
|
|
236
|
-
return currentCore.failed();
|
|
211
|
+
unlock() {
|
|
212
|
+
currentCore = primeCore;
|
|
237
213
|
},
|
|
238
|
-
|
|
239
214
|
get core() {
|
|
240
215
|
return currentCore;
|
|
241
216
|
},
|
|
242
|
-
lock(core) {
|
|
243
|
-
currentCore = core || new Core();
|
|
244
|
-
},
|
|
245
|
-
unlock() {
|
|
246
|
-
currentCore = primeCore;
|
|
247
|
-
},
|
|
248
217
|
};
|
|
218
|
+
|
|
219
|
+
export const assert = (...args) => currentCore.assert(...args);
|
|
220
|
+
export const info = (...args) => currentCore.info(...args);
|
|
221
|
+
export const not_reached = (...args) => currentCore.not_reached(...args);
|
|
222
|
+
export const group = (...args) => currentCore.group(...args);
|
|
223
|
+
export const fail = (...args) => currentCore.fail(...args);
|
|
224
|
+
export const todo = (...args) => currentCore.todo(...args);
|
|
225
|
+
export const warn = (...args) => currentCore.warn(...args);
|
|
226
|
+
export const success = (...args) => currentCore.success(...args);
|
|
227
|
+
export const failed = () => currentCore.failed();
|
package/core/format.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const esc_char = ''; // \x1b
|
|
2
2
|
|
|
3
3
|
const colors = {
|
|
4
4
|
group: '36',
|
|
@@ -13,17 +13,17 @@ const colors = {
|
|
|
13
13
|
intermittents: '105',
|
|
14
14
|
todos: '103',
|
|
15
15
|
warnings: '103',
|
|
16
|
-
failures:
|
|
16
|
+
failures: `41m${esc_char}[37`,
|
|
17
17
|
success: '102',
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const codes = new Map(
|
|
21
|
-
Array.from(Object.keys(colors)).map(key => [colors[key], key])
|
|
21
|
+
Array.from(Object.keys(colors)).map(key => [colors[key], key]),
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
// Colorifies the message.
|
|
25
25
|
function colorify(color, label, msg) {
|
|
26
|
-
return
|
|
26
|
+
return `${esc_char}[${colors[color]}m${label}${esc_char}[0m ${msg}`;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// Parses the given message.
|
|
@@ -53,60 +53,100 @@ function parse_failure(str) {
|
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
colorify,
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
function format_started(msg) {
|
|
57
|
+
return colorify('started', 'Started', msg);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function format_completed(msg) {
|
|
61
|
+
return colorify('completed', 'Completed', msg);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function format_intermittent(msg) {
|
|
65
|
+
return colorify('intermittent', 'Intermittent:', msg);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function format_intermittents(count, context) {
|
|
69
|
+
let label = context ? `${context} > intermittents` : 'Intermittents';
|
|
70
|
+
return colorify('intermittents', label, `Total: ${count}`);
|
|
71
|
+
}
|
|
60
72
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
format_intermittent(msg) {
|
|
68
|
-
return colorify('intermittent', 'Intermittent:', msg);
|
|
69
|
-
},
|
|
70
|
-
format_intermittents(count, context) {
|
|
71
|
-
let label = context ? `${context} > intermittents` : 'Intermittents';
|
|
72
|
-
return colorify('intermittents', label, `Total: ${count}`);
|
|
73
|
-
},
|
|
74
|
-
format_failure(msg, label) {
|
|
75
|
-
return colorify('failure', label || 'Failed:', msg);
|
|
76
|
-
},
|
|
77
|
-
format_failures(count, context_or_okcount, context) {
|
|
78
|
-
if (typeof context_or_okcount == 'string') {
|
|
79
|
-
return colorify(
|
|
80
|
-
'failures',
|
|
81
|
-
`>${context_or_okcount}`,
|
|
82
|
-
`Failure count: ${count}`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
let label = !context ? 'Failed!' : `${context} > failed`;
|
|
73
|
+
function format_failure(msg, label) {
|
|
74
|
+
return colorify('failure', label || 'Failed:', msg);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function format_failures(count, context_or_okcount, context) {
|
|
78
|
+
if (typeof context_or_okcount == 'string') {
|
|
86
79
|
return colorify(
|
|
87
80
|
'failures',
|
|
88
|
-
|
|
89
|
-
`
|
|
81
|
+
`>${context_or_okcount}`,
|
|
82
|
+
`Failure count: ${count}`,
|
|
90
83
|
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
84
|
+
}
|
|
85
|
+
let label = !context ? 'Failed!' : `${context} > failed`;
|
|
86
|
+
return colorify(
|
|
87
|
+
'failures',
|
|
88
|
+
label,
|
|
89
|
+
`Passed: ${context_or_okcount}. Failed: ${count}`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function format_ok(msg) {
|
|
94
|
+
return colorify('ok', 'Ok:', msg);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function format_success(okcount, context) {
|
|
98
|
+
return colorify('success', context || 'Success!', `Total: ${okcount}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function format_todo(msg) {
|
|
102
|
+
return colorify('todo', 'Todo:', msg);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function format_todos(count, context) {
|
|
106
|
+
let label = context ? `${context} > todos` : 'Todos';
|
|
107
|
+
return colorify('todos', label, `Total: ${count}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function format_warning(msg) {
|
|
111
|
+
return colorify('warning', 'Warning:', msg);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function format_warnings(count, context) {
|
|
115
|
+
let label = context ? `${context} > warnings` : 'Warnings';
|
|
116
|
+
return colorify('warnings', label, `Total: ${count}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Node v20 wraps stderr by '\[31m' and '\[39m' characters.
|
|
120
|
+
function stderr_wrap(s) {
|
|
121
|
+
return `[31m${s}[39m`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function stderr_unwrap(s) {
|
|
125
|
+
// eslint-disable-next-line no-control-regex
|
|
126
|
+
return s.replace(/\[31m(.*?)\[39m(\n?)/gs, '$1$2');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function stderr_format_failure(...args) {
|
|
130
|
+
return stderr_wrap(format_failure(...args));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
colorify,
|
|
135
|
+
parse,
|
|
136
|
+
parse_failure,
|
|
137
|
+
format_started,
|
|
138
|
+
format_completed,
|
|
139
|
+
format_intermittent,
|
|
140
|
+
format_intermittents,
|
|
141
|
+
format_failure,
|
|
142
|
+
format_failures,
|
|
143
|
+
format_ok,
|
|
144
|
+
format_success,
|
|
145
|
+
format_todo,
|
|
146
|
+
format_todos,
|
|
147
|
+
format_warning,
|
|
148
|
+
format_warnings,
|
|
149
|
+
stderr_wrap,
|
|
150
|
+
stderr_unwrap,
|
|
151
|
+
stderr_format_failure,
|
|
112
152
|
};
|