|
| 1 | +// SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +// |
| 3 | +// Phase D: clap aliases for the `compile` subcommand. Closes #36. |
| 4 | +// Asserts that invoking the CLI as `compile-eph` and `compile-affine` |
| 5 | +// both route to the same `Compile` subcommand. Probed by hypatia's |
| 6 | +// `build-gossamer-gui.yml` workflow (see #36 for the probe order). |
| 7 | + |
| 8 | +use std::process::Command; |
| 9 | + |
| 10 | +fn ephapax_bin() -> String { |
| 11 | + // CARGO_BIN_EXE_ephapax is set by cargo for integration tests. |
| 12 | + env!("CARGO_BIN_EXE_ephapax").to_string() |
| 13 | +} |
| 14 | + |
| 15 | +fn fixture(name: &str) -> String { |
| 16 | + format!( |
| 17 | + "{}/../../tests/v2-grammar/fixtures/{}", |
| 18 | + env!("CARGO_MANIFEST_DIR"), |
| 19 | + name |
| 20 | + ) |
| 21 | +} |
| 22 | + |
| 23 | +#[test] |
| 24 | +fn compile_eph_alias_routes_to_compile() { |
| 25 | + let out = tempfile::NamedTempFile::new().expect("temp file"); |
| 26 | + let status = Command::new(ephapax_bin()) |
| 27 | + .arg("compile-eph") |
| 28 | + .arg(fixture("extern-callsite.eph")) |
| 29 | + .arg("-o") |
| 30 | + .arg(out.path()) |
| 31 | + .output() |
| 32 | + .expect("ephapax compile-eph must run"); |
| 33 | + assert!( |
| 34 | + status.status.success(), |
| 35 | + "compile-eph alias failed: stdout={} stderr={}", |
| 36 | + String::from_utf8_lossy(&status.stdout), |
| 37 | + String::from_utf8_lossy(&status.stderr) |
| 38 | + ); |
| 39 | + let bytes = std::fs::read(out.path()).expect("output wasm exists"); |
| 40 | + assert!(bytes.starts_with(b"\0asm"), "wasm magic bytes present"); |
| 41 | +} |
| 42 | + |
| 43 | +#[test] |
| 44 | +fn compile_affine_alias_routes_to_compile() { |
| 45 | + let out = tempfile::NamedTempFile::new().expect("temp file"); |
| 46 | + let status = Command::new(ephapax_bin()) |
| 47 | + .arg("compile-affine") |
| 48 | + .arg(fixture("extern-callsite.eph")) |
| 49 | + .arg("-o") |
| 50 | + .arg(out.path()) |
| 51 | + .output() |
| 52 | + .expect("ephapax compile-affine must run"); |
| 53 | + assert!( |
| 54 | + status.status.success(), |
| 55 | + "compile-affine alias failed: stdout={} stderr={}", |
| 56 | + String::from_utf8_lossy(&status.stdout), |
| 57 | + String::from_utf8_lossy(&status.stderr) |
| 58 | + ); |
| 59 | + let bytes = std::fs::read(out.path()).expect("output wasm exists"); |
| 60 | + assert!(bytes.starts_with(b"\0asm"), "wasm magic bytes present"); |
| 61 | +} |
0 commit comments