Skip to content

Commit

Permalink
Less typing in test case declarations (pjd#52)
Browse files Browse the repository at this point in the history
Move FileType:: into the macro
  • Loading branch information
asomers authored Jul 11, 2022
1 parent 8cb7e41 commit 6e2858d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions rust/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ macro_rules! test_case {
}
}
};
(@ $f:ident, $features:expr, $flags:expr, $require_root:expr => [$( FileType:: $file_type:tt $( ($ft_args: tt) )? ),+ $(,)*]) => {
(@ $f:ident, $features:expr, $flags:expr, $require_root:expr => [$( $file_type:tt $( ($ft_args: tt) )? ),+ $(,)*]) => {
$(
paste::paste! {
::inventory::submit! {
$crate::test::TestCase {
name: concat!(module_path!(), "::", stringify!($f), "::", stringify!([<$file_type:lower>])),
required_features: $features,
required_file_flags: $flags,
require_root: $require_root || FileType::$file_type $( ($ft_args) )?.privileged(),
fun: |ctx| $f(ctx, FileType::$file_type $( ($ft_args) )?),
require_root: $require_root || crate::runner::context::FileType::$file_type $( ($ft_args) )?.privileged(),
fun: |ctx| $f(ctx, crate::runner::context::FileType::$file_type $( ($ft_args) )?),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust/src/tests/chmod/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::test::{FileFlags, FileSystemFeature};

use super::chmod;

crate::test_case! {enotdir => [FileType::Regular, FileType::Fifo, FileType::Block, FileType::Char, FileType::Socket]}
crate::test_case! {enotdir => [Regular, Fifo, Block, Char, Socket]}
/// Returns ENOTDIR if a component of the path prefix is not a directory
fn enotdir(ctx: &mut TestContext, f_type: FileType) {
let not_dir = ctx.create(f_type).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions rust/src/tests/chmod/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use nix::{
const FILE_PERMS: mode_t = 0o777;

// chmod/00.t:L24
crate::test_case! {change_perm => [FileType::Regular, FileType::Dir, FileType::Fifo, FileType::Block, FileType::Char, FileType::Socket]}
crate::test_case! {change_perm => [Regular, Dir, Fifo, Block, Char, Socket]}
fn change_perm(ctx: &mut TestContext, f_type: FileType) {
let path = ctx.create(f_type).unwrap();
let expected_mode = Mode::from_bits_truncate(0o111);
Expand Down Expand Up @@ -37,7 +37,7 @@ fn change_perm(ctx: &mut TestContext, f_type: FileType) {
}

// chmod/00.t:L58
crate::test_case! {ctime => [FileType::Regular, FileType::Dir, FileType::Fifo, FileType::Block, FileType::Char, FileType::Socket]}
crate::test_case! {ctime => [Regular, Dir, Fifo, Block, Char, Socket]}
fn ctime(ctx: &mut TestContext, f_type: FileType) {
let path = ctx.create(f_type).unwrap();
let ctime_before = stat(&path).unwrap().st_ctime;
Expand All @@ -51,7 +51,7 @@ fn ctime(ctx: &mut TestContext, f_type: FileType) {
}

// chmod/00.t:L89
crate::test_case! {failed_chmod_unchanged_ctime => [FileType::Regular, FileType::Dir, FileType::Fifo, FileType::Block, FileType::Char, FileType::Socket]}
crate::test_case! {failed_chmod_unchanged_ctime => [Regular, Dir, Fifo, Block, Char, Socket]}
fn failed_chmod_unchanged_ctime(ctx: &mut TestContext, f_type: FileType) {
let path = ctx.create(f_type).unwrap();
let ctime_before = stat(&path).unwrap().st_ctime;
Expand Down

0 comments on commit 6e2858d

Please sign in to comment.