[tests] Fix minor test errors
- Fix command line arguments - Adapt error messages for rust implementations
This commit is contained in:
parent
2bd3c17578
commit
fba2adbe56
@ -25,14 +25,12 @@ fn main() {
|
|||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("SB_ONLY")
|
Arg::with_name("SB_ONLY")
|
||||||
.help("Only check the superblock.")
|
.help("Only check the superblock.")
|
||||||
.long("super-block-only")
|
.long("super-block-only"),
|
||||||
.value_name("SB_ONLY"),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("SKIP_MAPPINGS")
|
Arg::with_name("SKIP_MAPPINGS")
|
||||||
.help("Don't check the mapping tree")
|
.help("Don't check the mapping tree")
|
||||||
.long("skip-mappings")
|
.long("skip-mappings"),
|
||||||
.value_name("SKIP_MAPPINGS"),
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("AUTO_REPAIR")
|
Arg::with_name("AUTO_REPAIR")
|
||||||
@ -47,7 +45,7 @@ fn main() {
|
|||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("CLEAR_NEEDS_CHECK")
|
Arg::with_name("CLEAR_NEEDS_CHECK")
|
||||||
.help("Clears the 'needs_check' flag in the superblock")
|
.help("Clears the 'needs_check' flag in the superblock")
|
||||||
.long("clear-needs-check"),
|
.long("clear-needs-check-flag"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("OVERRIDE_MAPPING_ROOT")
|
Arg::with_name("OVERRIDE_MAPPING_ROOT")
|
||||||
|
@ -42,7 +42,7 @@ fn accepts_help() -> Result<()> {
|
|||||||
#[test]
|
#[test]
|
||||||
fn missing_metadata() -> Result<()> {
|
fn missing_metadata() -> Result<()> {
|
||||||
let stderr = run_fail(cache_check!())?;
|
let stderr = run_fail(cache_check!())?;
|
||||||
assert!(stderr.contains("No input file provided"));
|
assert!(stderr.contains(msg::MISSING_INPUT_ARG));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ fn unreadable_metadata() -> Result<()> {
|
|||||||
let md = mk_valid_md(&mut td)?;
|
let md = mk_valid_md(&mut td)?;
|
||||||
cmd!("chmod", "-r", &md).run()?;
|
cmd!("chmod", "-r", &md).run()?;
|
||||||
let stderr = run_fail(cache_check!(&md))?;
|
let stderr = run_fail(cache_check!(&md))?;
|
||||||
assert!(stderr.contains("syscall 'open' failed: Permission denied"));
|
assert!(stderr.contains("Permission denied"));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,22 @@ use test_dir::TestDir;
|
|||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
|
||||||
|
#[cfg(not(feature = "rust_tests"))]
|
||||||
|
pub mod msg {
|
||||||
|
pub const FILE_NOT_FOUND: &str = "Couldn't stat file";
|
||||||
|
pub const MISSING_INPUT_ARG: &str = "No input file provided";
|
||||||
|
pub const MISSING_OUTPUT_ARG: &str = "No output file provided";
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rust_tests")]
|
||||||
|
pub mod msg {
|
||||||
|
pub const FILE_NOT_FOUND: &str = "Couldn't find input file";
|
||||||
|
pub const MISSING_INPUT_ARG: &str = "The following required arguments were not provided";
|
||||||
|
pub const MISSING_OUTPUT_ARG: &str = "The following required arguments were not provided";
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! path_to_cpp {
|
macro_rules! path_to_cpp {
|
||||||
($name: literal) => {
|
($name: literal) => {
|
||||||
|
@ -65,6 +65,7 @@ fn snap2_unspecified() -> Result<()> {
|
|||||||
#[test]
|
#[test]
|
||||||
fn dev_unspecified() -> Result<()> {
|
fn dev_unspecified() -> Result<()> {
|
||||||
let stderr = run_fail(thin_delta!("--snap1", "45", "--snap2", "46"))?;
|
let stderr = run_fail(thin_delta!("--snap1", "45", "--snap2", "46"))?;
|
||||||
assert!(stderr.contains("No input device provided"));
|
// TODO: replace with msg::MISSING_INPUT_ARG once the rust version is ready
|
||||||
|
assert!(stderr.contains("No input file provided"));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ fn missing_input_file() -> Result<()> {
|
|||||||
let md = mk_zeroed_md(&mut td)?;
|
let md = mk_zeroed_md(&mut td)?;
|
||||||
let stderr = run_fail(thin_repair!("-i", "no-such-file", "-o", &md))?;
|
let stderr = run_fail(thin_repair!("-i", "no-such-file", "-o", &md))?;
|
||||||
assert!(superblock_all_zeroes(&md)?);
|
assert!(superblock_all_zeroes(&md)?);
|
||||||
|
// TODO: replace with msg::FILE_NOT_FOUND once the rust version is ready
|
||||||
assert!(stderr.contains("Couldn't stat file"));
|
assert!(stderr.contains("Couldn't stat file"));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -72,6 +73,7 @@ fn missing_output_file() -> Result<()> {
|
|||||||
let mut td = TestDir::new()?;
|
let mut td = TestDir::new()?;
|
||||||
let md = mk_valid_md(&mut td)?;
|
let md = mk_valid_md(&mut td)?;
|
||||||
let stderr = run_fail(thin_repair!("-i", &md))?;
|
let stderr = run_fail(thin_repair!("-i", &md))?;
|
||||||
|
// TODO: replace with msg::MISSING_OUTPUT_ARG once the rust version is ready
|
||||||
assert!(stderr.contains("No output file provided."));
|
assert!(stderr.contains("No output file provided."));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ fn no_input_file() -> Result<()> {
|
|||||||
let mut td = TestDir::new()?;
|
let mut td = TestDir::new()?;
|
||||||
let md = mk_zeroed_md(&mut td)?;
|
let md = mk_zeroed_md(&mut td)?;
|
||||||
let stderr = run_fail(thin_restore!("-o", &md))?;
|
let stderr = run_fail(thin_restore!("-o", &md))?;
|
||||||
assert!(stderr.contains("No input file provided."));
|
assert!(stderr.contains(msg::MISSING_INPUT_ARG));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ fn missing_input_file() -> Result<()> {
|
|||||||
let md = mk_zeroed_md(&mut td)?;
|
let md = mk_zeroed_md(&mut td)?;
|
||||||
let stderr = run_fail(thin_restore!("-i", "no-such-file", "-o", &md))?;
|
let stderr = run_fail(thin_restore!("-i", "no-such-file", "-o", &md))?;
|
||||||
assert!(superblock_all_zeroes(&md)?);
|
assert!(superblock_all_zeroes(&md)?);
|
||||||
assert!(stderr.contains("Couldn't stat file"));
|
assert!(stderr.contains(msg::FILE_NOT_FOUND));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ fn no_output_file() -> Result<()> {
|
|||||||
let mut td = TestDir::new()?;
|
let mut td = TestDir::new()?;
|
||||||
let xml = mk_valid_xml(&mut td)?;
|
let xml = mk_valid_xml(&mut td)?;
|
||||||
let stderr = run_fail(thin_restore!("-i", &xml))?;
|
let stderr = run_fail(thin_restore!("-i", &xml))?;
|
||||||
assert!(stderr.contains("No output file provided."));
|
assert!(stderr.contains(msg::MISSING_OUTPUT_ARG));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ thin_delta_cmd::run(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argc == optind)
|
if (argc == optind)
|
||||||
die("No input device provided.");
|
die("No input file provided.");
|
||||||
else
|
else
|
||||||
fs.dev = argv[optind];
|
fs.dev = argv[optind];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user