Skip to content

Commit aaaf187

Browse files
authored
Merge pull request #150 from bollwyvl/test-retries-and-38
More Robot Test Robustness
2 parents 6c075fc + 4833c66 commit aaaf187

File tree

10 files changed

+57
-19
lines changed

10 files changed

+57
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Advanced static-analysis autocompletion without a running kernel
6363
Either:
6464

6565
- JupyterLab >=1.1.4,<1.2
66-
- JupyterLab >=1.2.3,<1.3.0a0
66+
- JupyterLab >=1.2.4,<1.3.0a0
6767
- Python 3.5+
6868
- nodejs 8+
6969

atest/00_Smoke.robot

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ Resource Keywords.robot
55
*** Test Cases ***
66
Lab Version
77
Capture Page Screenshot 00-smoke.png
8-
${script} = Get Element Attribute id:jupyter-config-data innerHTML
9-
${config} = Evaluate __import__("json").loads("""${script}""")
10-
Set Global Variable ${PAGE CONFIG} ${config}
11-
Set Global Variable ${LAB VERSION} ${config["appVersion"]}
128

139
Root URI
1410
[Documentation] the rootUri should be set in the page config

atest/Keywords.robot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Setup Server and Browser
2828
... stderr=STDOUT
2929
Set Global Variable ${SERVER} ${server}
3030
Open JupyterLab
31+
${script} = Get Element Attribute id:jupyter-config-data innerHTML
32+
${config} = Evaluate __import__("json").loads("""${script}""")
33+
Set Global Variable ${PAGE CONFIG} ${config}
34+
Set Global Variable ${LAB VERSION} ${config["appVersion"]}
3135

3236
Setup Suite For Screenshots
3337
[Arguments] ${folder}

ci/job.combine.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ parameters:
66
pythons:
77
- ThreeSix
88
- ThreeSeven
9+
- ThreeEight
910
install_robot: conda install -yc conda-forge robotframework
1011

1112
jobs:

ci/job.test.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ parameters:
1515
lab: '>=1.1,<1.2.0a0'
1616
- name: ThreeSeven
1717
spec: '>=3.7,<3.8.0a0'
18-
lab: '>=1.2.3,<1.3.0a0'
18+
lab: '>=1.2.4,<1.3.0a0'
19+
- name: ThreeEight
20+
spec: '>=3.8,<3.9.0a0'
21+
lab: '>=1.2.4,<1.3.0a0'
1922
env_update: conda env update -n jupyterlab-lsp --file env-test.yml --quiet
2023
lab_ext: jupyter labextension install --no-build $(THIRD_PARTY_LABEXTENSIONS) $(FIRST_PARTY_LABEXTENSIONS)
2124

@@ -39,13 +42,6 @@ jobs:
3942
- script: conda info && conda list -n jupyterlab-lsp
4043
displayName: list conda packages and info
4144

42-
# TODO: determine how can bring this back to get more robust installs (see #115)
43-
# - task: CacheBeta@0
44-
# inputs:
45-
# key: yarn | $(Agent.OS) | yarn.lock
46-
# path: $(YARN_CACHE_FOLDER)
47-
# displayName: restore cached yarn packages
48-
4945
- script: ${{ platform.activate }} jupyterlab-lsp && jlpm || jlpm || jlpm
5046
displayName: install npm dependencies
5147

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ channels:
77
dependencies:
88
# runtime dependencies
99
- python >=3.7,<3.8.0a0
10-
- jupyterlab >=1.2.3,<1.3.0a0
10+
- jupyterlab >=1.2.4,<1.3.0a0
1111
- notebook >=4.3.1
1212
# build dependencies
1313
- nodejs

requirements-lab.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# the version of jupyterlab
22
-r requirements.txt
3-
jupyterlab >=1.2.3,<1.3.0a0
3+
jupyterlab >=1.2.4,<1.3.0a0

scripts/atest.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import platform
66
import shutil
77
import sys
8+
import time
89
from pathlib import Path
910

1011
import robot
@@ -16,11 +17,33 @@
1617
OS = platform.system()
1718
PY = "".join(map(str, sys.version_info[:2]))
1819

20+
OS_PY_ARGS = {
21+
# notebook and ipykernel releases do not yet support python 3.8 on windows
22+
("Windows", "38"): ["--include", "not-supported", "--runemptysuite"]
23+
}
24+
25+
26+
def get_stem(attempt, extra_args):
27+
stem = "_".join([OS, PY, str(attempt)]).replace(".", "_").lower()
28+
29+
if "--dryrun" in extra_args:
30+
stem = f"dry_run_{stem}"
31+
32+
return stem
33+
1934

2035
def atest(attempt, extra_args):
2136
""" perform a single attempt of the acceptance tests
2237
"""
23-
stem = "_".join([OS, PY, str(attempt)]).replace(".", "_").lower()
38+
extra_args += OS_PY_ARGS.get((OS, PY), [])
39+
40+
stem = get_stem(attempt, extra_args)
41+
42+
if attempt != 1:
43+
previous = OUT / f"{get_stem(attempt - 1, extra_args)}.robot.xml"
44+
if previous.exists():
45+
extra_args += ["--rerunfailed", str(previous)]
46+
2447
out_dir = OUT / stem
2548

2649
args = [
@@ -40,6 +63,8 @@ def atest(attempt, extra_args):
4063
f"OS:{OS}",
4164
"--variable",
4265
f"PY:{PY}",
66+
"--randomize",
67+
"all",
4368
*(extra_args or []),
4469
ATEST,
4570
]
@@ -71,7 +96,9 @@ def attempt_atest_with_retries(*extra_args):
7196
while error_count != 0 and attempt <= retries:
7297
attempt += 1
7398
print("attempt {} of {}...".format(attempt, retries + 1))
74-
error_count = atest(attempt=attempt, extra_args=extra_args)
99+
start_time = time.time()
100+
error_count = atest(attempt=attempt, extra_args=list(extra_args))
101+
print(error_count, "errors in", int(time.time() - start_time), "seconds")
75102

76103
return error_count
77104

scripts/combine.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ def combine_robot_reports():
2424
*OUT.glob("*.robot.xml"),
2525
]
2626

27-
return rebot_cli(args, exit=False)
27+
return_code = rebot_cli(args, exit=False)
28+
print("rebot returned", return_code)
29+
30+
return 0
2831

2932

3033
if __name__ == "__main__":

scripts/utest.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
""" run python unit tests with pytest
22
"""
3+
import platform
34
import sys
45

56
import pytest
67

8+
OS = platform.system()
9+
PY = "".join(map(str, sys.version_info[:2]))
10+
11+
OS_PY_ARGS = {
12+
# notebook and ipykernel releases do not yet support python 3.8 on windows
13+
("Windows", "38"): ["-k", "not serverextension"]
14+
}
15+
16+
DEFAULT_ARGS = ["--cov-fail-under=100"]
17+
718

819
def run_tests():
920
""" actually run the tests
@@ -18,8 +29,8 @@ def run_tests():
1829
"-p",
1930
"no:warnings",
2031
"--flake8",
21-
"--cov-fail-under=100",
2232
"-vv",
33+
*OS_PY_ARGS.get((OS, PY), DEFAULT_ARGS),
2334
] + list(sys.argv[1:])
2435

2536
return pytest.main(args)

0 commit comments

Comments
 (0)