Skip to content

Commit bcd6e33

Browse files
fix(ci): Deploy pure-Python test pkg as test.py to std CDN.
1 parent 5523550 commit bcd6e33

5 files changed

Lines changed: 19 additions & 6 deletions

File tree

cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Flags: `--port <n>` (default `5173`), `--open` (open the browser).
9595

9696
## Edge Python Test
9797

98-
Not implemented yet.
98+
The `edge test` runner is not implemented yet. The `test` package itself (the harness you import) is available: `edge add test` writes it to `packages.json`, and `edge run` / `edge serve` resolve it by default, so a script can already `from test import fixture, test, raises, run` and call `run()` itself.
9999

100100
---
101101

@@ -120,7 +120,7 @@ $ edge init my-app
120120

121121
## Packages Manager
122122

123-
Manage `packages.json` by name. `edge` knows the official std (`json`, `re`, `math`) and host (`dom`, `network`, `storage`, `time`) packages, so you do not paste URLs.
123+
Manage `packages.json` by name. `edge` knows the official std (`json`, `re`, `math`, `test`) and host (`dom`, `network`, `storage`, `time`) packages, so you do not paste URLs. Most std packages are `.wasm`; `test` is pure Edge Python, so it resolves to `test.py`.
124124

125125
```text
126126
$ edge add math network

cli/src/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ fn vendor_packages(
161161
let Some((kind, url)) = pkg::resolve(name, manifest) else { continue };
162162
let bytes = fetch(&url).with_context(|| format!("fetching {url}"))?;
163163
let local = match kind {
164-
Kind::Std => format!("vendor/{name}.wasm"),
164+
// std packages are .wasm, except pure-Python ones (test) served as .py; preserve the real extension.
165+
Kind::Std => format!("vendor/{name}.{}", if url.ends_with(".py") { "py" } else { "wasm" }),
165166
Kind::Host => format!("vendor/{name}/index.js"),
166167
};
167168
write_under(out_dir, &local, &bytes)?;

cli/src/pkg.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,26 @@ pub enum Kind {
4141
Host,
4242
}
4343

44-
const STD: [&str; 3] = ["json", "re", "math"];
44+
const STD: [&str; 4] = ["json", "re", "math", "test"];
4545
const HOST: [&str; 4] = ["dom", "network", "storage", "time"];
4646

4747
/// Resolve a bare name against the official registry; user manifest overrides go through `resolve`.
4848
pub fn registry(name: &str) -> Option<(Kind, String)> {
4949
if STD.contains(&name) {
50-
Some((Kind::Std, format!("https://std.edgepython.com/{name}.wasm")))
50+
Some((Kind::Std, std_url(name)))
5151
} else if HOST.contains(&name) {
5252
Some((Kind::Host, format!("https://host.edgepython.com/{name}/index.js")))
5353
} else {
5454
None
5555
}
5656
}
5757

58+
/// CDN url for a std package. Most ship as `.wasm`; `test` is pure Edge Python, served as `.py`. Mirrors runtime/src/defaults.js.
59+
fn std_url(name: &str) -> String {
60+
let ext = if name == "test" { "py" } else { "wasm" };
61+
format!("https://std.edgepython.com/{name}.{ext}")
62+
}
63+
5864
/// Resolve `name` for the runtime: user manifest entry first, registry fallback.
5965
pub fn resolve(name: &str, manifest: &Manifest) -> Option<(Kind, String)> {
6066
if let Some(url) = manifest.imports.get(name) {

cli/tests/cli.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
"stdout": ["+ network", "host"],
3131
"contains": { "packages.json": "host.edgepython.com/network/index.js" }
3232
},
33+
{
34+
"given": { "packages.json": "{}\n" },
35+
"run": ["add", "test"],
36+
"stdout": ["+ test", "std"],
37+
"contains": { "packages.json": "std.edgepython.com/test.py" }
38+
},
3339
{
3440
"given": { "packages.json": "{}\n" },
3541
"run": ["add", "foo=https://example.com/foo.wasm"],

docs/reference/packages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ run() # prints PASS/FAIL lines and a summary, then raises SystemExit(0 if all pa
8888

8989
`@fixture` registers a `def` under its name and injects it by keyword into the tests that ask for it; `@test(description, *uses)` registers a test plus the fixtures it pulls; `raises(ExcType)` is a context manager asserting the block raises `ExcType` (a subclass, or any type in a tuple); `run()` executes every registered test, prints `PASS` / `FAIL` / `ERROR` and a summary, then raises `SystemExit(1 if any failed, else 0)` so a host can read the result as a process exit code.
9090

91-
Unlike the other standard packages, `test` ships as **pure Edge Python source** (`src/entry.py`), not a compiled `.wasm`, so there is no `cargo` build and nothing served from `std.edgepython.com`; the browser runtime resolves it by default and imports the `.py` directly (see [Defaults](#defaults)). Full API: [`std/test/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/test).
91+
Unlike the other standard packages, `test` ships as **pure Edge Python source** (`src/entry.py`), not a compiled `.wasm`, so there is no `cargo` build; it is served from `https://std.edgepython.com/test.py` and the browser runtime resolves it by default, importing the `.py` directly (see [Defaults](#defaults)). Full API: [`std/test/README.md`](https://github.com/dylan-sutton-chavez/edge-python/tree/main/std/test).
9292

9393
## Host libraries
9494

0 commit comments

Comments
 (0)