Support stable versions in tests

This commit is contained in:
Matt Gathu 2020-09-15 21:30:26 +02:00
parent 1d673ebc4e
commit 3527132c4d
No known key found for this signature in database
GPG Key ID: 7DAD4895E291CE56
4 changed files with 44 additions and 2 deletions

View File

@ -1,4 +1,3 @@
#[rustversion::attr(not(stable(1.42)), ignore)]
#[test]
fn compile_macros() {
let t = trybuild::TestCases::new();
@ -7,7 +6,22 @@ fn compile_macros() {
t.compile_fail("tests/trybuild/simple-fail.rs");
t.pass("tests/trybuild/route-ok.rs");
t.compile_fail("tests/trybuild/route-missing-method-fail.rs");
t.compile_fail("tests/trybuild/route-duplicate-method-fail.rs");
t.compile_fail("tests/trybuild/route-unexpected-method-fail.rs");
test_route_missing_method(&t)
}
#[rustversion::stable(1.42)]
fn test_route_missing_method(t: &trybuild::TestCases) {
t.compile_fail("tests/trybuild/route-missing-method-fail-msrv.rs");
}
#[rustversion::not(stable(1.42))]
#[rustversion::not(nightly)]
fn test_route_missing_method(t: &trybuild::TestCases) {
t.compile_fail("tests/trybuild/route-missing-method-fail.rs");
}
#[rustversion::nightly]
fn test_route_missing_method(_t: &trybuild::TestCases) {}

View File

@ -0,0 +1,15 @@
use actix_web::*;
#[route("/")]
async fn index() -> impl Responder {
HttpResponse::Ok()
}
#[actix_web::main]
async fn main() {
let srv = test::start(|| App::new().service(index));
let request = srv.get("/");
let response = request.send().await.unwrap();
assert!(response.status().is_success());
}

View File

@ -0,0 +1,11 @@
error: The #[route(..)] macro requires at least one `method` attribute
--> $DIR/route-missing-method-fail-msrv.rs:3:1
|
3 | #[route("/")]
| ^^^^^^^^^^^^^
error[E0425]: cannot find value `index` in this scope
--> $DIR/route-missing-method-fail-msrv.rs:10:49
|
10 | let srv = test::start(|| App::new().service(index));
| ^^^^^ not found in this scope

View File

@ -3,6 +3,8 @@ error: The #[route(..)] macro requires at least one `method` attribute
|
3 | #[route("/")]
| ^^^^^^^^^^^^^
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0425]: cannot find value `index` in this scope
--> $DIR/route-missing-method-fail.rs:10:49