File: 1002_test-data_path_from_env.patch

package info (click to toggle)
rust-rustls-webpki-0.101 0.101.7-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,688 kB
  • sloc: python: 1,519; perl: 282; sh: 140; makefile: 17
file content (53 lines) | stat: -rw-r--r-- 1,799 bytes parent folder | download
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
Description: allow specifying test-data path via an environment variable
 This allows the test data,
 which is included in the source package but not in the binary package,
 to be used during the autopkgtest.
Author: Peter Michael Green <plugwash@debian.org>
Bug-Debian: https://bugs.debian.org/1043418
Bug-Debian: https://bugs.debian.org/1055319
Last-Update: 2023-11-04
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,7 @@
+use std::env::VarError::NotPresent;
+fn main() {
+    println!("cargo:rerun-if-env-changed=SOURCEPACKAGEDIR");
+    if std::env::var("SOURCEPACKAGEDIR") == Err(NotPresent) {
+        println!("cargo:rustc-env=SOURCEPACKAGEDIR={}",std::env::current_dir().unwrap().to_str().unwrap());
+    }
+}
--- a/src/signed_data.rs
+++ b/src/signed_data.rs
@@ -448,7 +448,8 @@
     macro_rules! test_file_bytes {
         ( $file_name:expr ) => {
             include_bytes!(concat!(
-                "../third-party/chromium/data/verify_signed_data/",
+                env!("SOURCEPACKAGEDIR"),
+                "/third-party/chromium/data/verify_signed_data/",
                 $file_name
             ))
         };
--- a/tests/better_tls.rs
+++ b/tests/better_tls.rs
@@ -5,7 +5,7 @@
 
 #[test]
 pub fn path_building() {
-    let raw_json = include_bytes!("../third-party/bettertls/pathbuilding.tests.json");
+    let raw_json = include_bytes!(concat!(env!("SOURCEPACKAGEDIR"),"/third-party/bettertls/pathbuilding.tests.json"));
     let better_tls: BetterTls = serde_json::from_slice(raw_json).expect("invalid test JSON");
     println!("Testing BetterTLS revision {:?}", better_tls.revision);
 
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -51,6 +51,7 @@
 
     "src/data/**/*",
 
+    "src/test_utils.rs",
     "tests/**",
 ]