-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collect additional breadcrumbs to reduce the situations where we can'…
…t identify an external rustdoc JSON crate. It significantly mitigates #133.
- Loading branch information
1 parent
26cd09f
commit b88cbaf
Showing
8 changed files
with
341 additions
and
97 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
...cli/tests/ui_tests/reflection/ambiguous_dependency_version_is_handled/expectations/app.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//! Do NOT edit this code. | ||
//! It was automatically generated by Pavex. | ||
//! All manual edits will be lost next time the code is generated. | ||
extern crate alloc; | ||
struct ServerState { | ||
router: pavex_matchit::Router<u32>, | ||
#[allow(dead_code)] | ||
application_state: ApplicationState, | ||
} | ||
pub struct ApplicationState {} | ||
pub async fn build_application_state() -> crate::ApplicationState { | ||
crate::ApplicationState {} | ||
} | ||
pub fn run( | ||
server_builder: pavex::server::Server, | ||
application_state: ApplicationState, | ||
) -> pavex::server::ServerHandle { | ||
let server_state = std::sync::Arc::new(ServerState { | ||
router: build_router(), | ||
application_state, | ||
}); | ||
server_builder.serve(route_request, server_state) | ||
} | ||
fn build_router() -> pavex_matchit::Router<u32> { | ||
let mut router = pavex_matchit::Router::new(); | ||
router.insert("/home", 0u32).unwrap(); | ||
router | ||
} | ||
async fn route_request( | ||
request: http::Request<hyper::body::Incoming>, | ||
server_state: std::sync::Arc<ServerState>, | ||
) -> pavex::response::Response { | ||
let (request_head, request_body) = request.into_parts(); | ||
#[allow(unused)] | ||
let request_body = pavex::request::body::RawIncomingBody::from(request_body); | ||
let request_head: pavex::request::RequestHead = request_head.into(); | ||
let matched_route = match server_state.router.at(&request_head.target.path()) { | ||
Ok(m) => m, | ||
Err(_) => { | ||
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter( | ||
vec![], | ||
) | ||
.into(); | ||
return route_1::handler(&allowed_methods).await; | ||
} | ||
}; | ||
let route_id = matched_route.value; | ||
#[allow(unused)] | ||
let url_params: pavex::request::path::RawPathParams<'_, '_> = matched_route | ||
.params | ||
.into(); | ||
match route_id { | ||
0u32 => { | ||
match &request_head.method { | ||
&pavex::http::Method::GET => route_0::handler().await, | ||
_ => { | ||
let allowed_methods: pavex::router::AllowedMethods = pavex::router::MethodAllowList::from_iter([ | ||
pavex::http::Method::GET, | ||
]) | ||
.into(); | ||
route_1::handler(&allowed_methods).await | ||
} | ||
} | ||
} | ||
i => unreachable!("Unknown route id: {}", i), | ||
} | ||
} | ||
pub mod route_0 { | ||
pub async fn handler() -> pavex::response::Response { | ||
let v0 = app::handler(); | ||
<http::StatusCode as pavex::response::IntoResponse>::into_response(v0) | ||
} | ||
} | ||
pub mod route_1 { | ||
pub async fn handler( | ||
v0: &pavex::router::AllowedMethods, | ||
) -> pavex::response::Response { | ||
let v1 = pavex::router::default_fallback(v0).await; | ||
<pavex::response::Response as pavex::response::IntoResponse>::into_response(v1) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
.../ui_tests/reflection/ambiguous_dependency_version_is_handled/expectations/diagnostics.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
digraph "GET /home - 0" { | ||
0 [ label = "app::handler() -> http::StatusCode"] | ||
1 [ label = "<http::StatusCode as pavex::response::IntoResponse>::into_response(http::StatusCode) -> pavex::response::Response"] | ||
0 -> 1 [ ] | ||
} | ||
|
||
digraph "* /home - 0" { | ||
0 [ label = "pavex::router::default_fallback(&pavex::router::AllowedMethods) -> pavex::response::Response"] | ||
2 [ label = "<pavex::response::Response as pavex::response::IntoResponse>::into_response(pavex::response::Response) -> pavex::response::Response"] | ||
3 [ label = "&pavex::router::AllowedMethods"] | ||
0 -> 2 [ ] | ||
3 -> 0 [ ] | ||
} | ||
|
||
digraph app_state { | ||
0 [ label = "crate::ApplicationState() -> crate::ApplicationState"] | ||
} |
13 changes: 13 additions & 0 deletions
13
libs/pavex_cli/tests/ui_tests/reflection/ambiguous_dependency_version_is_handled/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use pavex::blueprint::{router::GET, Blueprint}; | ||
use pavex::f; | ||
use pavex::http::StatusCode; | ||
|
||
pub fn handler() -> StatusCode { | ||
todo!() | ||
} | ||
|
||
pub fn blueprint() -> Blueprint { | ||
let mut bp = Blueprint::new(); | ||
bp.route(GET, "/home", f!(crate::handler)); | ||
bp | ||
} |
12 changes: 12 additions & 0 deletions
12
...ex_cli/tests/ui_tests/reflection/ambiguous_dependency_version_is_handled/test_config.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
description = """Pavex can handle multiple versions of the same | ||
package in the project dependency tree, as long as they aren't all | ||
**direct** dependencies of the project""" | ||
|
||
[expectations] | ||
codegen = "pass" | ||
|
||
[dependencies] | ||
# This depends on a different version of `http` than what `pavex` brings in | ||
reqwest = { version = "0.11", features = ["json"] } | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.