From 9a8a436a20b5a168720372a9c4746962d0679241 Mon Sep 17 00:00:00 2001 From: Ryu <114303361+ryuapp@users.noreply.github.com> Date: Wed, 11 Mar 2026 01:43:35 +0900 Subject: [PATCH 1/2] feat: add example integration tests --- src/commands/build.rs | 1 + tests/examples.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/examples.rs diff --git a/src/commands/build.rs b/src/commands/build.rs index 4b6a6cf..43fd53d 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -4,6 +4,7 @@ use std::process::Command; pub fn run(input_path: &str, ast: &crate::parser::Program, opt_level: Option<&str>) { let (stem, zig_path) = emit_zig(input_path, ast); + std::fs::create_dir_all("zyre-out").unwrap(); let exe_path = if cfg!(windows) { format!("zyre-out/{}.exe", stem) } else { diff --git a/tests/examples.rs b/tests/examples.rs new file mode 100644 index 0000000..dbfe5b9 --- /dev/null +++ b/tests/examples.rs @@ -0,0 +1,29 @@ +use std::process::Command; + +fn run_example(path: &std::path::Path) { + let bin = env!("CARGO_BIN_EXE_zyre"); + let out = Command::new(bin) + .args(["run", &path.to_string_lossy()]) + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) + .output() + .unwrap_or_else(|e| panic!("failed to spawn zyre for {}: {}", path.display(), e)); + assert!( + out.status.success(), + "{} exited with non-zero status", + path.display() + ); +} + +#[test] +fn test_examples() { + let examples = std::fs::read_dir("examples") + .expect("examples/ directory not found") + .filter_map(|e| e.ok()) + .filter(|e| e.path().extension().map(|x| x == "zy").unwrap_or(false)) + .map(|e| e.path()); + + for path in examples { + run_example(&path); + } +} From 1bfdafad55a237630565940a98c0436bee4fdf23 Mon Sep 17 00:00:00 2001 From: Ryu <114303361+ryuapp@users.noreply.github.com> Date: Thu, 12 Mar 2026 00:56:01 +0900 Subject: [PATCH 2/2] tweak --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bc6fa1..bad92ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,9 @@ jobs: - uses: actions/checkout@v6 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 + - uses: mlugg/setup-zig@v2 + with: + version: "0.15.2" - run: cargo fmt --check - run: cargo build - run: cargo test