From ff2000293c01c62014d5650fb65488d454ff03e5 Mon Sep 17 00:00:00 2001 From: Jeb Rosen Date: Wed, 15 Jan 2020 16:53:57 -0800 Subject: [PATCH] Update 'compiletest' and fix and re-enable compile UI tests. --- contrib/codegen/Cargo.toml | 2 +- contrib/codegen/tests/compile-test.rs | 3 +- core/codegen/Cargo.toml | 2 +- core/codegen/tests/compile-test.rs | 3 +- .../tests/ui-fail/catch_type_errors.stderr | 8 +- core/codegen/tests/ui-fail/responder-types.rs | 1 + .../tests/ui-fail/responder-types.stderr | 35 ++++---- .../tests/ui-fail/typed-uri-bad-type.rs | 1 + .../tests/ui-fail/typed-uri-bad-type.stderr | 80 +++++++++++-------- scripts/test.sh | 3 +- 10 files changed, 78 insertions(+), 60 deletions(-) diff --git a/contrib/codegen/Cargo.toml b/contrib/codegen/Cargo.toml index 739d36ea..ab32b7db 100644 --- a/contrib/codegen/Cargo.toml +++ b/contrib/codegen/Cargo.toml @@ -27,6 +27,6 @@ yansi = "0.5" version_check = "0.9.1" [dev-dependencies] -compiletest_rs = { version = "0.3", features = ["stable"] } +compiletest_rs = "0.4" rocket = { version = "0.5.0-dev", path = "../../core/lib" } rocket_contrib = { version = "0.5.0-dev", path = "../lib", features = ["diesel_sqlite_pool"] } diff --git a/contrib/codegen/tests/compile-test.rs b/contrib/codegen/tests/compile-test.rs index 3212d0bf..d0d9cfda 100644 --- a/contrib/codegen/tests/compile-test.rs +++ b/contrib/codegen/tests/compile-test.rs @@ -97,7 +97,6 @@ fn run_mode(mode: &'static str, path: &'static str) { #[test] fn compile_test() { - // TODO.async: Restore UI tests once they can be fixed - // run_mode("ui", "ui-fail"); + run_mode("ui", "ui-fail"); run_mode("compile-fail", "ui-fail"); } diff --git a/core/codegen/Cargo.toml b/core/codegen/Cargo.toml index 1e7c3fd4..97031e88 100644 --- a/core/codegen/Cargo.toml +++ b/core/codegen/Cargo.toml @@ -27,4 +27,4 @@ version_check = "0.9.1" [dev-dependencies] rocket = { version = "0.5.0-dev", path = "../lib" } -compiletest_rs = { version = "0.3", features = ["stable"] } +compiletest_rs = "0.4" diff --git a/core/codegen/tests/compile-test.rs b/core/codegen/tests/compile-test.rs index ab7089dd..3e41ebc0 100644 --- a/core/codegen/tests/compile-test.rs +++ b/core/codegen/tests/compile-test.rs @@ -96,7 +96,6 @@ fn run_mode(mode: &'static str, path: &'static str) { #[test] fn compile_test() { - // TODO: Restore UI tests once they can be fixed - // run_mode("ui", "ui-fail"); + run_mode("ui", "ui-fail"); run_mode("compile-fail", "ui-fail"); } diff --git a/core/codegen/tests/ui-fail/catch_type_errors.stderr b/core/codegen/tests/ui-fail/catch_type_errors.stderr index a941fbbc..d2d2da7e 100644 --- a/core/codegen/tests/ui-fail/catch_type_errors.stderr +++ b/core/codegen/tests/ui-fail/catch_type_errors.stderr @@ -17,11 +17,13 @@ error[E0277]: the trait bound `bool: rocket::response::Responder<'_>` is not sat error[E0308]: mismatched types --> $DIR/catch_type_errors.rs:18:7 | +17 | #[catch(404)] + | ------------- expected due to this 18 | fn f3(_request: bool) -> usize { - | ^^^^^^^^^^^^^^ expected reference, found bool + | ^^^^^^^^^^^^^^ expected `&rocket::Request<'_>`, found `bool` | - = note: expected type `for<'r, 's> fn(&'r rocket::Request<'s>) -> _` - found type `fn(bool) -> usize {f3}` + = note: expected fn pointer `for<'r, 's> fn(&'r rocket::Request<'s>) -> _` + found fn item `fn(bool) -> usize {f3}` error[E0277]: the trait bound `usize: rocket::response::Responder<'_>` is not satisfied --> $DIR/catch_type_errors.rs:24:12 diff --git a/core/codegen/tests/ui-fail/responder-types.rs b/core/codegen/tests/ui-fail/responder-types.rs index a08dcb97..ce0c1329 100644 --- a/core/codegen/tests/ui-fail/responder-types.rs +++ b/core/codegen/tests/ui-fail/responder-types.rs @@ -1,5 +1,6 @@ // normalize-stderr-test: "<(.*) as (.*)>" -> "$1 as $$TRAIT" // normalize-stderr-test: "and \d+ others" -> "and $$N others" +// normalize-stderr-test: "::: (.*)/core/lib" -> "::: $$ROCKET/core/lib" #![feature(proc_macro_hygiene)] diff --git a/core/codegen/tests/ui-fail/responder-types.stderr b/core/codegen/tests/ui-fail/responder-types.stderr index dd778c1c..03796076 100644 --- a/core/codegen/tests/ui-fail/responder-types.stderr +++ b/core/codegen/tests/ui-fail/responder-types.stderr @@ -1,15 +1,15 @@ error[E0277]: the trait bound `u8: rocket::response::Responder<'_>` is not satisfied - --> $DIR/responder-types.rs:10:5 + --> $DIR/responder-types.rs:11:5 | -10 | thing: u8, +11 | thing: u8, | ^^^^^^^^^ the trait `rocket::response::Responder<'_>` is not implemented for `u8` | = note: required by `rocket::response::Responder::respond_to` error[E0277]: the trait bound `rocket::http::Header<'_>: std::convert::From` is not satisfied - --> $DIR/responder-types.rs:17:5 + --> $DIR/responder-types.rs:18:5 | -17 | other: u8, +18 | other: u8, | ^^^^^^^^^ the trait `std::convert::From` is not implemented for `rocket::http::Header<'_>` | = help: the following implementations were found: @@ -21,17 +21,17 @@ error[E0277]: the trait bound `rocket::http::Header<'_>: std::convert::From` = note: required because of the requirements on the impl of `std::convert::Into>` for `u8` error[E0277]: the trait bound `u8: rocket::response::Responder<'_>` is not satisfied - --> $DIR/responder-types.rs:23:5 + --> $DIR/responder-types.rs:24:5 | -23 | thing: u8, +24 | thing: u8, | ^^^^^^^^^ the trait `rocket::response::Responder<'_>` is not implemented for `u8` | = note: required by `rocket::response::Responder::respond_to` error[E0277]: the trait bound `rocket::http::Header<'_>: std::convert::From` is not satisfied - --> $DIR/responder-types.rs:25:5 + --> $DIR/responder-types.rs:26:5 | -25 | other: u8, +26 | other: u8, | ^^^^^^^^^ the trait `std::convert::From` is not implemented for `rocket::http::Header<'_>` | = help: the following implementations were found: @@ -43,9 +43,9 @@ error[E0277]: the trait bound `rocket::http::Header<'_>: std::convert::From` = note: required because of the requirements on the impl of `std::convert::Into>` for `u8` error[E0277]: the trait bound `rocket::http::Header<'_>: std::convert::From` is not satisfied - --> $DIR/responder-types.rs:33:5 + --> $DIR/responder-types.rs:34:5 | -33 | then: String, +34 | then: String, | ^^^^^^^^^^^^ the trait `std::convert::From` is not implemented for `rocket::http::Header<'_>` | = help: the following implementations were found: @@ -57,12 +57,15 @@ error[E0277]: the trait bound `rocket::http::Header<'_>: std::convert::From>` for `std::string::String` error[E0277]: the trait bound `usize: rocket::response::Responder<'_>` is not satisfied - --> $DIR/responder-types.rs:38:13 - | -38 | fn foo() -> usize { 0 } - | ^^^^^ the trait `rocket::response::Responder<'_>` is not implemented for `usize` - | - = note: required by `rocket::handler::, rocket::http::Status, rocket::Data>>::from` + --> $DIR/responder-types.rs:39:13 + | +39 | fn foo() -> usize { 0 } + | ^^^^^ the trait `rocket::response::Responder<'_>` is not implemented for `usize` + | + ::: $ROCKET/core/lib/src/handler.rs:202:20 + | +202 | pub fn from>(req: &Request<'_>, responder: T) -> Outcome<'r> { + | ------------- required by this bound in `rocket::handler::, rocket::http::Status, rocket::Data>>::from` error: aborting due to 6 previous errors diff --git a/core/codegen/tests/ui-fail/typed-uri-bad-type.rs b/core/codegen/tests/ui-fail/typed-uri-bad-type.rs index 0ce39584..da02a35b 100644 --- a/core/codegen/tests/ui-fail/typed-uri-bad-type.rs +++ b/core/codegen/tests/ui-fail/typed-uri-bad-type.rs @@ -1,5 +1,6 @@ // normalize-stderr-test: "<(.*) as (.*)>" -> "$1 as $$TRAIT" // normalize-stderr-test: "and \d+ others" -> "and $$N others" +// normalize-stderr-test: "::: (.*)/core/http" -> "::: $$ROCKET/core/http" #![feature(proc_macro_hygiene)] diff --git a/core/codegen/tests/ui-fail/typed-uri-bad-type.stderr b/core/codegen/tests/ui-fail/typed-uri-bad-type.stderr index 3a2e8894..b76600d5 100644 --- a/core/codegen/tests/ui-fail/typed-uri-bad-type.stderr +++ b/core/codegen/tests/ui-fail/typed-uri-bad-type.stderr @@ -1,7 +1,7 @@ error[E0277]: the trait bound `usize: rocket::http::uri::FromUriParam` is not satisfied - --> $DIR/typed-uri-bad-type.rs:47:23 + --> $DIR/typed-uri-bad-type.rs:50:23 | -47 | uri!(simple: id = "hi"); +50 | uri!(simple: id = "hi"); | ^^^^ the trait `rocket::http::uri::FromUriParam` is not implemented for `usize` | = help: the following implementations were found: @@ -11,9 +11,9 @@ error[E0277]: the trait bound `usize: rocket::http::uri::FromUriParam` is not satisfied - --> $DIR/typed-uri-bad-type.rs:50:18 + --> $DIR/typed-uri-bad-type.rs:53:18 | -50 | uri!(simple: "hello"); +53 | uri!(simple: "hello"); | ^^^^^^^ the trait `rocket::http::uri::FromUriParam` is not implemented for `usize` | = help: the following implementations were found: @@ -23,9 +23,9 @@ error[E0277]: the trait bound `usize: rocket::http::uri::FromUriParam` is not satisfied - --> $DIR/typed-uri-bad-type.rs:53:23 + --> $DIR/typed-uri-bad-type.rs:56:23 | -53 | uri!(simple: id = 239239i64); +56 | uri!(simple: id = 239239i64); | ^^^^^^^^^ the trait `rocket::http::uri::FromUriParam` is not implemented for `usize` | = help: the following implementations were found: @@ -35,15 +35,15 @@ error[E0277]: the trait bound `usize: rocket::http::uri::FromUriParam` is not satisfied - --> $DIR/typed-uri-bad-type.rs:56:31 + --> $DIR/typed-uri-bad-type.rs:59:31 | -56 | uri!(not_uri_display: 10, S); +59 | uri!(not_uri_display: 10, S); | ^ the trait `rocket::http::uri::FromUriParam` is not implemented for `S` error[E0277]: the trait bound `i32: rocket::http::uri::FromUriParam>` is not satisfied - --> $DIR/typed-uri-bad-type.rs:62:26 + --> $DIR/typed-uri-bad-type.rs:65:26 | -62 | uri!(optionals: id = Some(10), name = Ok("bob".into())); +65 | uri!(optionals: id = Some(10), name = Ok("bob".into())); | ^^^^^^^^ the trait `rocket::http::uri::FromUriParam>` is not implemented for `i32` | = help: the following implementations were found: @@ -53,9 +53,9 @@ error[E0277]: the trait bound `i32: rocket::http::uri::FromUriParam>` for `std::option::Option` error[E0277]: the trait bound `std::string::String: rocket::http::uri::FromUriParam>` is not satisfied - --> $DIR/typed-uri-bad-type.rs:62:43 + --> $DIR/typed-uri-bad-type.rs:65:43 | -62 | uri!(optionals: id = Some(10), name = Ok("bob".into())); +65 | uri!(optionals: id = Some(10), name = Ok("bob".into())); | ^^^^^^^^^^^^^^^^ the trait `rocket::http::uri::FromUriParam>` is not implemented for `std::string::String` | = help: the following implementations were found: @@ -67,9 +67,9 @@ error[E0277]: the trait bound `std::string::String: rocket::http::uri::FromUriPa = note: required because of the requirements on the impl of `rocket::http::uri::FromUriParam>` for `std::result::Result` error[E0277]: the trait bound `isize: rocket::http::uri::FromUriParam` is not satisfied - --> $DIR/typed-uri-bad-type.rs:66:20 + --> $DIR/typed-uri-bad-type.rs:69:20 | -66 | uri!(simple_q: "hi"); +69 | uri!(simple_q: "hi"); | ^^^^ the trait `rocket::http::uri::FromUriParam` is not implemented for `isize` | = help: the following implementations were found: @@ -79,9 +79,9 @@ error[E0277]: the trait bound `isize: rocket::http::uri::FromUriParam` is not satisfied - --> $DIR/typed-uri-bad-type.rs:69:25 + --> $DIR/typed-uri-bad-type.rs:72:25 | -69 | uri!(simple_q: id = "hi"); +72 | uri!(simple_q: id = "hi"); | ^^^^ the trait `rocket::http::uri::FromUriParam` is not implemented for `isize` | = help: the following implementations were found: @@ -91,37 +91,49 @@ error[E0277]: the trait bound `isize: rocket::http::uri::FromUriParam` is not satisfied - --> $DIR/typed-uri-bad-type.rs:72:24 + --> $DIR/typed-uri-bad-type.rs:75:24 | -72 | uri!(other_q: 100, S); +75 | uri!(other_q: 100, S); | ^ the trait `rocket::http::uri::FromUriParam` is not implemented for `S` error[E0277]: the trait bound `S: rocket::http::uri::FromUriParam` is not satisfied - --> $DIR/typed-uri-bad-type.rs:75:26 + --> $DIR/typed-uri-bad-type.rs:78:26 | -75 | uri!(other_q: rest = S, id = 100); +78 | uri!(other_q: rest = S, id = 100); | ^ the trait `rocket::http::uri::FromUriParam` is not implemented for `S` error[E0277]: the trait bound `S: rocket::http::uri::Ignorable` is not satisfied - --> $DIR/typed-uri-bad-type.rs:78:26 - | -78 | uri!(other_q: rest = _, id = 100); - | ^ the trait `rocket::http::uri::Ignorable` is not implemented for `S` - | - = note: required by `rocket::http::uri::assert_ignorable` + --> $DIR/typed-uri-bad-type.rs:42:29 + | +42 | fn other_q(id: usize, rest: S) { } + | ^ the trait `rocket::http::uri::Ignorable` is not implemented for `S` +... +81 | uri!(other_q: rest = _, id = 100); + | ---------------------------------- in this macro invocation + | + ::: $ROCKET/core/http/src/uri/uri_display.rs:467:40 + | +467 | pub fn assert_ignorable>() { } + | ------------ required by this bound in `rocket::http::uri::assert_ignorable` error[E0277]: the trait bound `usize: rocket::http::uri::Ignorable` is not satisfied - --> $DIR/typed-uri-bad-type.rs:81:34 - | -81 | uri!(other_q: rest = S, id = _); - | ^ the trait `rocket::http::uri::Ignorable` is not implemented for `usize` - | - = note: required by `rocket::http::uri::assert_ignorable` + --> $DIR/typed-uri-bad-type.rs:42:16 + | +42 | fn other_q(id: usize, rest: S) { } + | ^^^^^ the trait `rocket::http::uri::Ignorable` is not implemented for `usize` +... +83 | uri!(other_q: rest = S, id = _); + | -------------------------------- in this macro invocation + | + ::: $ROCKET/core/http/src/uri/uri_display.rs:467:40 + | +467 | pub fn assert_ignorable>() { } + | ------------ required by this bound in `rocket::http::uri::assert_ignorable` error[E0277]: the trait bound `S: rocket::http::uri::FromUriParam` is not satisfied - --> $DIR/typed-uri-bad-type.rs:81:26 + --> $DIR/typed-uri-bad-type.rs:83:26 | -81 | uri!(other_q: rest = S, id = _); +83 | uri!(other_q: rest = S, id = _); | ^ the trait `rocket::http::uri::FromUriParam` is not implemented for `S` error: aborting due to 13 previous errors diff --git a/scripts/test.sh b/scripts/test.sh index 88f16b96..4b2d8f36 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -41,7 +41,8 @@ function ensure_tab_free() { # Ensures there are no files with trailing whitespace. function ensure_trailing_whitespace_free() { - local matches=$(git grep -E -I "\s+$" "${PROJECT_ROOT}") + # FIXME: Some .stderr files contain trailing spaces + local matches=$(git grep -E -I "\s+$" "${PROJECT_ROOT}" | grep -v -F '.stderr:') if ! [ -z "${matches}" ]; then echo "Trailing whitespace was found in the following:" echo "${matches}"