From e07ea7d971d8e2f92e5d5f05c2a1c6a0e0a66bd4 Mon Sep 17 00:00:00 2001 From: Juan Aguilar Santillana Date: Mon, 19 Jul 2021 02:44:41 +0200 Subject: [PATCH] Add coverage for report error at macro #211 --- yarte/tests/compile.rs | 6 ++++++ yarte/tests/proc-fails/proc-basic.rs | 5 +++++ yarte/tests/proc-fails/proc-basic.stderr | 13 +++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 yarte/tests/proc-fails/proc-basic.rs create mode 100644 yarte/tests/proc-fails/proc-basic.stderr diff --git a/yarte/tests/compile.rs b/yarte/tests/compile.rs index ec0baf71..f2cf5e69 100644 --- a/yarte/tests/compile.rs +++ b/yarte/tests/compile.rs @@ -2,3 +2,9 @@ fn ui() { trybuild::TestCases::new().compile_fail("tests/fails/*.rs"); } + +#[cfg(any(feature = "bytes-buf", feature = "bytes-buf-tokio2"))] +#[test] +fn proc_ui() { + trybuild::TestCases::new().compile_fail("tests/proc-fails/*.rs"); +} diff --git a/yarte/tests/proc-fails/proc-basic.rs b/yarte/tests/proc-fails/proc-basic.rs new file mode 100644 index 00000000..34cc76e7 --- /dev/null +++ b/yarte/tests/proc-fails/proc-basic.rs @@ -0,0 +1,5 @@ +use yarte::*; + +fn main() { + let _ = auto!(ywrite_html!(String, "{{ @foo }}")); +} diff --git a/yarte/tests/proc-fails/proc-basic.stderr b/yarte/tests/proc-fails/proc-basic.stderr new file mode 100644 index 00000000..01697059 --- /dev/null +++ b/yarte/tests/proc-fails/proc-basic.stderr @@ -0,0 +1,13 @@ +error: proc macro panicked + --> $DIR/proc-basic.rs:4:13 + | +4 | let _ = auto!(ywrite_html!(String, "{{ @foo }}")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: message: error + --> $DIR/__Main__.hbs:1:5 + | + 1 | {{ @foo }} + | ^^^ Not exist @ helper + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)