@camperaid/watest 2.4.7 → 2.4.9
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 +7 -3
- package/bin/watest.js +3 -8
- package/core/base.js +83 -69
- package/core/core.js +25 -46
- package/core/format.js +96 -56
- package/core/process_args.js +1 -5
- package/core/series.js +62 -57
- package/core/settings.js +32 -32
- package/core/spawn.js +14 -21
- package/core/util.js +12 -19
- package/esling.config.js +0 -0
- 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 +82 -18
- package/tests/base/test.js +14 -21
- 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/loader/tests/meta.js +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_mixed/tests/ui/meta.js +2 -2
- 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/loader_multiple/tests/base/meta.js +2 -2
- package/tests/e2e/samples/loader_multiple/tests/core/meta.js +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/loader/meta.mjs +2 -2
- 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 +28 -19
- package/webdriver/control_driver.js +4 -8
- package/webdriver/driver.js +64 -63
- package/webdriver/driver_base.js +52 -62
- 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.
|
|
@@ -34,6 +32,12 @@ const cfg = {
|
|
|
34
32
|
*/
|
|
35
33
|
webdriver_headless: process.env.WATEST_WEBDRIVER_HEADLESS,
|
|
36
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Web driver window size.
|
|
37
|
+
*/
|
|
38
|
+
webdriver_window_width: process.env.WATEST_WEBDRIVER_WINDOW_WIDTH,
|
|
39
|
+
webdriver_window_height: process.env.WATEST_WEBDRIVER_WINDOW_HEIGHT,
|
|
40
|
+
|
|
37
41
|
/**
|
|
38
42
|
* Web driver log level.
|
|
39
43
|
*/
|
|
@@ -61,4 +65,4 @@ const cfg = {
|
|
|
61
65
|
ignore_pattern: process.env.WATEST_IGNORE_PATTERN,
|
|
62
66
|
};
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
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,53 +542,72 @@ 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
|
}
|
|
569
553
|
|
|
570
554
|
function throws(func, exception, msg) {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
} catch (e) {
|
|
575
|
-
is(e?.message, exception, msg);
|
|
576
|
-
}
|
|
555
|
+
const on_no_exception = () => fail(`${msg}: no '${exception}' exception`);
|
|
556
|
+
const on_exception = e => is(e?.message, exception, msg);
|
|
557
|
+
return throw_internal(func, on_no_exception, on_exception);
|
|
577
558
|
}
|
|
578
559
|
|
|
579
560
|
function no_throws(func, msg) {
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
success(msg);
|
|
583
|
-
} catch (e) {
|
|
561
|
+
const on_no_exception = () => success(msg);
|
|
562
|
+
const on_exception = e => {
|
|
584
563
|
log_error(e);
|
|
585
564
|
fail(`${msg}, got: ${e?.message ?? ''} exception`);
|
|
565
|
+
};
|
|
566
|
+
return throw_internal(func, on_no_exception, on_exception);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function throw_internal(func, on_no_exception, on_exception) {
|
|
570
|
+
try {
|
|
571
|
+
const result = func();
|
|
572
|
+
|
|
573
|
+
// If result is a Promise, handle it asynchronously
|
|
574
|
+
if (result && typeof result.then === 'function') {
|
|
575
|
+
return result.then(on_no_exception, on_exception);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// Sync function completed successfully (no exception)
|
|
579
|
+
on_no_exception();
|
|
580
|
+
} catch (e) {
|
|
581
|
+
// Sync function threw an exception
|
|
582
|
+
on_exception(e);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function print_string_diff(got, expected) {
|
|
587
|
+
log_error(`index\tgot\texpected\tgot\texpected`);
|
|
588
|
+
|
|
589
|
+
let min = Math.min(got.length, expected.length);
|
|
590
|
+
for (let j = 0; j < min; j++) {
|
|
591
|
+
log_error(
|
|
592
|
+
`${j}\t'${got[j]}'\t'${expected[j]}'\t${
|
|
593
|
+
expected[j] == got[j] ? '' : 'false'
|
|
594
|
+
}\t${got[j].charCodeAt(0)}\t${expected[j].charCodeAt(0)}`,
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
for (let j = min; j < got.length; j++) {
|
|
599
|
+
log_error(`${j}\t'${got[j]}'`);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
for (let j = min; j < expected.length; j++) {
|
|
603
|
+
log_error(`${j}\t\t'${expected[j]}'`);
|
|
586
604
|
}
|
|
587
605
|
}
|
|
588
606
|
|
|
589
|
-
|
|
607
|
+
export {
|
|
590
608
|
success,
|
|
591
609
|
fail,
|
|
592
610
|
failed,
|
|
593
|
-
|
|
594
611
|
ok,
|
|
595
612
|
is,
|
|
596
613
|
contains,
|
|
@@ -599,13 +616,10 @@ module.exports = {
|
|
|
599
616
|
is_object,
|
|
600
617
|
is_primitive,
|
|
601
618
|
is_string,
|
|
602
|
-
|
|
603
619
|
throws,
|
|
604
620
|
no_throws,
|
|
605
|
-
|
|
606
621
|
test_is,
|
|
607
622
|
test_contains,
|
|
608
|
-
|
|
609
623
|
capture_output,
|
|
610
624
|
capture_test_output,
|
|
611
625
|
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();
|