1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
use std::io::Write;
use std::process::Command;
use tempfile::NamedTempFile;
#[test]
fn test_list_tests() {
// Run cargo-subunit --list on this project itself
let output = Command::new("cargo")
.args(&["run", "--", "--list"])
.current_dir(env!("CARGO_MANIFEST_DIR"))
.output()
.expect("Failed to run cargo-subunit --list");
assert!(output.status.success(), "cargo-subunit --list failed");
let stdout = output.stdout;
// Should output subunit v2 format
assert!(!stdout.is_empty(), "Expected subunit output");
assert_eq!(stdout[0], 0xb3, "Expected subunit v2 signature byte");
}
#[test]
fn test_run_tests_with_subunit_output() {
// Run cargo-subunit on this project itself
let output = Command::new("cargo")
.args(&["run", "--"])
.current_dir(env!("CARGO_MANIFEST_DIR"))
.output()
.expect("Failed to run cargo-subunit");
// The command might fail if tests fail, but we should get some output
let stdout = output.stdout;
// Subunit v2 packets start with signature 0xb3
assert!(!stdout.is_empty(), "Expected subunit output");
assert_eq!(stdout[0], 0xb3, "Expected subunit v2 signature byte");
}
#[test]
fn test_load_list_functionality() {
// Create a temporary file with a test name
let mut temp_file = NamedTempFile::new().expect("Failed to create temp file");
writeln!(temp_file, "json_parser::tests::test_parse_suite_started")
.expect("Failed to write to temp file");
let temp_path = temp_file.path().to_str().unwrap();
// Run cargo-subunit with --load-list
let output = Command::new("cargo")
.args(&["run", "--", "--load-list", temp_path])
.current_dir(env!("CARGO_MANIFEST_DIR"))
.output()
.expect("Failed to run cargo-subunit --load-list");
// Should succeed
assert!(output.status.success(), "cargo-subunit --load-list failed");
let stdout = output.stdout;
// Should have subunit output
assert!(!stdout.is_empty(), "Expected subunit output");
assert_eq!(stdout[0], 0xb3, "Expected subunit v2 signature byte");
}
|