8000 Enable worker tests by antocuni · Pull Request #1757 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

Enable worker tests #1757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/main' into antocuni/worker-tests
  • Loading branch information
antocuni committed Sep 26, 2023
commit 71849847cd45b2d913ed183122ae75257895c153
29 changes: 2 additions & 27 deletions pyscript.core/src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,40 +71,15 @@ const registerModule = ({ XWorker: $XWorker, interpreter, io }) => {
interpreter.runPython(stdlib, { globals: interpreter.runPython("{}") });
};

export const hooks = {
/** @type {Set<function>} */
onBeforeRun: new Set(),
/** @type {Set<function>} */
onBeforeRunAsync: new Set(),
/** @type {Set<function>} */
onAfterRun: new Set(),
/** @type {Set<function>} */
onAfterRunAsync: new Set(),
/** @type {Set<function>} */
onInterpreterReady: new Set(),

/** @type {Set<string>} */
codeBeforeRunWorker: new Set(),
/** @type {Set<string>} */
codeBeforeRunWorkerAsync: new Set(),
/** @type {Set<string>} */
codeAfterRunWorker: new Set(),
/** @type {Set<string>} */
codeAfterRunWorkerAsync: new Set(),
};

// XXX (antocuni): this is a hack, we need to find a better way to do this
const afterRunWorker = "import js; js.console.debug('---pyscript: done---')"

const workerHooks = {
codeBeforeRunWorker: () =>
[stdlib, ...hooks.codeBeforeRunWorker].map(dedent).join("\n"),
codeBeforeRunWorkerAsync: () =>
[stdlib, ...hooks.codeBeforeRunWorkerAsync].map(dedent).join("\n"),
codeAfterRunWorker: () =>
[...hooks.codeAfterRunWorker, afterRunWorker].map(dedent).join("\n"),
[...hooks.codeAfterRunWorker].map(dedent).join("\n"),
codeAfterRunWorkerAsync: () =>
[...hooks.codeAfterRunWorkerAsync, afterRunWorker].map(dedent).join("\n"),
[...hooks.codeAfterRunWorkerAsync].map(dedent).join("\n"),
};

const exportedConfig = {};
Expand Down
3 changes: 2 additions & 1 deletion pyscript.core/tests/integration/test_01_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ def test_escaping_of_angle_brackets(self):

"""
)
# in workers the order of execution is not guaranteed, better to play safe
# in workers the order of execution is not guaranteed, better to play
# safe
lines = sorted(self.console.log.lines[-4:])
assert lines == [
"A true false",
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0