Skip to content
Merged
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
11 changes: 7 additions & 4 deletions air-script/tests/docs_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::{path::Path, process::Command};
#[test]
fn docs_sync() {
let examples_dir = Path::new("../docs/examples");
let airc_path = Path::new("target/release/airc");
// Use CARGO_MANIFEST_DIR to build an absolute path to airc, needed on Windows to correctly use
// `current_dir`.
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
let airc_path = Path::new(&manifest_dir).join("../target/release/airc");

// Build the CLI tool first
let build_output = Command::new("cargo")
Expand Down Expand Up @@ -38,11 +41,11 @@ fn docs_sync() {
let file_name = air_file.file_name().unwrap().to_string_lossy();
let output_path = air_file.with_extension("rs");

let output = Command::new(airc_path)
let output = Command::new(&airc_path)
.args(["transpile", air_file.to_str().unwrap(), "-o", output_path.to_str().unwrap()])
.current_dir("../")
.output()
.unwrap_or_else(|_| panic!("Failed to transpile {}", file_name));
.unwrap_or_else(|_| panic!("Failed to transpile {file_name}"));

assert!(
output.status.success(),
Expand All @@ -51,7 +54,7 @@ fn docs_sync() {
String::from_utf8_lossy(&output.stderr)
);

println!("Successfully transpiled: {}", file_name);
println!("Successfully transpiled: {file_name}");

// Clean up generated Rust files
let _ = std::fs::remove_file(output_path);
Expand Down