[tests] Refine trait names
This commit is contained in:
parent
47d39d1efa
commit
737cf2f67d
@ -67,7 +67,7 @@ impl<'a> InputProgram<'a> for CacheCheck {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> BinaryInputProgram<'_> for CacheCheck {}
|
||||
impl<'a> MetadataReader<'a> for CacheCheck {}
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
|
@ -182,7 +182,7 @@ macro_rules! test_unreadable_input_file {
|
||||
|
||||
pub fn test_help_message_for_tiny_input_file<'a, P>() -> Result<()>
|
||||
where
|
||||
P: BinaryInputProgram<'a>,
|
||||
P: MetadataReader<'a>,
|
||||
{
|
||||
let mut td = TestDir::new()?;
|
||||
|
||||
@ -209,7 +209,7 @@ macro_rules! test_help_message_for_tiny_input_file {
|
||||
|
||||
pub fn test_spot_xml_data<'a, P>() -> Result<()>
|
||||
where
|
||||
P: BinaryInputProgram<'a>,
|
||||
P: MetadataReader<'a>,
|
||||
{
|
||||
let mut td = TestDir::new()?;
|
||||
|
||||
|
@ -33,12 +33,12 @@ macro_rules! test_missing_output_option {
|
||||
|
||||
pub fn test_output_file_not_found<'a, P>() -> Result<()>
|
||||
where
|
||||
P: OutputProgram<'a>,
|
||||
P: MetadataWriter<'a>,
|
||||
{
|
||||
let mut td = TestDir::new()?;
|
||||
let input = P::mk_valid_input(&mut td)?;
|
||||
let stderr = run_fail(P::path(), args!["-i", &input, "-o", "no-such-file"])?;
|
||||
assert!(stderr.contains(<P as OutputProgram>::file_not_found()));
|
||||
assert!(stderr.contains(<P as MetadataWriter>::file_not_found()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ macro_rules! test_unwritable_output_file {
|
||||
// currently thin/cache_restore only
|
||||
pub fn test_tiny_output_file<'a, P>() -> Result<()>
|
||||
where
|
||||
P: BinaryOutputProgram<'a>,
|
||||
P: MetadataWriter<'a>,
|
||||
{
|
||||
let mut td = TestDir::new()?;
|
||||
let input = P::mk_valid_input(&mut td)?;
|
||||
|
@ -30,14 +30,20 @@ pub trait InputProgram<'a>: Program<'a> {
|
||||
fn corrupted_input() -> &'a str;
|
||||
}
|
||||
|
||||
pub trait BinaryInputProgram<'a>: InputProgram<'a> {}
|
||||
pub trait MetadataReader<'a>: InputProgram<'a> {}
|
||||
|
||||
pub trait OutputProgram<'a>: InputProgram<'a> {
|
||||
// error messages
|
||||
fn missing_output_arg() -> &'a str;
|
||||
}
|
||||
|
||||
// programs that write existed files
|
||||
pub trait MetadataWriter<'a>: OutputProgram<'a> {
|
||||
// error messages
|
||||
fn file_not_found() -> &'a str;
|
||||
}
|
||||
|
||||
pub trait BinaryOutputProgram<'a>: OutputProgram<'a> {}
|
||||
// programs that create output files (O_CREAT)
|
||||
pub trait MetadataCreator<'a>: OutputProgram<'a> {}
|
||||
|
||||
//------------------------------------------
|
||||
|
@ -70,7 +70,7 @@ impl<'a> InputProgram<'a> for ThinCheck {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> BinaryInputProgram<'_> for ThinCheck {}
|
||||
impl<'a> MetadataReader<'_> for ThinCheck {}
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
|
@ -74,10 +74,6 @@ impl<'a> InputProgram<'a> for ThinMetadataPack {
|
||||
}
|
||||
|
||||
impl<'a> OutputProgram<'a> for ThinMetadataPack {
|
||||
fn file_not_found() -> &'a str {
|
||||
rust_msg::FILE_NOT_FOUND
|
||||
}
|
||||
|
||||
fn missing_output_arg() -> &'a str {
|
||||
rust_msg::MISSING_OUTPUT_ARG
|
||||
}
|
||||
|
@ -76,10 +76,6 @@ impl<'a> InputProgram<'a> for ThinMetadataUnpack {
|
||||
}
|
||||
|
||||
impl<'a> OutputProgram<'a> for ThinMetadataUnpack {
|
||||
fn file_not_found() -> &'a str {
|
||||
rust_msg::FILE_NOT_FOUND
|
||||
}
|
||||
|
||||
fn missing_output_arg() -> &'a str {
|
||||
rust_msg::MISSING_OUTPUT_ARG
|
||||
}
|
||||
|
@ -69,15 +69,17 @@ impl<'a> InputProgram<'a> for ThinRepair {
|
||||
}
|
||||
|
||||
impl<'a> OutputProgram<'a> for ThinRepair {
|
||||
fn file_not_found() -> &'a str {
|
||||
cpp_msg::FILE_NOT_FOUND
|
||||
}
|
||||
|
||||
fn missing_output_arg() -> &'a str {
|
||||
cpp_msg::MISSING_OUTPUT_ARG
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> MetadataWriter<'a> for ThinRepair {
|
||||
fn file_not_found() -> &'a str {
|
||||
cpp_msg::FILE_NOT_FOUND
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
test_accepts_help!(ThinRepair);
|
||||
|
@ -70,16 +70,16 @@ impl<'a> InputProgram<'a> for ThinRestore {
|
||||
}
|
||||
|
||||
impl<'a> OutputProgram<'a> for ThinRestore {
|
||||
fn file_not_found() -> &'a str {
|
||||
msg::FILE_NOT_FOUND
|
||||
}
|
||||
|
||||
fn missing_output_arg() -> &'a str {
|
||||
msg::MISSING_OUTPUT_ARG
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> BinaryOutputProgram<'_> for ThinRestore {}
|
||||
impl<'a> MetadataWriter<'a> for ThinRestore {
|
||||
fn file_not_found() -> &'a str {
|
||||
msg::FILE_NOT_FOUND
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
@ -93,6 +93,8 @@ test_corrupted_input_data!(ThinRestore);
|
||||
test_missing_output_option!(ThinRestore);
|
||||
test_tiny_output_file!(ThinRestore);
|
||||
|
||||
test_unwritable_output_file!(ThinRestore);
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
// TODO: share with cache_restore, era_restore
|
||||
|
Loading…
Reference in New Issue
Block a user