1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
Description: detect if building in workspace and fence tests needing that
Author: Jonas Smedegaard <dr@jones.dk>
Bug: https://github.com/tokio-rs/axum/issues/2599
Last-Update: 2024-07-20
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- /dev/null
+++ b/axum-extra/build.rs
@@ -0,0 +1,13 @@
+use std::path::Path;
+
+fn main() {
+ let file_path = Path::new(
+ concat!(
+ env!("CARGO_MANIFEST_DIR"),
+ "/../axum/src/test_helpers/test_client.rs"
+ )
+ );
+ if file_path.exists() {
+ println!("cargo:rustc-cfg=feature=\"in-workspace\"");
+ }
+}
--- a/axum-extra/src/handler/or.rs
+++ b/axum-extra/src/handler/or.rs
@@ -104,6 +104,7 @@
}
}
+#[cfg(feature = "in-workspace")]
#[cfg(test)]
mod tests {
use super::*;
--- a/axum-extra/src/routing/mod.rs
+++ b/axum-extra/src/routing/mod.rs
@@ -411,6 +411,7 @@
impl<S> Sealed for axum::Router<S> {}
}
+#[cfg(feature = "in-workspace")]
#[cfg(test)]
mod tests {
use super::*;
--- a/axum-extra/Cargo.toml
+++ b/axum-extra/Cargo.toml
@@ -40,6 +40,7 @@
tracing = ["axum-core/tracing", "axum/tracing", "dep:tracing"]
typed-header = ["dep:headers"]
typed-routing = ["dep:axum-macros", "dep:percent-encoding", "dep:serde_html_form", "dep:form_urlencoded"]
+in-workspace = []
# Enabled by docs.rs because it uses all-features
__private_docs = [
--- a/axum-extra/src/extract/form.rs
+++ b/axum-extra/src/extract/form.rs
@@ -97,7 +97,7 @@
}
}
-#[cfg(test)]
+#[cfg(all(test, feature = "in-workspace"))]
mod tests {
use super::*;
use crate::test_helpers::*;
--- a/axum-extra/src/extract/query.rs
+++ b/axum-extra/src/extract/query.rs
@@ -202,7 +202,7 @@
}
}
-#[cfg(test)]
+#[cfg(all(test, feature = "in-workspace"))]
mod tests {
use super::*;
use crate::test_helpers::*;
|