-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of trying to run the entire pytest testsuite in the pyodide runtime, in selenium we now only run the end-to-end tests "outside" of pyodide. By passing the ``lsp-runtime pyodide`` argument to pytest, rather than launching the server under test via CPython, the test suite will use NodeJS and a small wrapper script to execute the given server in the Pyodide runtime.
- Loading branch information
Showing
13 changed files
with
341 additions
and
467 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.log | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import pathlib | ||
import subprocess | ||
import sys | ||
from typing import Optional | ||
|
||
# Common paths | ||
REPO = pathlib.Path(__file__).parent.parent.parent | ||
PYODIDE_DIR = REPO / "tests" / "pyodide" | ||
PYODIDE_INDEX = PYODIDE_DIR / "node_modules" / "pyodide" | ||
|
||
|
||
def download_dependencies(): | ||
"""Download pygls' dependencies so that we have the wheels locally for pyodide to | ||
use.""" | ||
requirements = PYODIDE_DIR / "requirements.txt" | ||
|
||
run( | ||
"poetry", | ||
"export", | ||
"-f", | ||
"requirements.txt", | ||
"--output", | ||
str(requirements), | ||
cwd=str(REPO), | ||
) | ||
|
||
# Ensure that pip uses packages compatible with the pyodide runtime. | ||
run( | ||
"pip", | ||
"download", | ||
"--no-deps", | ||
"--python-version", | ||
"3.11", # The version of Python pyodide compiled to WASM | ||
"--implementation", | ||
"py", # Use only pure python packages. | ||
"-r", | ||
str(requirements), | ||
"--dest", | ||
str(PYODIDE_INDEX), | ||
cwd=str(REPO), | ||
) | ||
|
||
|
||
def run(*cmd, cwd: Optional[str] = None, capture: bool = False) -> Optional[str]: | ||
"""Run a command.""" | ||
|
||
result = subprocess.run(cmd, cwd=cwd, capture_output=capture) | ||
if result.returncode != 0: | ||
if capture: | ||
sys.stdout.buffer.write(result.stdout) | ||
sys.stdout.flush() | ||
sys.stderr.buffer.write(result.stderr) | ||
sys.stderr.flush() | ||
|
||
sys.exit(result.returncode) | ||
|
||
if capture: | ||
return result.stdout.decode("utf8").strip() | ||
|
||
return None | ||
|
||
|
||
def main(): | ||
"""Bootstrap the pyodide environment.""" | ||
|
||
# NOTE: Disabled for now as it's non-trivial to get mircopip to look in the local | ||
# folder in the general case - we'd need to implement PyPi's JSON API! | ||
# | ||
# download_dependencies() | ||
|
||
# Install pyodide | ||
run("npm", "ci", cwd=str(PYODIDE_DIR)) | ||
|
||
# Build pygls | ||
run("poetry", "build", cwd=str(REPO)) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "pyodide_tests", | ||
"version": "0.0.0", | ||
"description": "Simple wrapper that executes pygls servers in Pyodide", | ||
"main": "run_server.js", | ||
"author": "openlawlibrary", | ||
"dependencies": { | ||
"pyodide": "^0.24.1" | ||
} | ||
} |
Oops, something went wrong.