use std::process::Command;
fn run_example(example_name: &str) {
let result = Command::new("cargo")
.args(["run", "--example", example_name])
.output()
.unwrap_or_else(|_| panic!("Failed to run example: {}", example_name));
assert!(
result.status.success(),
"Example '{}' failed with exit code {:?}\n\nSTDOUT:\n{}\n\nSTDERR:\n{}",
example_name,
result.status.code(),
String::from_utf8_lossy(&result.stdout),
String::from_utf8_lossy(&result.stderr)
);
let stdout = String::from_utf8_lossy(&result.stdout);
let stderr = String::from_utf8_lossy(&result.stderr);
let combined_output = format!("{}{}", stdout, stderr);
assert!(
!combined_output.trim().is_empty(),
"Example '{}' produced no output",
example_name
);
}
#[test]
fn smoke_test_basic_nodes() {
if std::env::var("WEAVEGRAPH_SMOKE_TESTS").is_err() {
eprintln!(
"Skipping smoke test smoke_test_basic_nodes (set WEAVEGRAPH_SMOKE_TESTS=1 to enable)"
);
return;
}
run_example("basic_nodes");
}
#[test]
fn smoke_test_graph_execution() {
if std::env::var("WEAVEGRAPH_SMOKE_TESTS").is_err() {
eprintln!(
"Skipping smoke test smoke_test_graph_execution (set WEAVEGRAPH_SMOKE_TESTS=1 to enable)"
);
return;
}
run_example("graph_execution");
}
#[test]
fn smoke_test_scheduler_fanout() {
if std::env::var("WEAVEGRAPH_SMOKE_TESTS").is_err() {
eprintln!(
"Skipping smoke test smoke_test_scheduler_fanout (set WEAVEGRAPH_SMOKE_TESTS=1 to enable)"
);
return;
}
run_example("scheduler_fanout");
}
#[test]
fn smoke_test_errors_pretty() {
if std::env::var("WEAVEGRAPH_SMOKE_TESTS").is_err() {
eprintln!(
"Skipping smoke test smoke_test_errors_pretty (set WEAVEGRAPH_SMOKE_TESTS=1 to enable)"
);
return;
}
run_example("errors_pretty");
}