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