diff options
author | Carl Lerche <me@carllerche.com> | 2019-10-25 12:50:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-25 12:50:15 -0700 |
commit | 227533d456fe32e48ffcd3796f1e6c8f9318b230 (patch) | |
tree | 498029aaf42dd64eeb8ef0e7d7f29802b45d4e95 /tests-build/tests | |
parent | 03a9378297c73c2e56a6d6b55db22b92427b850a (diff) |
net: move into tokio crate (#1683)
A step towards collapsing Tokio sub crates into a single `tokio`
crate (#1318).
The `net` implementation is now provided by the main `tokio` crate.
Functionality can be opted out of by using the various net related
feature flags.
Diffstat (limited to 'tests-build/tests')
13 files changed, 181 insertions, 0 deletions
diff --git a/tests-build/tests/fail/executor_without_current_thread.rs b/tests-build/tests/fail/executor_without_current_thread.rs new file mode 100644 index 00000000..205ce7e4 --- /dev/null +++ b/tests-build/tests/fail/executor_without_current_thread.rs @@ -0,0 +1,3 @@ +use tests_build::tokio_executor::current_thread; + +fn main() {} diff --git a/tests-build/tests/fail/executor_without_current_thread.stderr b/tests-build/tests/fail/executor_without_current_thread.stderr new file mode 100644 index 00000000..f2287c3f --- /dev/null +++ b/tests-build/tests/fail/executor_without_current_thread.stderr @@ -0,0 +1,7 @@ +error[E0432]: unresolved import `tests_build::tokio_executor::current_thread` + --> $DIR/executor_without_current_thread.rs:1:5 + | +1 | use tests_build::tokio_executor::current_thread; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `current_thread` in `tokio_executor` + +For more information about this error, try `rustc --explain E0432`. 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..12373486 --- /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 `current_thread` or `threadpool` + --> $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 `current_thread` or `threadpool` + --> $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/fail/net_without_tcp_missing_tcp.rs b/tests-build/tests/fail/net_without_tcp_missing_tcp.rs new file mode 100644 index 00000000..80010233 --- /dev/null +++ b/tests-build/tests/fail/net_without_tcp_missing_tcp.rs @@ -0,0 +1,4 @@ +use tests_build::tokio_net::tcp; + +fn main() {} + diff --git a/tests-build/tests/fail/net_without_tcp_missing_tcp.stderr b/tests-build/tests/fail/net_without_tcp_missing_tcp.stderr new file mode 100644 index 00000000..83ff59fb --- /dev/null +++ b/tests-build/tests/fail/net_without_tcp_missing_tcp.stderr @@ -0,0 +1,7 @@ +error[E0432]: unresolved import `tests_build::tokio_net::tcp` + --> $DIR/net_without_tcp_missing_tcp.rs:1:5 + | +1 | use tests_build::tokio_net::tcp; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `tcp` in `tokio_net` + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests-build/tests/fail/net_without_udp_missing_udp.rs b/tests-build/tests/fail/net_without_udp_missing_udp.rs new file mode 100644 index 00000000..6731af93 --- /dev/null +++ b/tests-build/tests/fail/net_without_udp_missing_udp.rs @@ -0,0 +1,4 @@ +use tests_build::tokio_net::udp; + +fn main() {} + diff --git a/tests-build/tests/fail/net_without_udp_missing_udp.stderr b/tests-build/tests/fail/net_without_udp_missing_udp.stderr new file mode 100644 index 00000000..e3471a79 --- /dev/null +++ b/tests-build/tests/fail/net_without_udp_missing_udp.stderr @@ -0,0 +1,7 @@ +error[E0432]: unresolved import `tests_build::tokio_net::udp` + --> $DIR/net_without_udp_missing_udp.rs:1:5 + | +1 | use tests_build::tokio_net::udp; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `udp` in `tokio_net` + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests-build/tests/fail/net_without_uds_missing_uds.rs b/tests-build/tests/fail/net_without_uds_missing_uds.rs new file mode 100644 index 00000000..d48a5eb4 --- /dev/null +++ b/tests-build/tests/fail/net_without_uds_missing_uds.rs @@ -0,0 +1,4 @@ +use tests_build::tokio_net::uds; + +fn main() {} + diff --git a/tests-build/tests/fail/net_without_uds_missing_uds.stderr b/tests-build/tests/fail/net_without_uds_missing_uds.stderr new file mode 100644 index 00000000..ad79fe18 --- /dev/null +++ b/tests-build/tests/fail/net_without_uds_missing_uds.stderr @@ -0,0 +1,7 @@ +error[E0432]: unresolved import `tests_build::tokio_net::uds` + --> $DIR/net_without_uds_missing_uds.rs:1:5 + | +1 | use tests_build::tokio_net::uds; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `uds` in `tokio_net` + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests-build/tests/fail/tokio_without_net_missing_net.rs b/tests-build/tests/fail/tokio_without_net_missing_net.rs new file mode 100644 index 00000000..f2e27836 --- /dev/null +++ b/tests-build/tests/fail/tokio_without_net_missing_net.rs @@ -0,0 +1,3 @@ +use tests_build::tokio::net; + +fn main() {} diff --git a/tests-build/tests/fail/tokio_without_net_missing_net.stderr b/tests-build/tests/fail/tokio_without_net_missing_net.stderr new file mode 100644 index 00000000..4435b0a6 --- /dev/null +++ b/tests-build/tests/fail/tokio_without_net_missing_net.stderr @@ -0,0 +1,7 @@ +error[E0432]: unresolved import `tests_build::tokio::net` + --> $DIR/tokio_without_net_missing_net.rs:1:5 + | +1 | use tests_build::tokio::net; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `net` in `tokio` + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests-build/tests/features.rs b/tests-build/tests/features.rs new file mode 100644 index 00000000..b40e44ed --- /dev/null +++ b/tests-build/tests/features.rs @@ -0,0 +1,62 @@ +#![allow(unused_imports)] + +#[test] +#[cfg(feature = "tokio-net")] +fn net_default() { + use tests_build::tokio_net::driver::{set_default, Handle, Reactor, Registration}; + use tests_build::tokio_net::util::PollEvented; +} + +#[test] +#[cfg(feature = "net-with-tcp")] +fn net_with_tcp() { + use tests_build::tokio_net::tcp; +} + +#[test] +#[cfg(feature = "net-with-udp")] +fn net_with_udp() { + use tests_build::tokio_net::udp; +} + +#[test] +#[cfg(feature = "net-with-uds")] +fn net_with_uds() { + use tests_build::tokio_net::uds; +} + +#[test] +#[cfg(feature = "net-with-process")] +fn net_with_process() { + use tests_build::tokio_net::process; +} + +#[test] +#[cfg(feature = "tokio-with-net")] +fn tokio_with_net() { + // net is present + use tests_build::tokio::net; +} + +#[test] +fn compile_fail() { + let t = trybuild::TestCases::new(); + + #[cfg(feature = "executor-without-current-thread")] + t.compile_fail("tests/fail/executor_without_current_thread.rs"); + + #[cfg(feature = "macros-invalid-input")] + t.compile_fail("tests/fail/macros_invalid_input.rs"); + + #[cfg(feature = "net-no-features")] + { + t.compile_fail("tests/fail/net_without_tcp_missing_tcp.rs"); + t.compile_fail("tests/fail/net_without_udp_missing_udp.rs"); + t.compile_fail("tests/fail/net_without_uds_missing_uds.rs"); + } + + #[cfg(feature = "tokio-no-features")] + t.compile_fail("tests/fail/tokio_without_net_missing_net.rs"); + + drop(t); +} |