@camperaid/watest 2.2.4 → 2.3.3
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/core/base.js +12 -11
- package/core/core.js +10 -9
- package/core/series.js +51 -32
- package/core/spawn.js +4 -2
- package/core/util.js +2 -1
- package/index.js +2 -1
- package/logging/logging.js +27 -0
- package/logging/logpipe.js +6 -5
- package/package.json +2 -2
- package/tests/e2e/samples/folder/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/folder/package-lock.json +1 -2
- package/tests/e2e/samples/loader/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/loader/package-lock.json +1 -2
- package/tests/e2e/samples/loader_mixed/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/loader_mixed/package-lock.json +1 -2
- package/tests/e2e/samples/loader_multiple/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/loader_multiple/package-lock.json +1 -2
- package/tests/e2e/samples/single/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/single/package-lock.json +1 -2
- package/tests/e2e/samples/wd_mixed/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/wd_mixed/package-lock.json +1 -2
- package/tests/e2e/samples/wd_single/node_modules/.package-lock.json +1 -2
- package/tests/e2e/samples/wd_single/package-lock.json +1 -2
- package/tests/series/build/t_expected_failures.js +111 -0
- package/tests/series/perform/t_intermittent_global.js +80 -0
- package/tests/webdriver/t_app_driver.js +45 -13
- package/tests/webdriver/t_attribute.js +1 -0
- package/tests/webdriver/t_attribute_all.js +1 -0
- package/tests/webdriver/t_properties.js +3 -0
- package/tests/webdriver/t_script.js +2 -0
- package/tests/webdriver/t_select_all.js +67 -0
- package/tests/webdriver/t_selection.js +1 -0
- package/tests/webdriver/t_text.js +4 -0
- package/tests/webdriver/t_text_all.js +3 -0
- package/tests/webdriver/test.js +7 -1
- package/webdriver/app_driver.js +3 -21
- package/webdriver/control_driver.js +32 -0
- package/webdriver/driver.js +20 -14
- package/webdriver/driver_base.js +24 -10
- package/webdriver/session.js +9 -12
package/core/base.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const core = require('./core.js');
|
|
4
4
|
const { success, fail, failed } = core;
|
|
5
|
-
const { format_failure } = require('./format.js');
|
|
6
5
|
|
|
6
|
+
const { log, log_error } = require('../logging/logging.js');
|
|
7
|
+
const { format_failure } = require('./format.js');
|
|
7
8
|
const { stringify } = require('./util.js');
|
|
8
9
|
|
|
9
10
|
const limit = 100;
|
|
@@ -411,12 +412,12 @@ async function is_test_output(func, out, err, msg) {
|
|
|
411
412
|
if (!stdout_matched || !stderr_matched) {
|
|
412
413
|
let formatted = format_test_output({ stdout, stderr });
|
|
413
414
|
if (!stdout_matched) {
|
|
414
|
-
|
|
415
|
-
|
|
415
|
+
log(`Test ready stdout for '${msg}':`);
|
|
416
|
+
log(formatted.stdout);
|
|
416
417
|
}
|
|
417
418
|
if (!stderr_matched) {
|
|
418
|
-
|
|
419
|
-
|
|
419
|
+
log(`Test ready stderr for '${msg}':`);
|
|
420
|
+
log(formatted.stderr);
|
|
420
421
|
}
|
|
421
422
|
}
|
|
422
423
|
}
|
|
@@ -508,7 +509,7 @@ function is_out(got, expected, msg) {
|
|
|
508
509
|
|
|
509
510
|
if (typeof exp_i == 'function') {
|
|
510
511
|
if (!exp_i(got_i)) {
|
|
511
|
-
|
|
512
|
+
log_error(
|
|
512
513
|
format_failure(
|
|
513
514
|
`got: ${stringify(got_i)}, expected: ${exp_i}`,
|
|
514
515
|
`Unexpected output at index ${i},`
|
|
@@ -522,7 +523,7 @@ function is_out(got, expected, msg) {
|
|
|
522
523
|
continue;
|
|
523
524
|
}
|
|
524
525
|
|
|
525
|
-
|
|
526
|
+
log_error(
|
|
526
527
|
format_failure(
|
|
527
528
|
`got: ${stringify(got_i)}, expected: ${exp_i}, got len: ${
|
|
528
529
|
got_i.length
|
|
@@ -530,23 +531,23 @@ function is_out(got, expected, msg) {
|
|
|
530
531
|
`Unexpected output at index ${i},`
|
|
531
532
|
)
|
|
532
533
|
);
|
|
533
|
-
|
|
534
|
+
log_error(
|
|
534
535
|
`index\tgot\texpected\tequal ${Math.min(got_i.length, exp_i.length)}`
|
|
535
536
|
);
|
|
536
537
|
|
|
537
538
|
let min = Math.min(got_i.length, exp_i.length);
|
|
538
539
|
for (let j = 0; j < min; j++) {
|
|
539
|
-
|
|
540
|
+
log_error(
|
|
540
541
|
`${j}\t'${got_i[j]}'\t'${exp_i[j]}'\t${exp_i[j] == got_i[j]}`
|
|
541
542
|
);
|
|
542
543
|
}
|
|
543
544
|
|
|
544
545
|
for (let j = min; j < got_i.length; j++) {
|
|
545
|
-
|
|
546
|
+
log_error(`${j}\t'${got_i[j]}'`);
|
|
546
547
|
}
|
|
547
548
|
|
|
548
549
|
for (let j = min; j < exp_i.length; j++) {
|
|
549
|
-
|
|
550
|
+
log_error(`${j}\t\t'${exp_i[j]}'`);
|
|
550
551
|
}
|
|
551
552
|
}
|
|
552
553
|
return false;
|
package/core/core.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { log, log_error, log_trace } = require('../logging/logging.js');
|
|
3
4
|
const {
|
|
4
5
|
format_failure,
|
|
5
6
|
format_intermittent,
|
|
@@ -29,29 +30,29 @@ class Core {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
info(msg) {
|
|
32
|
-
|
|
33
|
+
log(`Info: ${msg}`);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
assert(cond, msg) {
|
|
36
37
|
if (!cond) {
|
|
37
|
-
|
|
38
|
+
log_trace(msg);
|
|
38
39
|
this.fail(msg);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
not_reached(msg) {
|
|
43
|
-
|
|
44
|
+
log_trace(msg);
|
|
44
45
|
this.fail(msg);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
group(msg, label) {
|
|
48
49
|
this.currgroup = msg;
|
|
49
50
|
label = label || 'Group';
|
|
50
|
-
|
|
51
|
+
log(colorify('group', `${label}:`, msg));
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
success(msg) {
|
|
54
|
-
|
|
55
|
+
log(format_ok(msg));
|
|
55
56
|
this.kcnt++;
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -86,22 +87,22 @@ class Core {
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
unconditional_fail(msg) {
|
|
89
|
-
|
|
90
|
+
log_error(format_failure(msg));
|
|
90
91
|
this.fcnt++;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
intermittent(msg) {
|
|
94
|
-
|
|
95
|
+
log(format_intermittent(msg));
|
|
95
96
|
this.intermittentcnt++;
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
todo(msg) {
|
|
99
|
-
|
|
100
|
+
log(colorify('todo', 'Todo:', msg));
|
|
100
101
|
this.todocnt++;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
warn(msg) {
|
|
104
|
-
|
|
105
|
+
log(format_warning(msg));
|
|
105
106
|
this.warningcnt++;
|
|
106
107
|
}
|
|
107
108
|
|
package/core/series.js
CHANGED
|
@@ -4,6 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const nodepath = path;
|
|
6
6
|
|
|
7
|
+
const { log, log_error } = require('../logging/logging.js');
|
|
7
8
|
const { DriverBase } = require('../webdriver/driver_base.js');
|
|
8
9
|
const testflow = require('./core.js');
|
|
9
10
|
const { parse, parse_failure } = require('./format.js');
|
|
@@ -30,7 +31,7 @@ const root_folder = 'tests';
|
|
|
30
31
|
const root_dir = path.resolve('.');
|
|
31
32
|
|
|
32
33
|
process.on('unhandledRejection', error => {
|
|
33
|
-
|
|
34
|
+
log_error(error);
|
|
34
35
|
fail(`Unhandled Promise rejection`);
|
|
35
36
|
});
|
|
36
37
|
|
|
@@ -60,7 +61,7 @@ class Series {
|
|
|
60
61
|
e => {
|
|
61
62
|
let failures = series.shutdown();
|
|
62
63
|
fail(e.message);
|
|
63
|
-
|
|
64
|
+
log_error(e);
|
|
64
65
|
return failures;
|
|
65
66
|
}
|
|
66
67
|
);
|
|
@@ -144,7 +145,7 @@ class Series {
|
|
|
144
145
|
|
|
145
146
|
await settings.servicer.shutdown();
|
|
146
147
|
|
|
147
|
-
|
|
148
|
+
log(`Elapsed: ${Date.now() - start_time}ms`);
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
/**
|
|
@@ -163,7 +164,7 @@ class Series {
|
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
if (tests.length == 0) {
|
|
166
|
-
|
|
167
|
+
log(
|
|
167
168
|
colorify(
|
|
168
169
|
'failures',
|
|
169
170
|
'!Failed:',
|
|
@@ -184,7 +185,13 @@ class Series {
|
|
|
184
185
|
/**
|
|
185
186
|
* Returns tests as an array of { name, func, ... } objects.
|
|
186
187
|
*/
|
|
187
|
-
async build({
|
|
188
|
+
async build({
|
|
189
|
+
patterns,
|
|
190
|
+
folder,
|
|
191
|
+
virtual_folder,
|
|
192
|
+
webdriver = '',
|
|
193
|
+
inherited_expected_failures = [],
|
|
194
|
+
}) {
|
|
188
195
|
let tests = [];
|
|
189
196
|
try {
|
|
190
197
|
let test_module = await this.loadTestMeta(folder);
|
|
@@ -194,6 +201,12 @@ class Series {
|
|
|
194
201
|
throw new Error(`No tests found in ${folder}`);
|
|
195
202
|
}
|
|
196
203
|
|
|
204
|
+
if (test_module.expected_failures) {
|
|
205
|
+
inherited_expected_failures = inherited_expected_failures.concat(
|
|
206
|
+
test_module.expected_failures.filter(v => v[0] == '**')
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
197
210
|
if (
|
|
198
211
|
!this.childProcess &&
|
|
199
212
|
!this.suppressChildProcessInitiation &&
|
|
@@ -226,7 +239,9 @@ class Series {
|
|
|
226
239
|
virtual_folder,
|
|
227
240
|
subfolders,
|
|
228
241
|
webdriver,
|
|
242
|
+
inherited_expected_failures,
|
|
229
243
|
}),
|
|
244
|
+
inherited_expected_failures,
|
|
230
245
|
});
|
|
231
246
|
}
|
|
232
247
|
|
|
@@ -270,7 +285,9 @@ class Series {
|
|
|
270
285
|
virtual_folder: wd_virtual_folder,
|
|
271
286
|
subfolders,
|
|
272
287
|
webdriver,
|
|
288
|
+
inherited_expected_failures,
|
|
273
289
|
}),
|
|
290
|
+
inherited_expected_failures,
|
|
274
291
|
});
|
|
275
292
|
if (wdtests.length > 0) {
|
|
276
293
|
tests.push({
|
|
@@ -285,7 +302,7 @@ class Series {
|
|
|
285
302
|
name: virtual_folder,
|
|
286
303
|
path: folder,
|
|
287
304
|
func: () => {
|
|
288
|
-
|
|
305
|
+
log_error(e);
|
|
289
306
|
fail(`Failed to process tests in '${folder}' folder`);
|
|
290
307
|
},
|
|
291
308
|
failures_info: [],
|
|
@@ -341,6 +358,7 @@ class Series {
|
|
|
341
358
|
virtual_folder,
|
|
342
359
|
subfolders,
|
|
343
360
|
webdriver,
|
|
361
|
+
inherited_expected_failures,
|
|
344
362
|
}) {
|
|
345
363
|
if (!subfolders) {
|
|
346
364
|
return [];
|
|
@@ -353,6 +371,7 @@ class Series {
|
|
|
353
371
|
folder: `${folder}/${subfolder}`,
|
|
354
372
|
virtual_folder: `${virtual_folder}/${subfolder}`,
|
|
355
373
|
webdriver,
|
|
374
|
+
inherited_expected_failures,
|
|
356
375
|
}).then(subtests => ({
|
|
357
376
|
subfolder,
|
|
358
377
|
subtests,
|
|
@@ -384,6 +403,7 @@ class Series {
|
|
|
384
403
|
patterns,
|
|
385
404
|
webdriver,
|
|
386
405
|
subtests,
|
|
406
|
+
inherited_expected_failures,
|
|
387
407
|
}) {
|
|
388
408
|
const { include_list, exclude_list } = test_module;
|
|
389
409
|
let list = this.buildList({
|
|
@@ -401,7 +421,9 @@ class Series {
|
|
|
401
421
|
return tests;
|
|
402
422
|
}
|
|
403
423
|
|
|
404
|
-
const expected_failures =
|
|
424
|
+
const expected_failures = inherited_expected_failures.concat(
|
|
425
|
+
test_module.expected_failures || []
|
|
426
|
+
);
|
|
405
427
|
|
|
406
428
|
// Initialize
|
|
407
429
|
if (test_module.services || test_module.init) {
|
|
@@ -572,7 +594,7 @@ class Series {
|
|
|
572
594
|
!this.rootFolder.startsWith(folder);
|
|
573
595
|
|
|
574
596
|
if (should_report) {
|
|
575
|
-
|
|
597
|
+
log(format_started(folder));
|
|
576
598
|
}
|
|
577
599
|
|
|
578
600
|
let stop = false;
|
|
@@ -590,9 +612,7 @@ class Series {
|
|
|
590
612
|
} = test;
|
|
591
613
|
|
|
592
614
|
if (stop && !name.endsWith('uninit')) {
|
|
593
|
-
|
|
594
|
-
`\x1b[31m!Skipped:\x1b[0m ${name}, because of previous failures\n`
|
|
595
|
-
);
|
|
615
|
+
log(`\x1b[31m!Skipped:\x1b[0m ${name}, because of previous failures\n`);
|
|
596
616
|
continue;
|
|
597
617
|
}
|
|
598
618
|
|
|
@@ -613,7 +633,7 @@ class Series {
|
|
|
613
633
|
}
|
|
614
634
|
|
|
615
635
|
// Invoke a test.
|
|
616
|
-
|
|
636
|
+
log(`\n!Running: ${name}, path: ${path}\n`);
|
|
617
637
|
let start_time = new Date();
|
|
618
638
|
try {
|
|
619
639
|
this.core.setExpectedFailures(failures_info);
|
|
@@ -621,7 +641,7 @@ class Series {
|
|
|
621
641
|
} catch (e) {
|
|
622
642
|
let failmsg = e;
|
|
623
643
|
if (e instanceof Error) {
|
|
624
|
-
|
|
644
|
+
log_error(e);
|
|
625
645
|
failmsg = e.message;
|
|
626
646
|
}
|
|
627
647
|
fail(failmsg);
|
|
@@ -640,7 +660,7 @@ class Series {
|
|
|
640
660
|
stop = true; // print skipped tests
|
|
641
661
|
}
|
|
642
662
|
|
|
643
|
-
|
|
663
|
+
log(`>${name} completed in ${new Date() - start_time}ms\n`);
|
|
644
664
|
}
|
|
645
665
|
}
|
|
646
666
|
|
|
@@ -654,7 +674,7 @@ class Series {
|
|
|
654
674
|
wcnt,
|
|
655
675
|
ocnt,
|
|
656
676
|
});
|
|
657
|
-
|
|
677
|
+
log(format_completed(folder));
|
|
658
678
|
}
|
|
659
679
|
|
|
660
680
|
// Stop nested logging.
|
|
@@ -668,7 +688,7 @@ class Series {
|
|
|
668
688
|
// Record intermittents.
|
|
669
689
|
let delta = this.core.intermittentCount - this.icnt;
|
|
670
690
|
if (delta > 0) {
|
|
671
|
-
|
|
691
|
+
log(`>${name} has ${delta} intermittent(s)`);
|
|
672
692
|
this.icnt = this.core.intermittentCount;
|
|
673
693
|
hasChanged = true;
|
|
674
694
|
}
|
|
@@ -676,7 +696,7 @@ class Series {
|
|
|
676
696
|
// Record todos.
|
|
677
697
|
delta = this.core.todoCount - this.tcnt;
|
|
678
698
|
if (delta > 0) {
|
|
679
|
-
|
|
699
|
+
log(`>${name} has ${delta} todo(s)`);
|
|
680
700
|
this.tcnt = this.core.todoCount;
|
|
681
701
|
hasChanged = true;
|
|
682
702
|
}
|
|
@@ -684,7 +704,7 @@ class Series {
|
|
|
684
704
|
// Record warnings.
|
|
685
705
|
delta = this.core.warningCount - this.wcnt;
|
|
686
706
|
if (delta > 0) {
|
|
687
|
-
|
|
707
|
+
log(`>${name} has ${delta} warnings(s)`);
|
|
688
708
|
this.wcnt = this.core.warningCount;
|
|
689
709
|
hasChanged = true;
|
|
690
710
|
}
|
|
@@ -707,7 +727,7 @@ class Series {
|
|
|
707
727
|
|
|
708
728
|
// Record failures.
|
|
709
729
|
if (delta > 0) {
|
|
710
|
-
|
|
730
|
+
log_error(format_failure(`has ${delta} failure(s)`, `>${name}`));
|
|
711
731
|
this.failures.push({
|
|
712
732
|
name,
|
|
713
733
|
path,
|
|
@@ -727,28 +747,28 @@ class Series {
|
|
|
727
747
|
// Do not log interim test results into console to reduce noice. Keep
|
|
728
748
|
// file logging. In case of a child process log into console, the main
|
|
729
749
|
// process will take care of that.
|
|
730
|
-
const
|
|
750
|
+
const log_func =
|
|
731
751
|
is_root || this.childProcess
|
|
732
|
-
?
|
|
752
|
+
? log
|
|
733
753
|
: this.LogPipe.logToFile.bind(this.LogPipe);
|
|
734
754
|
|
|
735
755
|
let hasChanged = this.failures.length > fidx || this.core.okCount > ocnt;
|
|
736
756
|
|
|
737
757
|
let delta = this.core.warningCount - wcnt;
|
|
738
758
|
if (delta > 0) {
|
|
739
|
-
|
|
759
|
+
log_func(format_warnings(delta, is_root ? '' : folder));
|
|
740
760
|
hasChanged = true;
|
|
741
761
|
}
|
|
742
762
|
|
|
743
763
|
delta = this.core.intermittentCount - icnt;
|
|
744
764
|
if (delta > 0) {
|
|
745
|
-
|
|
765
|
+
log_func(format_intermittents(delta, is_root ? '' : folder));
|
|
746
766
|
hasChanged = true;
|
|
747
767
|
}
|
|
748
768
|
|
|
749
769
|
delta = this.core.todoCount - tcnt;
|
|
750
770
|
if (delta > 0) {
|
|
751
|
-
|
|
771
|
+
log_func(format_todos(delta, is_root ? '' : folder));
|
|
752
772
|
hasChanged = true;
|
|
753
773
|
}
|
|
754
774
|
|
|
@@ -765,9 +785,9 @@ class Series {
|
|
|
765
785
|
if (this.failures.length > fidx) {
|
|
766
786
|
for (let i = fidx; i < this.failures.length; i++) {
|
|
767
787
|
let f = this.failures[i];
|
|
768
|
-
|
|
788
|
+
log_func(format_failures(f.count, f.name));
|
|
769
789
|
}
|
|
770
|
-
|
|
790
|
+
log_func(
|
|
771
791
|
format_failures(
|
|
772
792
|
this.core.failureCount - fcnt,
|
|
773
793
|
this.core.okCount - ocnt,
|
|
@@ -775,13 +795,13 @@ class Series {
|
|
|
775
795
|
)
|
|
776
796
|
);
|
|
777
797
|
} else {
|
|
778
|
-
|
|
798
|
+
log_func(format_success(this.core.okCount - ocnt, !is_root && folder));
|
|
779
799
|
}
|
|
780
800
|
}
|
|
781
801
|
|
|
782
802
|
static failuresInfo({ failures, webdriver, platform, testname }) {
|
|
783
803
|
let filtered_failures = failures.filter(
|
|
784
|
-
v => testname.includes(v[0]) || v[0] == '*'
|
|
804
|
+
v => testname.includes(v[0]) || v[0] == '*' || v[0] == '**'
|
|
785
805
|
);
|
|
786
806
|
|
|
787
807
|
return (
|
|
@@ -825,7 +845,7 @@ class Series {
|
|
|
825
845
|
return test_module.test;
|
|
826
846
|
},
|
|
827
847
|
e => {
|
|
828
|
-
|
|
848
|
+
log_error(e);
|
|
829
849
|
throw new Error(`Failed to load test: ${test_path}`);
|
|
830
850
|
}
|
|
831
851
|
);
|
|
@@ -867,7 +887,7 @@ class Series {
|
|
|
867
887
|
return spawn('node', args, {}, buffer =>
|
|
868
888
|
this.processChildProcessOutput(name, buffer)
|
|
869
889
|
).catch(e => {
|
|
870
|
-
|
|
890
|
+
log_error(e);
|
|
871
891
|
fail(`Failed to process child process output`);
|
|
872
892
|
});
|
|
873
893
|
}
|
|
@@ -881,8 +901,7 @@ class Series {
|
|
|
881
901
|
continue;
|
|
882
902
|
}
|
|
883
903
|
|
|
884
|
-
let log_func = msg =>
|
|
885
|
-
is_stdout ? console.log(msg) : console.error(msg);
|
|
904
|
+
let log_func = msg => (is_stdout ? log(msg) : log_error(msg));
|
|
886
905
|
|
|
887
906
|
if (line.startsWith('console.debug')) {
|
|
888
907
|
line = line.replace(
|
package/core/spawn.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const { spawn } = require('child_process');
|
|
4
4
|
|
|
5
|
+
const { log_error } = require('../logging/logging.js');
|
|
6
|
+
|
|
5
7
|
class ChildProcess {
|
|
6
8
|
constructor(on_output) {
|
|
7
9
|
this.on_output = on_output;
|
|
@@ -44,8 +46,8 @@ class ChildProcess {
|
|
|
44
46
|
if (!this.processChildProcessOutputPromise) {
|
|
45
47
|
this.processChildProcessOutputPromise = this.processChildProcessBuffer()
|
|
46
48
|
.catch(e => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
log_error(`Unexpected error when parsing a child process output`);
|
|
50
|
+
log_error(e);
|
|
49
51
|
cp.kill('SIGUSR1');
|
|
50
52
|
})
|
|
51
53
|
.then(() => {
|
package/core/util.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const { log } = require('../logging/logging.js');
|
|
4
5
|
const cfg = require('./settings.js');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Logs object in console colored.
|
|
8
9
|
*/
|
|
9
10
|
function inspect(obj) {
|
|
10
|
-
|
|
11
|
+
log(
|
|
11
12
|
require('util').inspect(obj, false, null, true /* enable colors */)
|
|
12
13
|
);
|
|
13
14
|
}
|
package/index.js
CHANGED
|
@@ -26,7 +26,8 @@ const { inspect } = require('./core/util.js');
|
|
|
26
26
|
|
|
27
27
|
const { tmp_storage_dir } = require('./core/settings.js');
|
|
28
28
|
|
|
29
|
-
const { AppDriver
|
|
29
|
+
const { AppDriver } = require('./webdriver/app_driver.js');
|
|
30
|
+
const { ControlDriver } = require('./webdriver/control_driver.js');
|
|
30
31
|
const { start_session, scope } = require('./webdriver/session.js');
|
|
31
32
|
|
|
32
33
|
module.exports = {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { ProcessArgs } = require('../core/process_args.js');
|
|
4
|
+
|
|
5
|
+
function log(...args) {
|
|
6
|
+
console.log(...args);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function log_trace(...args) {
|
|
10
|
+
console.trace(...args);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function log_error(...args) {
|
|
14
|
+
// No stderr in a child process, becuase stdout/stderr streams buffer the data
|
|
15
|
+
// before sending it via callbacks, which may make buffers to contain output
|
|
16
|
+
// from multiple console.log/error calls, which makes the child process output
|
|
17
|
+
// processing messy.
|
|
18
|
+
ProcessArgs.asObject().childProcess ?
|
|
19
|
+
console.log(...args) :
|
|
20
|
+
console.error(...args);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
log,
|
|
25
|
+
log_trace,
|
|
26
|
+
log_error
|
|
27
|
+
};
|
package/logging/logpipe.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
|
|
5
5
|
const settings = require('../core/settings.js');
|
|
6
|
+
const { log, log_error } = require('./logging.js');
|
|
6
7
|
const { log_dir, run } = settings;
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -25,8 +26,8 @@ class LogPipeInstance {
|
|
|
25
26
|
this.fstream = new this.FS(this.log_dir, this.fname);
|
|
26
27
|
|
|
27
28
|
this.fstream.on('error', e => {
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
log_error(`Failed to write to ${this.fstream.filepath}`);
|
|
30
|
+
log_error(e);
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
return settings.logger.testRunStarted({ run, invocation });
|
|
@@ -39,7 +40,7 @@ class LogPipeInstance {
|
|
|
39
40
|
let stream = new this.FS(this.log_dir, name);
|
|
40
41
|
stream.write(content);
|
|
41
42
|
await stream.end();
|
|
42
|
-
|
|
43
|
+
log(`Screenshot is captured and written to ${stream.filepath}`);
|
|
43
44
|
|
|
44
45
|
await settings.logger.writeLogFile({
|
|
45
46
|
run,
|
|
@@ -69,7 +70,7 @@ class LogPipeInstance {
|
|
|
69
70
|
})
|
|
70
71
|
)
|
|
71
72
|
.catch(e => {
|
|
72
|
-
|
|
73
|
+
log_error(`Logging shutdown rejected: ${e}`);
|
|
73
74
|
})
|
|
74
75
|
);
|
|
75
76
|
}
|
|
@@ -130,7 +131,7 @@ class LogPipe {
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
this.suppress_fstream = true;
|
|
133
|
-
|
|
134
|
+
log(`Logs are written to ${pipeToRelease.fstream.filepath}`);
|
|
134
135
|
this.suppress_fstream = false;
|
|
135
136
|
|
|
136
137
|
if (this.stack.length == 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camperaid/watest",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"description": "Web Application Testsuite",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.15.1"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"watest": "./bin/watest.js"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"
|
|
14
|
+
"prepare": "bash tests/install.sh",
|
|
15
15
|
"lint": "eslint '**/*.js'",
|
|
16
16
|
"lint:staged": "eslint --",
|
|
17
17
|
"pretty": "prettier --write",
|