libyaml-safer/tests/test_emitter.rs

38 lines
929 B
Rust
Raw Normal View History

2022-07-08 06:58:14 +00:00
#![allow(clippy::type_complexity)]
2022-07-08 01:28:43 +00:00
mod bin;
#[path = "../src/bin/run-emitter-test-suite.rs"]
#[allow(dead_code)]
mod run_emitter_test_suite;
2022-07-03 19:05:16 +00:00
use std::fs;
use std::path::Path;
fn test(id: &str) {
let dir = Path::new("tests")
.join("data")
.join("yaml-test-suite")
.join(id);
2022-07-08 01:28:43 +00:00
let output = bin::run(
env!("CARGO_BIN_EXE_run-emitter-test-suite"),
run_emitter_test_suite::unsafe_main,
&dir.join("test.event"),
);
2022-07-03 19:05:16 +00:00
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
eprint!("{}", stderr);
let out = if dir.join("out.yaml").exists() {
dir.join("out.yaml")
} else {
dir.join("in.yaml")
};
let expected = fs::read_to_string(out).unwrap();
pretty_assertions::assert_str_eq!(expected, stdout);
2022-07-08 01:28:43 +00:00
assert!(output.success);
2022-07-03 19:05:16 +00:00
}
unsafe_libyaml_test_suite::test_emitter!();