From c31fe5f3fc313ca539ff1f1c92cc1337a472e809 Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Fri, 2 Jul 2021 15:54:17 +0200 Subject: Fix expected error message for missing file rust-lang/rust#82069 made error message that stem macro invocations more verbose. Since Rust 1.54 (currently in beta) the message includes the name of the offending macro. This PR uses version_check to select the appropriate expected error message. --- testing/Cargo.toml | 1 + testing/tests/ui.rs | 7 +++++++ testing/tests/ui/before_1_54/incorrect_path.rs | 8 ++++++++ testing/tests/ui/before_1_54/incorrect_path.stderr | 7 +++++++ testing/tests/ui/incorrect_path.rs | 8 -------- testing/tests/ui/incorrect_path.stderr | 7 ------- testing/tests/ui/since_1_54/incorrect_path.rs | 1 + testing/tests/ui/since_1_54/incorrect_path.stderr | 7 +++++++ 8 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 testing/tests/ui/before_1_54/incorrect_path.rs create mode 100644 testing/tests/ui/before_1_54/incorrect_path.stderr delete mode 100644 testing/tests/ui/incorrect_path.rs delete mode 100644 testing/tests/ui/incorrect_path.stderr create mode 120000 testing/tests/ui/since_1_54/incorrect_path.rs create mode 100644 testing/tests/ui/since_1_54/incorrect_path.stderr (limited to 'testing') diff --git a/testing/Cargo.toml b/testing/Cargo.toml index 0fcee8c..d676bef 100644 --- a/testing/Cargo.toml +++ b/testing/Cargo.toml @@ -16,6 +16,7 @@ serde_json = { version = "1.0", optional = true } [dev-dependencies] criterion = "0.3" trybuild = "1.0" +version_check = "0.9" [[bench]] name = "all" diff --git a/testing/tests/ui.rs b/testing/tests/ui.rs index 17c2248..39a0b78 100644 --- a/testing/tests/ui.rs +++ b/testing/tests/ui.rs @@ -1,7 +1,14 @@ use trybuild::TestCases; +use version_check as rustc; #[cfg_attr(not(windows), test)] fn ui() { let t = TestCases::new(); t.compile_fail("tests/ui/*.rs"); + + if rustc::is_min_version("1.54").unwrap() { + t.compile_fail("tests/ui/since_1_54/*.rs"); + } else { + t.compile_fail("tests/ui/before_1_54/*.rs"); + } } diff --git a/testing/tests/ui/before_1_54/incorrect_path.rs b/testing/tests/ui/before_1_54/incorrect_path.rs new file mode 100644 index 0000000..f0c85cf --- /dev/null +++ b/testing/tests/ui/before_1_54/incorrect_path.rs @@ -0,0 +1,8 @@ +use askama::Template; + +#[derive(Template)] +#[template(path = "thisdoesnotexist.html")] +struct MyTemplate; + +fn main() { +} diff --git a/testing/tests/ui/before_1_54/incorrect_path.stderr b/testing/tests/ui/before_1_54/incorrect_path.stderr new file mode 100644 index 0000000..ea97149 --- /dev/null +++ b/testing/tests/ui/before_1_54/incorrect_path.stderr @@ -0,0 +1,7 @@ +error: template "thisdoesnotexist.html" not found in directories ["$WORKSPACE/target/tests/askama_testing/templates"] + --> $DIR/incorrect_path.rs:3:10 + | +3 | #[derive(Template)] + | ^^^^^^^^ + | + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/testing/tests/ui/incorrect_path.rs b/testing/tests/ui/incorrect_path.rs deleted file mode 100644 index f0c85cf..0000000 --- a/testing/tests/ui/incorrect_path.rs +++ /dev/null @@ -1,8 +0,0 @@ -use askama::Template; - -#[derive(Template)] -#[template(path = "thisdoesnotexist.html")] -struct MyTemplate; - -fn main() { -} diff --git a/testing/tests/ui/incorrect_path.stderr b/testing/tests/ui/incorrect_path.stderr deleted file mode 100644 index ea97149..0000000 --- a/testing/tests/ui/incorrect_path.stderr +++ /dev/null @@ -1,7 +0,0 @@ -error: template "thisdoesnotexist.html" not found in directories ["$WORKSPACE/target/tests/askama_testing/templates"] - --> $DIR/incorrect_path.rs:3:10 - | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/testing/tests/ui/since_1_54/incorrect_path.rs b/testing/tests/ui/since_1_54/incorrect_path.rs new file mode 120000 index 0000000..224f517 --- /dev/null +++ b/testing/tests/ui/since_1_54/incorrect_path.rs @@ -0,0 +1 @@ +../before_1_54/incorrect_path.rs \ No newline at end of file diff --git a/testing/tests/ui/since_1_54/incorrect_path.stderr b/testing/tests/ui/since_1_54/incorrect_path.stderr new file mode 100644 index 0000000..e3d7ca4 --- /dev/null +++ b/testing/tests/ui/since_1_54/incorrect_path.stderr @@ -0,0 +1,7 @@ +error: template "thisdoesnotexist.html" not found in directories ["$WORKSPACE/target/tests/askama_testing/templates"] + --> $DIR/incorrect_path.rs:3:10 + | +3 | #[derive(Template)] + | ^^^^^^^^ + | + = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) -- cgit