Skip to content

Commit 064e64a

Browse files
committed
add (opt-in) pabot, clean up ff
1 parent 77b3efb commit 064e64a

File tree

4 files changed

+49
-51
lines changed

4 files changed

+49
-51
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ node_modules
110110
*.tgz
111111

112112
atest/output/
113+
.pabotsuitenames
113114
junit.xml
114115
coverage/
115116
.vscode/

atest/Keywords.resource

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,16 @@ Wait For Splash
112112

113113
Open JupyterLab
114114
Set Environment Variable MOZ_HEADLESS ${HEADLESS}
115-
${firefox} = Get Firefox Binary
116115
${geckodriver} = Which geckodriver
117116
Should Not Be Equal As Strings ${geckodriver} None
118117
... geckodriver not found, do you need to install firefox-geckodriver?
119118
${service args} = Create List --log debug
120119
Create WebDriver Firefox
121120
... executable_path=${geckodriver}
122-
... firefox_binary=${firefox}
123121
... service_log_path=${GECKODRIVER LOG}
124122
... service_args=${service args}
125123
Wait Until Keyword Succeeds 3x 5s Wait For Splash
126124

127-
Get Firefox Binary
128-
[Documentation] Get Firefox path from the environment... or hope for the best
129-
${from which} = Which firefox
130-
${firefox} = Set Variable If "%{FIREFOX_BINARY}" %{FIREFOX_BINARY} ${from which}
131-
[Return] ${firefox}
132-
133125
Close JupyterLab
134126
Close All Browsers
135127

scripts/atest.py

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
11
""" Run acceptance tests with robot framework
22
"""
33
# pylint: disable=broad-except
4+
import json
5+
import multiprocessing
46
import os
57
import platform
68
import shutil
79
import sys
810
import time
9-
from os.path import join
1011
from pathlib import Path
1112

1213
import robot
14+
from pabot import pabot
15+
16+
OS = platform.system()
17+
PY = "".join(map(str, sys.version_info[:2]))
1318

1419
ROOT = Path(__file__).parent.parent.resolve()
1520
ATEST = ROOT / "atest"
1621
OUT = ATEST / "output"
1722

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
2031

2132
OS_PY_ARGS = {
2233
# notebook and ipykernel releases do not yet support python 3.8 on windows
2334
# ("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"]
2635
}
2736

2837
NON_CRITICAL = [
2938
# TODO: restore when yaml-language-server supports both config and...
3039
# everything else: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/245
3140
["language:yaml", "feature:config"],
32-
# TODO: restore when we figure out win36 vs jedi on windows
33-
["language:python", "py:36", "os:windows"],
3441
]
3542

36-
3743
# because we use diagnostics as a litmus for "working", revert to behavior
3844
# from before https://github.com/bash-lsp/bash-language-server/pull/269
3945
os.environ["HIGHLIGHT_PARSING_ERRORS"] = "true"
@@ -51,24 +57,6 @@ def get_stem(attempt, extra_args):
5157
def atest(attempt, extra_args):
5258
"""perform a single attempt of the acceptance tests"""
5359

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-
7260
extra_args += OS_PY_ARGS.get((OS, PY), [])
7361

7462
stem = get_stem(attempt, extra_args)
@@ -88,41 +76,49 @@ def atest(attempt, extra_args):
8876
f"{OS}{PY}",
8977
"--outputdir",
9078
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",
9979
"--variable",
10080
f"OS:{OS}",
10181
"--variable",
10282
f"PY:{PY}",
10383
# don't ever test our examples
10484
"--exclude",
10585
"atest:example",
106-
# random ensures there's not inter-test coupling
107-
"--randomize",
108-
"all",
10986
*(extra_args or []),
11087
ATEST,
11188
]
11289

11390
print("Robot Arguments\n", " ".join(["robot"] + list(map(str, args))))
11491

115-
os.chdir(ATEST)
116-
11792
if out_dir.exists():
11893
print("trying to clean out {}".format(out_dir))
11994
try:
12095
shutil.rmtree(out_dir)
12196
except Exception as err:
12297
print("Error deleting {}, hopefully harmless: {}".format(out_dir, err))
12398

99+
os.chdir(ATEST)
100+
101+
str_args = list(map(str, args))
102+
124103
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+
)
126122
return 0
127123
except SystemExit as err:
128124
return err.code
@@ -133,7 +129,7 @@ def attempt_atest_with_retries(*extra_args):
133129
attempt = 0
134130
error_count = -1
135131

136-
retries = int(os.environ.get("ATEST_RETRIES") or "0")
132+
retries = ATEST_RETRIES
137133

138134
while error_count != 0 and attempt <= retries:
139135
attempt += 1

scripts/lint.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,21 @@
6565
def lint():
6666
"""get that linty fresh feeling"""
6767

68+
def call_with_print(args):
69+
str_args = [a for a in args if isinstance(a, str)]
70+
paths = [a for a in args if isinstance(a, Path)]
71+
print(f"{len(paths)} paths:", " ".join(str_args))
72+
return_code = call(list(map(str, args)))
73+
if return_code:
74+
print("\n...", f"ERROR {return_code}", *str_args, "\n")
75+
return return_code
76+
6877
return max(
6978
map(
70-
call,
79+
call_with_print,
7180
[
7281
["isort", *ALL_PY],
73-
["black", *ALL_PY],
82+
["black", "--quiet", *ALL_PY],
7483
["flake8", *ALL_PY],
7584
*[
7685
# see https://github.com/python/mypy/issues/4008

0 commit comments

Comments
 (0)