use assert_cmd::prelude::*; use predicates::prelude::*; use std::process::Command; #[test] fn file_doesnt_exist() -> Result<(), Box> { let mut cmd = Command::cargo_bin("tidyvcf")?; cmd.arg("-i").arg("test/file/doesnt/exist"); cmd.assert() .failure() .stderr(predicate::str::contains("No such file")); Ok(()) } #[test] fn spec_noncompliance_fails() -> Result<(), Box> { let mut cmd = Command::cargo_bin("tidyvcf")?; cmd.arg("-i").arg("resources/test_nonspec.vcf"); cmd.assert() .failure() .stderr(predicate::str::contains("Invalid")); Ok(()) } #[test] fn spec_noncompliance_allowed_lenient() -> Result<(), Box> { let mut cmd = Command::cargo_bin("tidyvcf")?; cmd.arg("-i").arg("resources/test_nonspec.vcf").arg("-l"); cmd.assert() .success() .stdout(predicate::str::contains("chr1")); Ok(()) } #[test] fn subsetting_columns_works() -> Result<(), Box> { let mut cmd = Command::cargo_bin("tidyvcf")?; cmd.arg("-i") .arg("resources/test.vcf") .arg("--just") .arg(" pos") .arg("info_DP") .arg("-v"); cmd.assert().success(); Ok(()) }