@camperaid/watest 2.5.2 → 2.5.4
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/process-args.js +9 -0
- package/core/series.js +31 -3
- package/core/util.js +19 -2
- package/index.js +4 -1
- package/package.json +1 -1
- package/tests/series/build/t-rerun-suffix.js +66 -0
- package/tests/series/logging/t-verify.js +6 -6
- package/tests/series/run/t-verify-webdriver.js +4 -4
- package/tests/series/run/t-verify.js +6 -6
- package/webdriver/driver-base.js +5 -0
- package/webdriver/driver.js +2 -2
- package/webdriver/session.js +7 -0
package/core/process-args.js
CHANGED
|
@@ -44,6 +44,11 @@ class ProcessArgs {
|
|
|
44
44
|
obj.rootFolder = process.argv[++i];
|
|
45
45
|
break;
|
|
46
46
|
|
|
47
|
+
case '--rerun':
|
|
48
|
+
// Rerun suffix appended to first folder level (e.g., --rerun 5 → www becomes www-5)
|
|
49
|
+
obj.rerun = process.argv[++i];
|
|
50
|
+
break;
|
|
51
|
+
|
|
47
52
|
case '--input-type=module':
|
|
48
53
|
break;
|
|
49
54
|
|
|
@@ -70,6 +75,10 @@ class ProcessArgs {
|
|
|
70
75
|
} else if ('verify' in args) {
|
|
71
76
|
list.push('--verify');
|
|
72
77
|
}
|
|
78
|
+
// Pass rerun suffix to child processes
|
|
79
|
+
if ('rerun' in args) {
|
|
80
|
+
list.push('--rerun', args.rerun);
|
|
81
|
+
}
|
|
73
82
|
return list;
|
|
74
83
|
}
|
|
75
84
|
}
|
package/core/series.js
CHANGED
|
@@ -76,6 +76,7 @@ class Series {
|
|
|
76
76
|
{
|
|
77
77
|
debunk,
|
|
78
78
|
invocation,
|
|
79
|
+
rerun,
|
|
79
80
|
skipOnFail,
|
|
80
81
|
timeout,
|
|
81
82
|
verify,
|
|
@@ -90,6 +91,7 @@ class Series {
|
|
|
90
91
|
) {
|
|
91
92
|
this.debunk = debunk;
|
|
92
93
|
this.invocation = invocation || settings.invocation;
|
|
94
|
+
this.rerun = rerun;
|
|
93
95
|
this.patterns = patterns;
|
|
94
96
|
this.skipOnFail = skipOnFail;
|
|
95
97
|
this.verify = verify;
|
|
@@ -140,9 +142,9 @@ class Series {
|
|
|
140
142
|
await this.runFor(this.patterns.map(p => ({ path: p, webdriver: '' })));
|
|
141
143
|
}
|
|
142
144
|
} else {
|
|
143
|
-
// In
|
|
145
|
+
// In verify mode, re-run all failing tests.
|
|
144
146
|
if (this.verify && this.failures.length > 0) {
|
|
145
|
-
await this.runFor(this.failures, '
|
|
147
|
+
await this.runFor(this.failures, '-verify');
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
log(`Elapsed: ${Date.now() - start_time}ms`);
|
|
@@ -158,11 +160,23 @@ class Series {
|
|
|
158
160
|
virtual_folder: this.invocation,
|
|
159
161
|
});
|
|
160
162
|
|
|
161
|
-
// Adjust names.
|
|
163
|
+
// Adjust names for verify mode (appends postfix like "2").
|
|
162
164
|
if (name_postfix) {
|
|
163
165
|
this.adjustTestNames(tests, name_postfix);
|
|
164
166
|
}
|
|
165
167
|
|
|
168
|
+
// Apply rerun suffix to first folder level (e.g., --rerun 5 → www becomes www-5).
|
|
169
|
+
if (this.rerun) {
|
|
170
|
+
// Extract numeric ID if the argument includes a prefix (e.g. "www-12" -> "12")
|
|
171
|
+
let suffix = this.rerun;
|
|
172
|
+
// Match hyphen + digits at end of string
|
|
173
|
+
const match = suffix.match(/-(\d+)$/);
|
|
174
|
+
if (match) {
|
|
175
|
+
suffix = match[1];
|
|
176
|
+
}
|
|
177
|
+
this.applyRerunSuffix(tests, suffix);
|
|
178
|
+
}
|
|
179
|
+
|
|
166
180
|
if (tests.length == 0) {
|
|
167
181
|
log(
|
|
168
182
|
colorify(
|
|
@@ -586,6 +600,20 @@ class Series {
|
|
|
586
600
|
}
|
|
587
601
|
}
|
|
588
602
|
|
|
603
|
+
/**
|
|
604
|
+
* Apply rerun suffix to the first folder level in test names.
|
|
605
|
+
* e.g., --rerun 5 transforms linux/www/test → linux/www-5/test
|
|
606
|
+
*/
|
|
607
|
+
applyRerunSuffix(tests, suffix) {
|
|
608
|
+
for (let test of tests) {
|
|
609
|
+
// Match first folder after invocation: linux/www/ → linux/www-5/
|
|
610
|
+
test.name = test.name.replace(/^([^/]+\/[^/]+)(\/|$)/, `$1-${suffix}$2`);
|
|
611
|
+
if (test.subtests) {
|
|
612
|
+
this.applyRerunSuffix(test.subtests, suffix);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
589
617
|
/**
|
|
590
618
|
* Runs the tests.
|
|
591
619
|
*/
|
package/core/util.js
CHANGED
|
@@ -98,12 +98,29 @@ function removeDir(path) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
function
|
|
101
|
+
function isMac() {
|
|
102
102
|
return process.platform == 'darwin';
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
function isLinux() {
|
|
106
|
+
return process.platform == 'linux';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isWin() {
|
|
110
|
+
return process.platform == 'win32';
|
|
111
|
+
}
|
|
112
|
+
|
|
105
113
|
function toDataURL(html) {
|
|
106
114
|
return `data:text/html,${querystring.escape(html)}`;
|
|
107
115
|
}
|
|
108
116
|
|
|
109
|
-
export {
|
|
117
|
+
export {
|
|
118
|
+
inspect,
|
|
119
|
+
stringify,
|
|
120
|
+
isMac,
|
|
121
|
+
isLinux,
|
|
122
|
+
isWin,
|
|
123
|
+
toDataURL,
|
|
124
|
+
removeDir,
|
|
125
|
+
initTmpStorage,
|
|
126
|
+
};
|
package/index.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from './core/base.js';
|
|
24
24
|
|
|
25
25
|
import { settings } from './core/settings.js';
|
|
26
|
-
import { inspect } from './core/util.js';
|
|
26
|
+
import { inspect, isMac, isLinux, isWin } from './core/util.js';
|
|
27
27
|
import { AppDriver } from './webdriver/app-driver.js';
|
|
28
28
|
import { ControlDriver } from './webdriver/control-driver.js';
|
|
29
29
|
import { start_session, scope } from './webdriver/session.js';
|
|
@@ -48,6 +48,9 @@ export {
|
|
|
48
48
|
is_output,
|
|
49
49
|
info,
|
|
50
50
|
inspect,
|
|
51
|
+
isLinux,
|
|
52
|
+
isMac,
|
|
53
|
+
isWin,
|
|
51
54
|
not_reached,
|
|
52
55
|
no_throws,
|
|
53
56
|
ok,
|
package/package.json
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { is, MockSeries } from '../test.js';
|
|
2
|
+
|
|
3
|
+
export async function test() {
|
|
4
|
+
const test = got => got.name == 'test_wrap';
|
|
5
|
+
const ts = {
|
|
6
|
+
'www': {
|
|
7
|
+
meta: {
|
|
8
|
+
folders: ['ui', 'api'],
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
'www/ui': {
|
|
12
|
+
files: ['t_login.js'],
|
|
13
|
+
},
|
|
14
|
+
'www/ui/t_login.js': {
|
|
15
|
+
test() {},
|
|
16
|
+
},
|
|
17
|
+
'www/api': {
|
|
18
|
+
files: ['t_search.js'],
|
|
19
|
+
},
|
|
20
|
+
'www/api/t_search.js': {
|
|
21
|
+
test() {},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const series = new MockSeries([], { ts });
|
|
26
|
+
const tests = await series.build({
|
|
27
|
+
patterns: [],
|
|
28
|
+
folder: 'www',
|
|
29
|
+
virtual_folder: 'linux/www',
|
|
30
|
+
});
|
|
31
|
+
series.applyRerunSuffix(tests, '5');
|
|
32
|
+
series.shutdown();
|
|
33
|
+
|
|
34
|
+
is(
|
|
35
|
+
tests,
|
|
36
|
+
[
|
|
37
|
+
{
|
|
38
|
+
name: 'linux/www-5/ui',
|
|
39
|
+
path: 'www/ui/',
|
|
40
|
+
subtests: [
|
|
41
|
+
{
|
|
42
|
+
name: 'linux/www-5/ui/t_login.js',
|
|
43
|
+
path: 'www/ui/t_login.js',
|
|
44
|
+
func: test,
|
|
45
|
+
failures_info: [],
|
|
46
|
+
webdriver: '',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'linux/www-5/api',
|
|
52
|
+
path: 'www/api/',
|
|
53
|
+
subtests: [
|
|
54
|
+
{
|
|
55
|
+
name: 'linux/www-5/api/t_search.js',
|
|
56
|
+
path: 'www/api/t_search.js',
|
|
57
|
+
func: test,
|
|
58
|
+
failures_info: [],
|
|
59
|
+
webdriver: '',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
'rerun suffix transforms linux/www → linux/www-5',
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -93,16 +93,16 @@ export async function test() {
|
|
|
93
93
|
],
|
|
94
94
|
],
|
|
95
95
|
[
|
|
96
|
-
'mac/webdriver/chrome/end-to-end/
|
|
96
|
+
'mac/webdriver/chrome/end-to-end/history-verify/log',
|
|
97
97
|
[
|
|
98
|
-
'\x1B[38;5;99mStarted\x1B[0m mac/webdriver/chrome/end-to-end/
|
|
99
|
-
'!Running: mac/webdriver/chrome/end-to-end/
|
|
98
|
+
'\x1B[38;5;99mStarted\x1B[0m mac/webdriver/chrome/end-to-end/history-verify',
|
|
99
|
+
'!Running: mac/webdriver/chrome/end-to-end/history-verify/t_history.js, path: tests/webdriver/end-to-end/history/t_history.js',
|
|
100
100
|
'\x1B[32mOk:\x1B[0m TestoOk',
|
|
101
101
|
completed_in(
|
|
102
|
-
'mac/webdriver/chrome/end-to-end/
|
|
102
|
+
'mac/webdriver/chrome/end-to-end/history-verify/t_history.js',
|
|
103
103
|
),
|
|
104
|
-
'\x1B[102mmac/webdriver/chrome/end-to-end/
|
|
105
|
-
'\x1B[38;5;243mCompleted\x1B[0m mac/webdriver/chrome/end-to-end/
|
|
104
|
+
'\x1B[102mmac/webdriver/chrome/end-to-end/history-verify\x1B[0m Total: 1',
|
|
105
|
+
'\x1B[38;5;243mCompleted\x1B[0m mac/webdriver/chrome/end-to-end/history-verify',
|
|
106
106
|
],
|
|
107
107
|
],
|
|
108
108
|
]
|
|
@@ -69,11 +69,11 @@ export async function test() {
|
|
|
69
69
|
'\x1B[38;5;99mStarted\x1B[0m mac/webdriver',
|
|
70
70
|
'\x1B[38;5;99mStarted\x1B[0m mac/webdriver/chrome',
|
|
71
71
|
'\x1B[38;5;99mStarted\x1B[0m mac/webdriver/chrome/end-to-end',
|
|
72
|
-
'\x1B[38;5;99mStarted\x1B[0m mac/webdriver/chrome/end-to-end/
|
|
73
|
-
'!Running: mac/webdriver/chrome/end-to-end/
|
|
72
|
+
'\x1B[38;5;99mStarted\x1B[0m mac/webdriver/chrome/end-to-end/sharing-verify',
|
|
73
|
+
'!Running: mac/webdriver/chrome/end-to-end/sharing-verify/t_shared_editing.js, path: tests/webdriver/end-to-end/sharing/t_shared_editing.js',
|
|
74
74
|
'\x1B[32mOk:\x1B[0m WDSuccessio',
|
|
75
|
-
'>mac/webdriver/chrome/end-to-end/
|
|
76
|
-
'\x1B[38;5;243mCompleted\x1B[0m mac/webdriver/chrome/end-to-end/
|
|
75
|
+
'>mac/webdriver/chrome/end-to-end/sharing-verify/t_shared_editing.js completed in',
|
|
76
|
+
'\x1B[38;5;243mCompleted\x1B[0m mac/webdriver/chrome/end-to-end/sharing-verify',
|
|
77
77
|
'Logs are written to',
|
|
78
78
|
'\x1B[38;5;243mCompleted\x1B[0m mac/webdriver/chrome/end-to-end',
|
|
79
79
|
'Logs are written to',
|
|
@@ -55,14 +55,14 @@ export async function test() {
|
|
|
55
55
|
'Logs are written to',
|
|
56
56
|
'\x1B[38;5;99mStarted\x1B[0m mac/',
|
|
57
57
|
'\x1B[38;5;99mStarted\x1B[0m mac/unit',
|
|
58
|
-
'\x1B[38;5;99mStarted\x1B[0m mac/unit/
|
|
59
|
-
'!Running: mac/unit/
|
|
60
|
-
'>mac/unit/
|
|
61
|
-
'\x1B[38;5;243mCompleted\x1B[0m mac/unit/
|
|
58
|
+
'\x1B[38;5;99mStarted\x1B[0m mac/unit/core-verify',
|
|
59
|
+
'!Running: mac/unit/core-verify/t_presto.js, path: tests/unit/core/t_presto.js',
|
|
60
|
+
'>mac/unit/core-verify/t_presto.js completed in',
|
|
61
|
+
'\x1B[38;5;243mCompleted\x1B[0m mac/unit/core-verify',
|
|
62
62
|
'Logs are written to',
|
|
63
63
|
'\x1B[38;5;243mCompleted\x1B[0m mac/unit',
|
|
64
64
|
'Logs are written to',
|
|
65
|
-
'\x1B[41m\x1B[37m>mac/unit/
|
|
65
|
+
'\x1B[41m\x1B[37m>mac/unit/core-verify/t_presto.js\x1B[0m Failure count: 1',
|
|
66
66
|
'\x1B[41m\x1B[37mFailed!\x1B[0m Passed: 0. Failed: 1',
|
|
67
67
|
'\x1B[38;5;243mCompleted\x1B[0m mac/',
|
|
68
68
|
'Logs are written to',
|
|
@@ -75,7 +75,7 @@ export async function test() {
|
|
|
75
75
|
'\x1B[31mFailed:\x1B[0m Presto',
|
|
76
76
|
'\x1B[31m>mac/unit/core/t_presto.js\x1B[0m has 1 failure(s)',
|
|
77
77
|
'\x1B[31mFailed:\x1B[0m Presto',
|
|
78
|
-
'\x1B[31m>mac/unit/
|
|
78
|
+
'\x1B[31m>mac/unit/core-verify/t_presto.js\x1B[0m has 1 failure(s)',
|
|
79
79
|
];
|
|
80
80
|
|
|
81
81
|
await is_test_output(
|
package/webdriver/driver-base.js
CHANGED
|
@@ -39,6 +39,11 @@ function getChromeOptions() {
|
|
|
39
39
|
}
|
|
40
40
|
// Accept self-signed certificates (for k3s testing)
|
|
41
41
|
chromeOptions.addArguments('ignore-certificate-errors');
|
|
42
|
+
|
|
43
|
+
// Required for running in Docker/VPS environments
|
|
44
|
+
chromeOptions.addArguments('no-sandbox');
|
|
45
|
+
chromeOptions.addArguments('disable-dev-shm-usage');
|
|
46
|
+
|
|
42
47
|
return chromeOptions;
|
|
43
48
|
}
|
|
44
49
|
|
package/webdriver/driver.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { By, Condition, Key, until } from 'selenium-webdriver';
|
|
2
2
|
import { test_is, test_contains, is, contains, ok } from '../core/base.js';
|
|
3
3
|
import { assert, fail } from '../core/core.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isMac, stringify, toDataURL } from '../core/util.js';
|
|
5
5
|
import { log } from '../logging/logging.js';
|
|
6
6
|
import { getTimeout, DriverBase } from './driver-base.js';
|
|
7
7
|
|
|
@@ -841,7 +841,7 @@ class Driver extends DriverBase {
|
|
|
841
841
|
assert(msg, `selectAll: no msg`);
|
|
842
842
|
|
|
843
843
|
if (this.firefox) {
|
|
844
|
-
let accel = (
|
|
844
|
+
let accel = (isMac() && Key.COMMAND) || Key.CONTROL;
|
|
845
845
|
return this.waitForElementToInvoke(
|
|
846
846
|
selector,
|
|
847
847
|
el => el.sendKeys(Key.chord(accel, 'a')),
|
package/webdriver/session.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assert, group, fail, info } from '../core/core.js';
|
|
2
2
|
import { log, log_error } from '../logging/logging.js';
|
|
3
3
|
import { Driver } from './driver.js';
|
|
4
|
+
import { isMac, isLinux, isWin } from '../core/util.js';
|
|
4
5
|
|
|
5
6
|
let active_sessions = [];
|
|
6
7
|
|
|
@@ -113,6 +114,12 @@ async function start_session(arg1, arg2) {
|
|
|
113
114
|
|
|
114
115
|
s.isSafari = () => s.driver.safari;
|
|
115
116
|
|
|
117
|
+
s.isMac = () => isMac();
|
|
118
|
+
|
|
119
|
+
s.isLinux = () => isLinux();
|
|
120
|
+
|
|
121
|
+
s.isWin = () => isWin();
|
|
122
|
+
|
|
116
123
|
/**
|
|
117
124
|
* Pause the session for number of secs.
|
|
118
125
|
*/
|