summaryrefslogtreecommitdiffstats
path: root/tests-integration/tests
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-01-21 10:46:32 -0800
committerGitHub <noreply@github.com>2020-01-21 10:46:32 -0800
commit38bff0adda393f8121225727d93cb342d8363979 (patch)
treed0e7c16e369a559d53c8f843fccd0523018a6dfa /tests-integration/tests
parentfbe143b142875977f49772d2905029b57b92e429 (diff)
macros: fix `#[tokio::main]` without rt-core (#2139)
The Tokio runtime provides a "shell" runtime when `rt-core` is not available. This shell runtime is enough to support `#[tokio::main`] and `#[tokio::test]. A previous change disabled these two attr macros when `rt-core` was not selected. This patch fixes this by re-enabling the `main` and `test` attr macros without `rt-core` and adds some integration tests to prevent future regressions.
Diffstat (limited to 'tests-integration/tests')
-rw-r--r--tests-integration/tests/macros_main.rs25
-rw-r--r--tests-integration/tests/process_stdio.rs1
2 files changed, 26 insertions, 0 deletions
diff --git a/tests-integration/tests/macros_main.rs b/tests-integration/tests/macros_main.rs
new file mode 100644
index 00000000..182e2779
--- /dev/null
+++ b/tests-integration/tests/macros_main.rs
@@ -0,0 +1,25 @@
+#![cfg(feature = "macros")]
+
+#[tokio::main]
+async fn basic_main() -> usize {
+ 1
+}
+
+#[cfg(feature = "rt-core")]
+mod spawn {
+ #[tokio::main]
+ async fn spawning() -> usize {
+ let join = tokio::spawn(async { 1 });
+ join.await.unwrap()
+ }
+
+ #[test]
+ fn main_with_spawn() {
+ assert_eq!(1, spawning());
+ }
+}
+
+#[test]
+fn shell() {
+ assert_eq!(1, basic_main());
+}
diff --git a/tests-integration/tests/process_stdio.rs b/tests-integration/tests/process_stdio.rs
index de7cf025..8bf2c149 100644
--- a/tests-integration/tests/process_stdio.rs
+++ b/tests-integration/tests/process_stdio.rs
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
+#![cfg(feature = "full")]
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
use tokio::process::{Child, Command};