From 7a1c942a216f3e376b2066654d52e582c9aaa66e Mon Sep 17 00:00:00 2001 From: ibraheemdev Date: Tue, 8 Jun 2021 10:40:48 -0400 Subject: [PATCH] add trybuild tests --- actix-macros/tests/trybuild.rs | 2 ++ .../tests/trybuild/main-05-system-expect-path.rs | 4 ++++ .../tests/trybuild/main-05-system-expect-path.stderr | 5 +++++ actix-macros/tests/trybuild/main-06-unknown-attr.rs | 7 +++++++ .../tests/trybuild/main-06-unknown-attr.stderr | 11 +++++++++++ 5 files changed, 29 insertions(+) create mode 100644 actix-macros/tests/trybuild/main-05-system-expect-path.rs create mode 100644 actix-macros/tests/trybuild/main-05-system-expect-path.stderr create mode 100644 actix-macros/tests/trybuild/main-06-unknown-attr.rs create mode 100644 actix-macros/tests/trybuild/main-06-unknown-attr.stderr diff --git a/actix-macros/tests/trybuild.rs b/actix-macros/tests/trybuild.rs index db1ccda2..410d9499 100644 --- a/actix-macros/tests/trybuild.rs +++ b/actix-macros/tests/trybuild.rs @@ -5,6 +5,8 @@ fn compile_macros() { t.compile_fail("tests/trybuild/main-02-only-async.rs"); t.pass("tests/trybuild/main-03-fn-params.rs"); t.pass("tests/trybuild/main-04-system-path.rs"); + t.compile_fail("tests/trybuild/main-05-system-expect-path.rs"); + t.compile_fail("tests/trybuild/main-06-unknown-attr.rs"); t.pass("tests/trybuild/test-01-basic.rs"); t.pass("tests/trybuild/test-02-keep-attrs.rs"); diff --git a/actix-macros/tests/trybuild/main-05-system-expect-path.rs b/actix-macros/tests/trybuild/main-05-system-expect-path.rs new file mode 100644 index 00000000..af541977 --- /dev/null +++ b/actix-macros/tests/trybuild/main-05-system-expect-path.rs @@ -0,0 +1,4 @@ +#[actix_rt::main(system = "!@#*&")] +async fn main2() {} + +fn main() {} diff --git a/actix-macros/tests/trybuild/main-05-system-expect-path.stderr b/actix-macros/tests/trybuild/main-05-system-expect-path.stderr new file mode 100644 index 00000000..7b9c3d83 --- /dev/null +++ b/actix-macros/tests/trybuild/main-05-system-expect-path.stderr @@ -0,0 +1,5 @@ +error: Expected path + --> $DIR/main-05-system-expect-path.rs:1:27 + | +1 | #[actix_rt::main(system = "!@#*&")] + | ^^^^^^^ diff --git a/actix-macros/tests/trybuild/main-06-unknown-attr.rs b/actix-macros/tests/trybuild/main-06-unknown-attr.rs new file mode 100644 index 00000000..72163d25 --- /dev/null +++ b/actix-macros/tests/trybuild/main-06-unknown-attr.rs @@ -0,0 +1,7 @@ +#[actix_rt::main(foo = "bar")] +async fn async_main() {} + +#[actix_rt::main(bar::baz)] +async fn async_main2() {} + +fn main() {} diff --git a/actix-macros/tests/trybuild/main-06-unknown-attr.stderr b/actix-macros/tests/trybuild/main-06-unknown-attr.stderr new file mode 100644 index 00000000..0b04c5e7 --- /dev/null +++ b/actix-macros/tests/trybuild/main-06-unknown-attr.stderr @@ -0,0 +1,11 @@ +error: Unkown attribute specified + --> $DIR/main-06-unknown-attr.rs:1:18 + | +1 | #[actix_rt::main(foo = "bar")] + | ^^^^^^^^^^^ + +error: Unknown attribute specified + --> $DIR/main-06-unknown-attr.rs:4:18 + | +4 | #[actix_rt::main(bar::baz)] + | ^^^^^^^^