summaryrefslogtreecommitdiffstats
path: root/tests-build/tests
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2019-11-22 14:38:49 -0800
committerGitHub <noreply@github.com>2019-11-22 14:38:49 -0800
commite1b1e216c506a01a1f4ca579adae02f85b8db82b (patch)
tree77d5fcb2f241c7d1c6d4073e097e85d0fbf7c4fc /tests-build/tests
parent7cd63fb94608ce8c70b8a7a7a4118cba658b3bcc (diff)
ci: bring back build tests (#1813)
This directory was deleted when `cargo hack` was introduced, however there were some tests that were still useful (macro failure output). Also, additional build tests will be added over time.
Diffstat (limited to 'tests-build/tests')
-rw-r--r--tests-build/tests/fail/macros_invalid_input.rs25
-rw-r--r--tests-build/tests/fail/macros_invalid_input.stderr41
-rw-r--r--tests-build/tests/macros.rs9
3 files changed, 75 insertions, 0 deletions
diff --git a/tests-build/tests/fail/macros_invalid_input.rs b/tests-build/tests/fail/macros_invalid_input.rs
new file mode 100644
index 00000000..5b1a8adc
--- /dev/null
+++ b/tests-build/tests/fail/macros_invalid_input.rs
@@ -0,0 +1,25 @@
+use tests_build::tokio;
+
+#[tokio::main]
+fn main_is_not_async() {}
+
+#[tokio::main(foo)]
+async fn main_attr_has_unknown_args() {}
+
+#[tokio::main(threadpool::bar)]
+async fn main_attr_has_path_args() {}
+
+#[tokio::test]
+fn test_is_not_async() {}
+
+#[tokio::test]
+async fn test_fn_has_args(_x: u8) {}
+
+#[tokio::test(foo)]
+async fn test_attr_has_args() {}
+
+#[tokio::test]
+#[test]
+async fn test_has_second_test_attr() {}
+
+fn main() {}
diff --git a/tests-build/tests/fail/macros_invalid_input.stderr b/tests-build/tests/fail/macros_invalid_input.stderr
new file mode 100644
index 00000000..96fdcb17
--- /dev/null
+++ b/tests-build/tests/fail/macros_invalid_input.stderr
@@ -0,0 +1,41 @@
+error: the async keyword is missing from the function declaration
+ --> $DIR/macros_invalid_input.rs:4:1
+ |
+4 | fn main_is_not_async() {}
+ | ^^
+
+error: Unknown attribute foo is specified; expected `basic_scheduler` or `threaded_scheduler`
+ --> $DIR/macros_invalid_input.rs:6:15
+ |
+6 | #[tokio::main(foo)]
+ | ^^^
+
+error: Must have specified ident
+ --> $DIR/macros_invalid_input.rs:9:15
+ |
+9 | #[tokio::main(threadpool::bar)]
+ | ^^^^^^^^^^^^^^^
+
+error: the async keyword is missing from the function declaration
+ --> $DIR/macros_invalid_input.rs:13:1
+ |
+13 | fn test_is_not_async() {}
+ | ^^
+
+error: the test function cannot accept arguments
+ --> $DIR/macros_invalid_input.rs:16:27
+ |
+16 | async fn test_fn_has_args(_x: u8) {}
+ | ^^^^^^
+
+error: Unknown attribute foo is specified; expected `basic_scheduler` or `threaded_scheduler`
+ --> $DIR/macros_invalid_input.rs:18:15
+ |
+18 | #[tokio::test(foo)]
+ | ^^^
+
+error: second test attribute is supplied
+ --> $DIR/macros_invalid_input.rs:22:1
+ |
+22 | #[test]
+ | ^^^^^^^
diff --git a/tests-build/tests/macros.rs b/tests-build/tests/macros.rs
new file mode 100644
index 00000000..170db227
--- /dev/null
+++ b/tests-build/tests/macros.rs
@@ -0,0 +1,9 @@
+#[test]
+fn compile_fail() {
+ let t = trybuild::TestCases::new();
+
+ #[cfg(feature = "full")]
+ t.compile_fail("tests/fail/macros_invalid_input.rs");
+
+ drop(t);
+}