File: 2005_workspace_testing.patch

package info (click to toggle)
rust-axum 0.7.9-14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,992 kB
  • sloc: javascript: 26; makefile: 21; sql: 6; sh: 1
file content (93 lines) | stat: -rw-r--r-- 2,388 bytes parent folder | download | duplicates (2)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
@@ -361,6 +361,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
@@ -33,6 +33,7 @@
 tracing = ["axum-core/tracing", "axum/tracing"]
 typed-header = ["dep:headers"]
 typed-routing = ["dep:axum-macros", "dep:percent-encoding", "dep:serde_html_form", "dep:form_urlencoded"]
+in-workspace = []
 
 [dependencies]
 axum = { path = "../axum", version = "0.7.8", default-features = false, features = ["original-uri"] }
--- a/axum-extra/src/lib.rs
+++ b/axum-extra/src/lib.rs
@@ -119,6 +119,7 @@
 pub(crate) mod test_helpers {
     use axum::{extract::Request, response::Response, serve};
 
+    #[cfg(feature = "in-workspace")]
     mod test_client {
         #![allow(dead_code)]
         include!(concat!(
@@ -126,5 +127,8 @@
             "/../axum/src/test_helpers/test_client.rs"
         ));
     }
+    #[cfg(not(feature = "in-workspace"))]
+    mod test_client {
+    }
     pub(crate) use self::test_client::*;
 }
--- a/axum-extra/src/extract/form.rs
+++ b/axum-extra/src/extract/form.rs
@@ -113,7 +113,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
@@ -262,7 +262,7 @@
     }
 }
 
-#[cfg(test)]
+#[cfg(all(test, feature = "in-workspace"))]
 mod tests {
     use super::*;
     use crate::test_helpers::*;