Skip to content

Commit 468c5e0

Browse files
author
Ben Creech
committed
Deflake test and fix Alpine compat note
1 parent 3423b5b commit 468c5e0

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

.github/workflows/pypi-build.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ jobs:
5454
# build distro):
5555
- image: debian:bullseye
5656
- image: arm64v8/debian:bullseye
57-
# And for Alpine we mostly measure compatibility in musl minor versions, and
58-
# the oldest supported Alpine as of this writing (3.16) has the same minor
59-
# version as 3.19, so use 3.19. (This helps bring a newer system clang, which
60-
# works better with the V8 build.)
57+
# Alpine 3.19 includes a clang new enough for V8 to build (with only minor
58+
# patches!). Builds on 3.19 seem incompatible with <= 3.18 due to libstdc++
59+
# symbols. (And we can't just run on an old Alpine and update clang from the
60+
# llvm site, because unlike Debian, the llvm project doesn't maintain
61+
# updated packages for old Alpine distros.)
6162
- image: alpine:3.19
6263
- image: arm64v8/alpine:3.19
6364

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ PyMiniRacer is distributed using [wheels](https://pythonwheels.com/) on
114114
| Debian ≥ 11 |||
115115
| RHEL ≥ 8 |||
116116
| other Linuxes with glibc ≥ 2.31 |||
117-
| Alpine ≥ 3.16 |||
117+
| Alpine ≥ 3.19 |||
118118
| other Linux with musl ≥ 1.2 |||
119119

120120
If you have a up-to-date pip and it doesn't use a wheel, you might have an environment

tests/test_eval.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,17 @@ def test_null_byte():
8282

8383

8484
def test_timeout():
85-
timeout_ms = 100
85+
timeout = 0.1
8686
start_time = time()
8787

8888
mr = MiniRacer()
8989
with pytest.raises(JSTimeoutException):
90-
mr.eval("while(1) { }", timeout=timeout_ms)
90+
mr.eval("while(1) { }", timeout=int(timeout * 1000))
9191

9292
duration = time() - start_time
93-
assert timeout_ms <= duration * 1000 <= timeout_ms + 200
93+
# Make sure it timed out on time, and allow a giant leeway (because aarch64
94+
# emulation tests are surprisingly slow!)
95+
assert timeout <= duration <= timeout + 5
9496

9597

9698
def test_max_memory_soft():
@@ -144,13 +146,17 @@ def test_async():
144146
const shared = new SharedArrayBuffer(8);
145147
const view = new Int32Array(shared);
146148
147-
const p = Atomics.waitAsync(view, 0, 0, 1); // 1 ms timeout
149+
const p = Atomics.waitAsync(view, 0, 0, 1000); // 1 s timeout
148150
p.value.then(() => { done = true; });
149151
done
150152
"""
151153
)
152-
sleep(0.1)
153154
assert not mr.eval("done")
155+
start = time()
156+
# Give the 1-second wait 10 seconds to finish. (Emulated aarch64 tests are
157+
# surprisingly slow!)
158+
while time() - start < 10 and not mr.eval("done"):
159+
sleep(0.1)
154160
assert mr.eval("done")
155161

156162

0 commit comments

Comments
 (0)