Skip to content
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

TST Make pyodide-test-runner installable #2742

Merged
merged 16 commits into from
Jul 4, 2022

Conversation

ryanking13
Copy link
Member

@ryanking13 ryanking13 commented Jun 20, 2022

Description

This makes pyodide-test-runner a regular installable Python package, instead of hacking with sys.path.

Related issue: #2741

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

.circleci/config.yml Outdated Show resolved Hide resolved
pyodide-test-runner/setup.cfg Show resolved Hide resolved
Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ! A few more questions otherwise looks good.

The one thing I don't understand is the reason for the changes in test_decorator.py

@@ -202,6 +206,8 @@ jobs:
name: stack-size
command: |
make npm-link
pip install ./pyodide-test-runner
npm install -g node-fetch@2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to install node-fetch? It should already be installed I think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node-fetch is installed locally during the installation of pyodide JS package, which means it cannot be accessed unless the js script file (node_test_driver.js) is located in the subdirectory of Pyodide source tree. In this PR we are installing pyodide-test-runner to e.g. site-packages, so node-fetch needs to be installed globally.

Maybe we can update the node version in our docker image in a subsequent PR that supports native fetch to remove those duplicated node-fetch installations.

@@ -80,7 +82,7 @@ def selenium_common(
f"Unknown runner or browser: {runner_type} / {request.param}"
)

dist_dir = request.config.getoption("--dist-dir")
dist_dir = Path(os.getcwd(), request.config.getoption("--dist-dir"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--dist-dir could also be an absolute path in which case this will not work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it works even if --dist-dir is an absolute path:

>>> Path("/abs1", "/abs2")
PosixPath('/abs2')

@@ -25,8 +24,6 @@ const context = {
TextDecoder: util.TextDecoder,
TextEncoder: util.TextEncoder,
URL,
atob: base64.decode,
btoa: base64.encode,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you comment why removing it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those functions were previously required in run_in_pyodide decorator, but was removed (#2510).

source : atob({encoded}.join("")),

@@ -1,83 +1,53 @@
import asyncio
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please comment why we need to refactor this file? Maybe Hood should review this.

Copy link
Member Author

@ryanking13 ryanking13 Jun 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored this to remove all import pyodide statements. I wanted to make pyodide-test-runner testable without accessing Pyodide source tree.

Most changes in test_decorator file are replacing the selenium mock class with a real selenium class which, I guess, does not harm test coverage.

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rth rth merged commit 7d7b7e8 into pyodide:main Jul 4, 2022
@ryanking13 ryanking13 deleted the test-runner-package branch July 5, 2022 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants