Improve test cleanup by using scopeguard.
This commit is contained in:
@@ -21,3 +21,4 @@ base64 = "0.20.0"
|
|||||||
rpassword = "7.2.0"
|
rpassword = "7.2.0"
|
||||||
shlex = "1.1.0"
|
shlex = "1.1.0"
|
||||||
shellexpand = "3.0.0"
|
shellexpand = "3.0.0"
|
||||||
|
scopeguard = "1.1.0"
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
#[macro_use]
|
#[macro_use] extern crate lazy_static;
|
||||||
extern crate lazy_static;
|
#[macro_use(defer)] extern crate scopeguard;
|
||||||
|
|
||||||
mod lk;
|
mod lk;
|
||||||
mod parser;
|
mod parser;
|
||||||
|
|||||||
+15
-8
@@ -323,16 +323,23 @@ mod tests {
|
|||||||
writeln!(writer, "#!/bin/sh\ncat >test_pb_out").expect("write");
|
writeln!(writer, "#!/bin/sh\ncat >test_pb_out").expect("write");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_must_use)]
|
fn clear_test_files() {
|
||||||
{
|
#[allow(unused_must_use)]
|
||||||
std::fs::remove_file("test_history");
|
{
|
||||||
std::fs::remove_file("test_init");
|
std::fs::remove_file("test_history");
|
||||||
std::fs::remove_file("test_dump");
|
std::fs::remove_file("test_init");
|
||||||
std::fs::remove_file("test_correct");
|
std::fs::remove_file("test_dump");
|
||||||
std::fs::remove_file("test_pb");
|
std::fs::remove_file("test_correct");
|
||||||
std::fs::remove_file("test_pb_out");
|
std::fs::remove_file("test_pb");
|
||||||
|
std::fs::remove_file("test_pb_out");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer! {
|
||||||
|
clear_test_files();
|
||||||
|
}
|
||||||
|
|
||||||
|
clear_test_files();
|
||||||
create_init();
|
create_init();
|
||||||
create_pb();
|
create_pb();
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
add t1 R 99 2022-10-10
|
|
||||||
add t2 R 99 2022-10-10 test ^t1
|
|
||||||
add t3 R 99 2022-10-10 aoeu ^t2
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
add t1 r 99 2022-10-10
|
|
||||||
add t2 r 99 2022-10-10 test ^t1
|
|
||||||
add t3 r 99 2022-10-10 ^t2 aoeu
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
fief gild sits can un very
|
|
||||||
Reference in New Issue
Block a user