Skip to content

Commit

Permalink
#205 Add integration test for rejecting absolute
Browse files Browse the repository at this point in the history
paths
  • Loading branch information
la10736 committed Aug 12, 2023
1 parent bee9843 commit 36ac25a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
18 changes: 16 additions & 2 deletions rstest/tests/resources/rstest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,22 @@ fn error_convert_to_type_that_not_implement_from_str(#[case] s: S) {}

#[rstest]
#[case(async { "hello" } )]
async fn error_future_on_impl_type(#[case] #[future] s: impl AsRef<str>) {}
async fn error_future_on_impl_type(
#[case]
#[future]
s: impl AsRef<str>,
) {
}

#[rstest]
#[case(async { 42 } )]
async fn error_future_on_impl_type(#[case] #[future] #[future] a: i32) {}
async fn error_future_on_impl_type(
#[case]
#[future]
#[future]
a: i32,
) {
}

#[rstest]
#[timeout]
Expand All @@ -104,3 +115,6 @@ fn error_timeout_without_expression_arg() {}
#[rstest]
#[timeout(42)]
fn error_timeout_without_duration() {}

#[rstest]
fn error_absolute_path_files(#[files("/tmp/tmp.Q81idVZYAV/*.txt")] path: std::path::PathBuf) {}
25 changes: 25 additions & 0 deletions rstest/tests/rstest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1562,4 +1562,29 @@ mod should_show_correct_errors {
.unindent()
);
}

#[test]
fn if_files_contains_absolute_path() {
let (output, name) = execute();

assert_in!(
output.stderr.str(),
format!(
"
error: Invalid glob path: path contains non-relative component
--> {}/src/lib.rs:120:30",
name
)
.unindent()
);

assert_in!(
output.stderr.str(),
r#"
120 | fn error_absolute_path_files(#[files("/tmp/tmp.Q81idVZYAV/*.txt")] path: std::path::PathBuf) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"#
.unindent()
);
}
}

0 comments on commit 36ac25a

Please sign in to comment.