Skip to content

Commit

Permalink
Merge #19
Browse files Browse the repository at this point in the history
19: Use trybuild instead of compiletest r=taiki-e a=taiki-e

Refs: dtolnay/trybuild#13

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e authored Sep 26, 2019
2 parents 3878b58 + 7e56b11 commit 3c73432
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 129 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ futures-core-preview = { version = "0.3.0-alpha.18", default-features = false }
pin-project = "0.4"

[dev-dependencies]
compiletest = { version = "=0.3.22", package = "compiletest_rs", features = ["stable", "tmp"] }
trybuild = "1.0"
futures-preview = "0.3.0-alpha.18"
romio = "0.3.0-alpha.10"
9 changes: 2 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ jobs:
parameters:
toolchain: nightly
- script: |
cargo clean
cargo test -p futures-async-stream --all-features --test compiletest
env:
RUSTFLAGS: -Dwarnings --cfg compiletest
RUSTFLAGS='-Dwarnings --cfg compiletest' cargo test -p futures-async-stream --all-features --test compiletest
displayName: compiletest
- job: clippy
Expand Down Expand Up @@ -116,7 +113,5 @@ jobs:
parameters:
toolchain: nightly
- script: |
cargo doc --no-deps --all --all-features
env:
RUSTDOCFLAGS: -Dwarnings
RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all --all-features
displayName: cargo doc
3 changes: 2 additions & 1 deletion compiletest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
# . ./compiletest.sh
# ```

rm -rf target/debug/deps/libfutures_async_stream* && RUSTFLAGS='--cfg compiletest' cargo +nightly test -p futures-async-stream --all-features --test compiletest
TRYBUILD=overwrite RUSTFLAGS='--cfg compiletest' cargo +nightly test -p futures-async-stream --all-features --test compiletest
# RUSTFLAGS='--cfg compiletest' cargo +nightly test -p futures-async-stream --all-features --test compiletest
28 changes: 3 additions & 25 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
#![cfg(compiletest)]
#![warn(rust_2018_idioms)]

use std::{env, path::PathBuf};

fn run_mode(mode: &'static str) {
let mut config = compiletest::Config::default();
config.mode = mode.parse().expect("invalid mode");
let mut me = env::current_exe().unwrap();
me.pop();
config.target_rustcflags = Some(format!(
"--edition=2018 \
-Z unstable-options \
--extern futures_async_stream \
-L {}",
me.display()
));
let src = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
config.src_base = src.join("tests").join(mode);

me.pop();
me.pop();
config.build_base = me.join("tests").join(mode);
compiletest::run_tests(&config);
}

#[test]
fn compiletest() {
run_mode("ui");
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}
2 changes: 0 additions & 2 deletions tests/ui/bad-item-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,5 @@ note: the type is part of the generator because of this `yield`
18 | #[async_stream(item = (i32, i32))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 11 previous errors

Some errors have detailed explanations: E0271, E0308, E0698.
For more information about an error, try `rustc --explain E0271`.
2 changes: 0 additions & 2 deletions tests/ui/forget-semicolon.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ error[E0308]: mismatched types
= note: expected type `()`
found type `std::option::Option<()>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
3 changes: 0 additions & 3 deletions tests/ui/invalid-arguments.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,3 @@ error: `boxed` and `boxed_local` cannot be used at the same time.
|
52 | #[async_stream(item = i32, boxed_local, boxed)] //~ ERROR `boxed` and `boxed_local` cannot be used at the same time.
| ^^^^^

error: aborting due to 8 previous errors

3 changes: 0 additions & 3 deletions tests/ui/invalid-function.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ error: async stream must return the unit type
|
17 | async fn output() -> i32 {} //~ ERROR async stream must return the unit type
| ^^^

error: aborting due to 5 previous errors

3 changes: 0 additions & 3 deletions tests/ui/missing-item.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error: unexpected end of input, expected `item`
|
7 | #[async_stream] //~ ERROR unexpected end of input, expected `item`
| ^^^^^^^^^^^^^^^

error: aborting due to previous error

2 changes: 0 additions & 2 deletions tests/ui/move-captured-variable.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ error[E0507]: cannot move out of `a`, a captured variable in an `FnMut` closure
| |__________move out of `a` occurs here
| in this macro invocation

error: aborting due to previous error

For more information about this error, try `rustc --explain E0507`.
3 changes: 0 additions & 3 deletions tests/ui/nested.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ error[E0727]: `async` generators are not yet supported
|
19 | yield i * i; //~ ERROR `async` generators are not yet supported [E0727]
| ^^^^^^^^^^^

error: aborting due to previous error

2 changes: 0 additions & 2 deletions tests/ui/question-mark-await-type-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,5 @@ error[E0277]: the `?` operator can only be applied to values that implement `std
= help: the trait `std::ops::Try` is not implemented for `()`
= note: required by `std::ops::Try::into_result`

error: aborting due to 14 previous errors

Some errors have detailed explanations: E0277, E0698.
For more information about an error, try `rustc --explain E0277`.
2 changes: 0 additions & 2 deletions tests/ui/threads-sendsync.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ error[E0277]: `dyn futures_core::stream::Stream<Item = i32>` cannot be sent betw
= note: required because it appears within the type `std::boxed::Box<dyn futures_core::stream::Stream<Item = i32>>`
= note: required because it appears within the type `std::pin::Pin<std::boxed::Box<dyn futures_core::stream::Stream<Item = i32>>>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
2 changes: 0 additions & 2 deletions tests/ui/type-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ error[E0308]: mismatched types
= note: expected type `i32`
found type `&'static str`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
26 changes: 19 additions & 7 deletions tests/ui/unresolved-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@ error[E0412]: cannot find type `Left` in this scope
|
7 | #[async_stream(item = Left)] //~ ERROR cannot find type `Left` in this scope
| ^^^^ not found in this scope
help: there is an enum variant `core::fmt::Alignment::Left` and 4 others; try using the variant's enum
help: there is an enum variant `core::fmt::Alignment::Left` and 9 others; try using the variant's enum
|
7 | #[async_stream(item = core::fmt::Alignment)] //~ ERROR cannot find type `Left` in this scope
| ^^^^^^^^^^^^^^^^^^^^
7 | #[async_stream(item = core::fmt::rt::v1::Alignment)] //~ ERROR cannot find type `Left` in this scope
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 | #[async_stream(item = std::fmt::Alignment)] //~ ERROR cannot find type `Left` in this scope
| ^^^^^^^^^^^^^^^^^^^
7 | #[async_stream(item = std::fmt::rt::v1::Alignment)] //~ ERROR cannot find type `Left` in this scope
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 | #[async_stream(item = futures::core_reexport::fmt::Alignment)] //~ ERROR cannot find type `Left` in this scope
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7 | #[async_stream(item = futures::core_reexport::fmt::rt::v1::Alignment)] //~ ERROR cannot find type `Left` in this scope
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and 5 other candidates

error: aborting due to previous error
error[E0698]: type inside generator must be known in this context
--> $DIR/unresolved-type.rs:7:1
|
7 | #[async_stream(item = Left)] //~ ERROR cannot find type `Left` in this scope
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `T`
|
note: the type is part of the generator because of this `yield`
--> $DIR/unresolved-type.rs:7:1
|
7 | #[async_stream(item = Left)] //~ ERROR cannot find type `Left` in this scope
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0412`.
Some errors have detailed explanations: E0412, E0698.
For more information about an error, try `rustc --explain E0412`.
24 changes: 0 additions & 24 deletions tests/ui/update-all-references.sh

This file was deleted.

40 changes: 0 additions & 40 deletions tests/ui/update-references.sh

This file was deleted.

0 comments on commit 3c73432

Please sign in to comment.