-
Notifications
You must be signed in to change notification settings - Fork 4
MoonLive scripts are modules: one picker, one language, one editor #90
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2060c85
Highlight MoonLive scripts, and declare every loop counter
ewowi d10051b
Add scripts to the module picker, and fix what that exposed
ewowi 9edc476
Include <string> where the apply test uses it
ewowi fdfbe22
Run the tests when the code they compile changes
ewowi cae200c
Mark the failing line once the editor has the text to mark
ewowi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,77 @@ | ||
| #!/usr/bin/env python3 | ||
| """Run the host test suites: the Python ones, the JS ones, or both. | ||
|
|
||
| These are the tests that live outside the C++ binary, and they cover what it cannot reach: the | ||
| cross-language contracts (the Improv frame's wire format, WLED's /json shape), the MoonDeck scripts | ||
| themselves, the browser code in src/ui, and the claim that every shipped MoonLive script is valid | ||
| C++. The commit gate and CI both run them; this is the same command with a card in front of it. | ||
|
|
||
| uv run moondeck/test/test_host.py # both suites | ||
| uv run moondeck/test/test_host.py --python # just Python | ||
| uv run moondeck/test/test_host.py --js # just JS | ||
|
|
||
| The Python deps ride in a PEP-723 block per test file, so they are named here rather than | ||
| installed: `uv run --with` resolves them per run and leaves no environment behind. | ||
| """ | ||
|
|
||
| import argparse | ||
| import shutil | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[2] | ||
|
|
||
| # Named here rather than in a requirements file: each is a test's own dependency (pyserial for the | ||
| # flash tests, wled for the /json shim, markdown for the docs checks), and `uv run --with` is how | ||
| # every other script in MoonDeck reaches one. | ||
| PY_DEPS = ("pytest", "pyserial", "markdown", "wled") | ||
|
|
||
|
|
||
| def run(cmd, label): | ||
| print(f"\n=== {label} ===", flush=True) | ||
| r = subprocess.run(cmd, cwd=ROOT, check=False) # the caller collects the code; a raise would skip the other suite | ||
| return r.returncode | ||
|
|
||
|
|
||
| def main() -> int: | ||
| ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) | ||
| # Mutually exclusive: each flag means "ONLY this suite", so passing both asks for two | ||
| # contradictory things. Neither flag still means both suites, which is the common case. | ||
| only = ap.add_mutually_exclusive_group() | ||
| only.add_argument("--python", action="store_true", help="run only the Python suite") | ||
| only.add_argument("--js", action="store_true", help="run only the JS suite") | ||
| args = ap.parse_args() | ||
| both = not (args.python or args.js) | ||
|
|
||
| rc = 0 | ||
| if both or args.python: | ||
| cmd = ["uv", "run"] | ||
| for d in PY_DEPS: | ||
| cmd += ["--with", d] | ||
| cmd += ["pytest", "test/python", "-q"] | ||
| rc |= run(cmd, "Python (test/python)") | ||
|
|
||
| if both or args.js: | ||
| # node, not uv: the JS suite is the browser code's own runner. Reported rather than failed | ||
| # when node is absent, because a Python-only bench is a normal setup and a missing runtime | ||
| # is "this does not apply here", which is what SKIP means. | ||
| if shutil.which("node") is None: | ||
| print("\n=== JS (test/js) ===\nSKIP: node is not on PATH", flush=True) | ||
| else: | ||
| # Expanded HERE, not by node and not by a shell. The call passes a list with no | ||
| # shell=True, so a literal `test/js/**/*.test.mjs` would reach node and depend on its | ||
| # own glob support, which older runtimes lack. Resolving the paths in Python makes the | ||
| # command work on any node, and names the files it ran. | ||
| tests = sorted(str(f.relative_to(ROOT)) for f in (ROOT / "test/js").rglob("*.test.mjs")) | ||
| if not tests: | ||
| print("\n=== JS (test/js) ===\nSKIP: no test files found", flush=True) | ||
| else: | ||
| rc |= run(["node", "--test", *tests], "JS (test/js)") | ||
|
|
||
| print("\nDONE" if rc == 0 else "\nFAILED", flush=True) | ||
| return rc | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.