Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 29 additions & 0 deletions tests/examples.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading