Skip to content

Commit

Permalink
Fix #176
Browse files Browse the repository at this point in the history
  • Loading branch information
la10736 committed Jan 15, 2023
1 parent 811f59b commit 478baa1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions rstest_reuse/src/lib.rs
Expand Up @@ -357,6 +357,7 @@ pub fn template(_args: proc_macro::TokenStream, input: proc_macro::TokenStream)
}
}
}
#[allow(unused_imports)]
pub(crate) use #macro_name as #macro_name;
});
tokens.into()
Expand Down
20 changes: 16 additions & 4 deletions rstest_reuse/tests/acceptance.rs
@@ -1,7 +1,10 @@
use rstest_test::{assert_not_in, sanitize_name, testname, Project, Stringable, TestResults};
use rstest_test::{
assert_in, assert_not_in, sanitize_name, testname, Project, Stringable, TestResults,
};

use lazy_static::lazy_static;

use rstest::rstest;
use std::path::{Path, PathBuf};
use temp_testdir::TempDir;

Expand Down Expand Up @@ -50,13 +53,22 @@ fn use_before_define() {
.assert(output);
}

#[test]
fn not_show_any_warning() {
let (output, _) = run_test("simple_example.rs");
#[rstest]
#[case::simple("simple_example.rs")]
#[case::export_not_used("export_not_used.rs")]
fn not_show_any_warning(#[case] path: &str) {
let (output, _) = run_test(path);

assert_not_in!(output.stderr.str(), "warning:");
}

#[test]
fn should_show_warning_if_not_used_template() {
let (output, _) = run_test("not_used.rs");

assert_in!(output.stderr.str(), "warning:");
}

#[test]
fn in_mod() {
let (output, _) = run_test("in_mod.rs");
Expand Down
9 changes: 9 additions & 0 deletions rstest_reuse/tests/resources/export_not_used.rs
@@ -0,0 +1,9 @@
mod foo {
use rstest_reuse::template;

#[template]
#[export]
#[rstest]
#[case("bar")]
fn not_used(#[case] s: &str) {}
}
8 changes: 8 additions & 0 deletions rstest_reuse/tests/resources/not_used.rs
@@ -0,0 +1,8 @@
mod foo {
use rstest_reuse::template;

#[template]
#[rstest]
#[case("bar")]
fn not_used(#[case] s: &str) {}
}

0 comments on commit 478baa1

Please sign in to comment.