Skip to content

Commit 1749039

Browse files
committed
fix zip download
1 parent fe035bc commit 1749039

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

wasm-preview/run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async def main(tests_zip: str):
2626
count = 0
2727
for name in zip_file.namelist():
2828
if name.endswith('.py'):
29-
path, subs = re.subn(r'^pydantic-core-main/tests/', 'tests/', name)
29+
path, subs = re.subn(r'^pydantic-core-.+?/tests/', 'tests/', name)
3030
if subs:
3131
count += 1
3232
path = Path(path)

wasm-preview/worker.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,24 @@ async function get(url, mode) {
7474

7575
self.onmessage = async () => {
7676
self.postMessage('Downloading repo archive to get tests...\n')
77-
const [python_code, tests_zip,] = await Promise.all([
78-
get(`./run_tests.py?v=${Date.now()}`, 'text'),
79-
// 95c4f56 commit matches the pydantic-core wheel being used, so tests should pass
80-
get('https://githubproxy.samuelcolvin.workers.dev/samuelcolvin/pydantic-core/archive/refs/95c4f56/main.zip', 'blob'),
81-
importScripts('https://cdn.jsdelivr.net/pyodide/v0.21.0a3/full/pyodide.js')
82-
])
83-
84-
const pyodide = await loadPyodide()
85-
const {FS} = pyodide
86-
setupStreams(FS, pyodide._module.TTY)
87-
FS.mkdir('/test_dir')
88-
FS.chdir('/test_dir')
89-
await pyodide.loadPackage(['micropip', 'pytest', 'pytz'])
9077
try {
78+
const [python_code, tests_zip,] = await Promise.all([
79+
get(`./run_tests.py?v=${Date.now()}`, 'text'),
80+
// e4cf2e2 commit matches the pydantic-core wheel being used, so tests should pass
81+
get('https://githubproxy.samuelcolvin.workers.dev/samuelcolvin/pydantic-core/archive/e4cf2e2.zip', 'blob'),
82+
importScripts('https://cdn.jsdelivr.net/pyodide/v0.21.0a3/full/pyodide.js')
83+
])
84+
85+
const pyodide = await loadPyodide()
86+
const {FS} = pyodide
87+
setupStreams(FS, pyodide._module.TTY)
88+
FS.mkdir('/test_dir')
89+
FS.chdir('/test_dir')
90+
await pyodide.loadPackage(['micropip', 'pytest', 'pytz'])
9191
await pyodide.runPythonAsync(python_code, {globals: pyodide.toPy({tests_zip})})
92+
post()
9293
} catch (err) {
9394
console.error(err)
94-
const raw_error = Array.from(new TextEncoder().encode(err.toString()))
95-
self.postMessage(raw_error)
95+
self.postMessage(`Error: ${err}\n`)
9696
}
97-
post()
9897
}

0 commit comments

Comments
 (0)