1
1
""" Run acceptance tests with robot framework
2
2
"""
3
3
# pylint: disable=broad-except
4
+ import json
5
+ import multiprocessing
4
6
import os
5
7
import platform
6
8
import shutil
7
9
import sys
8
10
import time
9
- from os .path import join
10
11
from pathlib import Path
11
12
12
13
import robot
14
+ from pabot import pabot
15
+
16
+ OS = platform .system ()
17
+ PY = "" .join (map (str , sys .version_info [:2 ]))
13
18
14
19
ROOT = Path (__file__ ).parent .parent .resolve ()
15
20
ATEST = ROOT / "atest"
16
21
OUT = ATEST / "output"
17
22
18
- OS = platform .system ()
19
- PY = "" .join (map (str , sys .version_info [:2 ]))
23
+ ATEST_RETRIES = json .loads (os .environ .get ("ATEST_RETRIES" , "0" ))
24
+ ATEST_PROCESSES = json .loads (os .environ .get ("ATEST_PROCESSES" , "1" ))
25
+
26
+ if not ATEST_PROCESSES :
27
+ # each test incurs a jupyter server, a browser, and a bunch of language
28
+ # servers and kernels, so be a bit more conservative than the default
29
+ # $CPU_COUNT + 1
30
+ ATEST_PROCESSES = max (int (multiprocessing .cpu_count () / 2 ), 1 ) + 1
20
31
21
32
OS_PY_ARGS = {
22
33
# notebook and ipykernel releases do not yet support python 3.8 on windows
23
34
# ("Windows", "38"): ["--include", "not-supported", "--runemptysuite"]
24
- # TODO: restore when we figure out win36 vs jedi on windows
25
- ("Windows" , "36" ): ["--exclude" , "feature:completion" , "--runemptysuite" ]
26
35
}
27
36
28
37
NON_CRITICAL = [
29
38
# TODO: restore when yaml-language-server supports both config and...
30
39
# everything else: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/245
31
40
["language:yaml" , "feature:config" ],
32
- # TODO: restore when we figure out win36 vs jedi on windows
33
- ["language:python" , "py:36" , "os:windows" ],
34
41
]
35
42
36
-
37
43
# because we use diagnostics as a litmus for "working", revert to behavior
38
44
# from before https://github.com/bash-lsp/bash-language-server/pull/269
39
45
os .environ ["HIGHLIGHT_PARSING_ERRORS" ] = "true"
@@ -51,24 +57,6 @@ def get_stem(attempt, extra_args):
51
57
def atest (attempt , extra_args ):
52
58
"""perform a single attempt of the acceptance tests"""
53
59
54
- # TODO: investigate whether this is still required vs geckodriver 0.28
55
- if "FIREFOX_BINARY" not in os .environ :
56
- os .environ ["FIREFOX_BINARY" ] = shutil .which ("firefox" )
57
-
58
- prefix = os .environ .get ("CONDA_PREFIX" )
59
-
60
- if prefix :
61
- app_dir = join (prefix , "bin" , "FirefoxApp" )
62
- os .environ ["FIREFOX_BINARY" ] = {
63
- "Windows" : join (prefix , "Library" , "bin" , "firefox.exe" ),
64
- "Linux" : join (app_dir , "firefox" ),
65
- "Darwin" : join (app_dir , "Contents" , "MacOS" , "firefox" ),
66
- }[OS ]
67
-
68
- print ("Will use firefox at" , os .environ ["FIREFOX_BINARY" ])
69
-
70
- assert os .path .exists (os .environ ["FIREFOX_BINARY" ])
71
-
72
60
extra_args += OS_PY_ARGS .get ((OS , PY ), [])
73
61
74
62
stem = get_stem (attempt , extra_args )
@@ -88,41 +76,49 @@ def atest(attempt, extra_args):
88
76
f"{ OS } { PY } " ,
89
77
"--outputdir" ,
90
78
out_dir ,
91
- "--output" ,
92
- OUT / f"{ stem } .robot.xml" ,
93
- "--log" ,
94
- OUT / f"{ stem } .log.html" ,
95
- "--report" ,
96
- OUT / f"{ stem } .report.html" ,
97
- "--xunit" ,
98
- OUT / f"{ stem } .xunit.xml" ,
99
79
"--variable" ,
100
80
f"OS:{ OS } " ,
101
81
"--variable" ,
102
82
f"PY:{ PY } " ,
103
83
# don't ever test our examples
104
84
"--exclude" ,
105
85
"atest:example" ,
106
- # random ensures there's not inter-test coupling
107
- "--randomize" ,
108
- "all" ,
109
86
* (extra_args or []),
110
87
ATEST ,
111
88
]
112
89
113
90
print ("Robot Arguments\n " , " " .join (["robot" ] + list (map (str , args ))))
114
91
115
- os .chdir (ATEST )
116
-
117
92
if out_dir .exists ():
118
93
print ("trying to clean out {}" .format (out_dir ))
119
94
try :
120
95
shutil .rmtree (out_dir )
121
96
except Exception as err :
122
97
print ("Error deleting {}, hopefully harmless: {}" .format (out_dir , err ))
123
98
99
+ os .chdir (ATEST )
100
+
101
+ str_args = list (map (str , args ))
102
+
124
103
try :
125
- robot .run_cli (list (map (str , args )))
104
+ if "--dryrun" in extra_args or ATEST_PROCESSES == 1 :
105
+ robot .run_cli (
106
+ [
107
+ # random ensures there's not inter-test coupling
108
+ "--randomize" ,
109
+ "all" ,
110
+ * str_args ,
111
+ ]
112
+ )
113
+ else :
114
+ pabot .main (
115
+ [
116
+ * ("--processes" , f"{ ATEST_PROCESSES } " ),
117
+ * ("--artifacts" , "png,log" ),
118
+ "--artifactsinsubfolders" ,
119
+ * str_args ,
120
+ ]
121
+ )
126
122
return 0
127
123
except SystemExit as err :
128
124
return err .code
@@ -133,7 +129,7 @@ def attempt_atest_with_retries(*extra_args):
133
129
attempt = 0
134
130
error_count = - 1
135
131
136
- retries = int ( os . environ . get ( " ATEST_RETRIES" ) or "0" )
132
+ retries = ATEST_RETRIES
137
133
138
134
while error_count != 0 and attempt <= retries :
139
135
attempt += 1
0 commit comments