Skip to content

Commit 4c6c763

Browse files
bollwyvljtpio
andauthored
Clean up log messages, flaky tests on Windows (#1183)
* clean up logs, linting * also skip rebuild timing checks on windows * Align `logFilters` comment with upstream --------- Co-authored-by: Jeremy Tuloup <[email protected]>
1 parent fc839a9 commit 4c6c763

File tree

11 files changed

+59
-50
lines changed

11 files changed

+59
-50
lines changed

Diff for: .binder/environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ dependencies:
8181
- pytest-check-links
8282
# test
8383
- ansi2html
84-
- pytest-console-scripts
84+
- pytest-console-scripts >=1.4.0
8585
- pytest-cov
8686
- pytest-html
8787
- pytest-xdist

Diff for: .yarnrc.yml

+15
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,18 @@ enableTelemetry: false
44
httpTimeout: 60000
55
nodeLinker: node-modules
66
npmRegistryServer: 'https://registry.yarnpkg.com'
7+
8+
# these messages provide no actionable information, and make non-TTY output
9+
# almost unreadable, masking real dependency-related information
10+
# see: https://yarnpkg.com/advanced/error-codes
11+
logFilters:
12+
- code: YN0006 # SOFT_LINK_BUILD
13+
level: discard
14+
- code: YN0007 # MUST_BUILD
15+
level: discard
16+
- code: YN0008 # MUST_REBUILD
17+
level: discard
18+
- code: YN0013 # FETCH_NOT_CACHED
19+
level: discard
20+
- code: YN0019 # UNUSED_CACHE_ENTRY
21+
level: discard

Diff for: docs/environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies:
3838
- pytest-check-links
3939
# test
4040
- ansi2html
41-
- pytest-console-scripts
41+
- pytest-console-scripts >=1.4.0
4242
- pytest-cov
4343
- pytest-html
4444
- pytest-xdist

Diff for: docs/reference/cli.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -944,4 +944,4 @@
944944
},
945945
"nbformat": 4,
946946
"nbformat_minor": 5
947-
}
947+
}

Diff for: examples/pyodide/plotly.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,4 @@
151151
},
152152
"nbformat": 4,
153153
"nbformat_minor": 4
154-
}
154+
}

Diff for: py/jupyterlite-core/jupyterlite_core/tests/test_archive.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_archive_is_reproducible(an_empty_lite_dir, script_runner, source_date_e
4444
# build once for initial tarball
4545
before = an_empty_lite_dir / "v1.tgz"
4646
initial = script_runner.run(
47-
*archive_args, "--output-archive", str(before), "--no-libarchive", **cwd
47+
[*archive_args, "--output-archive", str(before), "--no-libarchive"], **cwd
4848
)
4949
assert initial.success, "failed to build the first tarball"
5050

@@ -53,7 +53,7 @@ def test_archive_is_reproducible(an_empty_lite_dir, script_runner, source_date_e
5353

5454
# build another tarball
5555
after = an_empty_lite_dir / "v2.tgz"
56-
subsequent = script_runner.run(*archive_args, "--output-archive", str(after), **cwd)
56+
subsequent = script_runner.run([*archive_args, "--output-archive", str(after)], **cwd)
5757
assert subsequent.success, "failed to build the second tarball"
5858

5959
# check them
@@ -67,17 +67,13 @@ def test_archive_is_idempotent(an_empty_lite_dir, script_runner, source_date_epo
6767

6868
# build once for initial tarball
6969
before = an_empty_lite_dir / "v1.tgz"
70-
initial = script_runner.run(*archive_args, "--output-archive", str(before), **cwd)
70+
initial = script_runner.run([*archive_args, "--output-archive", str(before)], **cwd)
7171
assert initial.success, "failed to build the first tarball"
7272

7373
# build another tarball
7474
after = an_empty_lite_dir / "v2.tgz"
7575
subsequent = script_runner.run(
76-
*archive_args,
77-
"--app-archive",
78-
str(before),
79-
"--output-archive",
80-
str(after),
76+
[*archive_args, "--app-archive", str(before), "--output-archive", str(after)],
8177
**cwd,
8278
)
8379
assert subsequent.success, "failed to build the second tarball"
@@ -118,7 +114,7 @@ def _assert_same_tarball(message, script_runner, before, after): # pragma: no c
118114
tdp = Path(td)
119115
print(tdp)
120116

121-
diffoscope_result = script_runner.run(diffoscope, str(before), str(after))
117+
diffoscope_result = script_runner.run([diffoscope, str(before), str(after)])
122118

123119
if not diffoscope_result.success:
124120
fails += [diffoscope_result.stdout, diffoscope_result.stderr]

Diff for: py/jupyterlite-core/jupyterlite_core/tests/test_cli.py

+27-21
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
PY_IMPL = platform.python_implementation()
1111
IS_PYPY = "pypy" in PY_IMPL.lower()
12+
IS_WIN = platform.system() == "Windows"
1213

1314

1415
# TODO: others?
@@ -60,7 +61,7 @@
6061
@mark.parametrize("lite_args", LITE_INVOCATIONS)
6162
def test_cli_version(lite_args, script_runner):
6263
"""do various invocations work"""
63-
returned_version = script_runner.run(*lite_args, "--version")
64+
returned_version = script_runner.run([*lite_args, "--version"])
6465
assert returned_version.success
6566
assert __version__ in returned_version.stdout
6667
assert returned_version.stderr == ""
@@ -70,21 +71,21 @@ def test_cli_version(lite_args, script_runner):
7071
@mark.parametrize("help", ["-h", "--help"])
7172
def test_cli_help(lite_args, help, script_runner): # noqa: A002
7273
"""does help work"""
73-
returned_version = script_runner.run(*lite_args, help)
74+
returned_version = script_runner.run([*lite_args, help])
7475
assert returned_version.success
7576
assert returned_version.stderr == ""
7677

7778

7879
@mark.parametrize("lite_args", LITE_INVOCATIONS)
7980
def test_nonzero_rc(lite_args, script_runner):
80-
a_step = script_runner.run(*lite_args, "doit", "this-is-not-a-step")
81+
a_step = script_runner.run([*lite_args, "doit", "this-is-not-a-step"])
8182
assert not a_step.success
8283

8384

8485
@mark.parametrize("lite_hook", ["list", "status"])
8586
def test_cli_status_null(lite_hook, an_empty_lite_dir, script_runner):
8687
"""do the "side-effect-free" commands create exactly one file?"""
87-
returned_status = script_runner.run("jupyter", "lite", lite_hook, cwd=str(an_empty_lite_dir))
88+
returned_status = script_runner.run(["jupyter", "lite", lite_hook], cwd=str(an_empty_lite_dir))
8889
assert returned_status.success
8990
files = set(an_empty_lite_dir.rglob("*"))
9091
# we would expect to see our build cruft sqlite
@@ -103,7 +104,7 @@ def test_cli_any_hook( # noqa: PLR0915
103104
"""
104105
expected_files = TRASH if lite_hook in FAST_HOOKS else A_GOOD_BUILD
105106
started = time.time()
106-
returned_status = script_runner.run("jupyter", "lite", lite_hook, cwd=str(an_empty_lite_dir))
107+
returned_status = script_runner.run(["jupyter", "lite", lite_hook], cwd=str(an_empty_lite_dir))
107108
duration_1 = time.time() - started
108109
assert returned_status.success
109110
files = set(an_empty_lite_dir.rglob("*"))
@@ -116,11 +117,14 @@ def test_cli_any_hook( # noqa: PLR0915
116117

117118
# re-run, be faster
118119
restarted = time.time()
119-
rereturned_status = script_runner.run("jupyter", "lite", lite_hook, cwd=str(an_empty_lite_dir))
120+
rereturned_status = script_runner.run(
121+
["jupyter", "lite", lite_hook],
122+
cwd=str(an_empty_lite_dir),
123+
)
120124
duration_2 = time.time() - restarted
121125
assert rereturned_status.success
122126

123-
if not IS_PYPY:
127+
if not (IS_PYPY or IS_WIN):
124128
# some caching doesn't seep to work reliably
125129
assert duration_1 > duration_2
126130

@@ -148,14 +152,16 @@ def test_cli_any_hook( # noqa: PLR0915
148152
app_overrides.write_text(AN_OVERRIDES, encoding="utf-8")
149153

150154
forced_status = script_runner.run(
151-
"jupyter",
152-
"lite",
153-
lite_hook,
154-
"--force",
155-
"--contents",
156-
str(readme),
157-
"--contents",
158-
str(more),
155+
[
156+
"jupyter",
157+
"lite",
158+
lite_hook,
159+
"--force",
160+
"--contents",
161+
str(readme),
162+
"--contents",
163+
str(more),
164+
],
159165
cwd=str(an_empty_lite_dir),
160166
)
161167

@@ -194,7 +200,7 @@ def test_cli_any_hook( # noqa: PLR0915
194200
def test_cli_raw_doit(an_empty_lite_dir, script_runner):
195201
"""does raw doit work"""
196202
returned_status = script_runner.run(
197-
"jupyter", "lite", "doit", "--", "--help", cwd=str(an_empty_lite_dir)
203+
["jupyter", "lite", "doit", "--", "--help"], cwd=str(an_empty_lite_dir)
198204
)
199205
assert returned_status.success
200206
assert "http://pydoit.org" in returned_status.stdout
@@ -205,13 +211,13 @@ def test_build_repl_no_sourcemaps(an_empty_lite_dir, script_runner):
205211
out = an_empty_lite_dir / "_output"
206212

207213
args = original_args = "jupyter", "lite", "build"
208-
status = script_runner.run(*args, cwd=str(an_empty_lite_dir))
214+
status = script_runner.run(args, cwd=str(an_empty_lite_dir))
209215
norm_files = sorted(out.rglob("*"))
210216
assert status.success
211217
assert [f for f in norm_files if f.name.endswith(".map")], "expected maps"
212218

213219
args = [*args, "--apps", "repl", "--apps", "foobarbaz"]
214-
status = script_runner.run(*args, cwd=str(an_empty_lite_dir))
220+
status = script_runner.run(args, cwd=str(an_empty_lite_dir))
215221
repl_files = sorted(out.rglob("*"))
216222
repl_bundles = sorted(out.glob("build/*/bundle.js"))
217223
assert status.success
@@ -221,7 +227,7 @@ def test_build_repl_no_sourcemaps(an_empty_lite_dir, script_runner):
221227
assert "'foobarbaz' is not one of" in status.stderr
222228

223229
args = [*args, "--no-unused-shared-packages"]
224-
status = script_runner.run(*args, cwd=str(an_empty_lite_dir))
230+
status = script_runner.run(args, cwd=str(an_empty_lite_dir))
225231
no_chunk_files = sorted(out.rglob("*"))
226232
# assert "pruning unused shared package" in status.stderr
227233

@@ -230,15 +236,15 @@ def test_build_repl_no_sourcemaps(an_empty_lite_dir, script_runner):
230236
assert len(no_chunk_files) < len(repl_files), f"unexpected {unexpected}"
231237

232238
args = [*args, "--no-sourcemaps"]
233-
status = script_runner.run(*args, cwd=str(an_empty_lite_dir))
239+
status = script_runner.run(args, cwd=str(an_empty_lite_dir))
234240
min_files = sorted(out.rglob("*"))
235241
assert status.success
236242

237243
assert not [f for f in min_files if f.name.endswith(".map")], "expected no maps"
238244

239245
assert len(min_files) < len(no_chunk_files), "expected fewer files still"
240246

241-
status = script_runner.run(*original_args, cwd=str(an_empty_lite_dir))
247+
status = script_runner.run(original_args, cwd=str(an_empty_lite_dir))
242248
rebuild_files = sorted(out.rglob("*"))
243249
assert status.success
244250

Diff for: py/jupyterlite-core/jupyterlite_core/tests/test_contents.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ def test_contents_with_dot( # noqa: PLR0913
3636
postbuild.write_text("#!/usr/bin/env bash\necho ok")
3737

3838
result = script_runner.run(
39-
"jupyter",
40-
"lite",
41-
"build",
42-
"--contents",
43-
".",
39+
["jupyter", "lite", "build", "--contents", "."],
4440
cwd=str(an_empty_lite_dir),
4541
)
4642
if expect_success:
@@ -80,11 +76,7 @@ def test_contents_with_space(
8076
contents_file.touch()
8177

8278
result = script_runner.run(
83-
"jupyter",
84-
"lite",
85-
"build",
86-
"--contents",
87-
"contents",
79+
["jupyter", "lite", "build", "--contents", "contents"],
8880
cwd=str(an_empty_lite_dir),
8981
)
9082
assert result.success

Diff for: py/jupyterlite-core/jupyterlite_core/tests/test_federated.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ def test_federated_extensions( # noqa: PLR0913
4444

4545
extra_args = [] if use_libarchive else ["--no-libarchive"]
4646

47-
build = script_runner.run("jupyter", "lite", "build", *extra_args, cwd=str(an_empty_lite_dir))
47+
build = script_runner.run(["jupyter", "lite", "build", *extra_args], cwd=str(an_empty_lite_dir))
4848

4949
if ext_name.endswith(".conda") and not use_libarchive:
5050
assert not build.success
5151
return
5252

5353
assert build.success
5454

55-
check = script_runner.run("jupyter", "lite", "check", *extra_args, cwd=str(an_empty_lite_dir))
55+
check = script_runner.run(["jupyter", "lite", "check", *extra_args], cwd=str(an_empty_lite_dir))
5656
assert check.success
5757

5858
output = an_empty_lite_dir / "_output"

Diff for: py/jupyterlite-core/jupyterlite_core/tests/test_mathjax.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ def test_mathjax(
3131
extra_args = extra_args or []
3232
kwargs = dict(cwd=str(an_empty_lite_dir))
3333

34-
status = script_runner.run("jupyter", "lite", "status", *extra_args, **kwargs)
34+
status = script_runner.run(["jupyter", "lite", "status", *extra_args], **kwargs)
3535
assert status.success, "the status did NOT succeed"
3636

37-
build = script_runner.run("jupyter", "lite", "build", *extra_args, **kwargs)
37+
build = script_runner.run(["jupyter", "lite", "build", *extra_args], **kwargs)
3838
assert build.success, "the build did NOT succeed"
3939

4040
mathjax_path = an_empty_lite_dir / "_output/static/jupyter_server_mathjax/MathJax.js"
@@ -44,5 +44,5 @@ def test_mathjax(
4444
else:
4545
assert not mathjax_path.exists(), f"{mathjax_path} was NOT expected"
4646

47-
check = script_runner.run("jupyter", "lite", "check", *extra_args, **kwargs)
47+
check = script_runner.run(["jupyter", "lite", "check", *extra_args], **kwargs)
4848
assert check.success, "the build did NOT check out"

Diff for: requirements-test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
ansi2html
66
diffoscope; sys_platform == 'linux'
77
libarchive-c; sys_platform == 'linux'
8-
pytest-console-scripts
8+
pytest-console-scripts >=1.4.0
99
pytest-cov
1010
pytest-html
1111
pytest-xdist

0 commit comments

Comments
 (0)