File: 1002_test-data_path_from_env.patch

package info (click to toggle)
rust-rustls-webpki 0.103.4-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 10,632 kB
  • sloc: python: 2,278; sh: 61; makefile: 12
file content (56 lines) | stat: -rw-r--r-- 1,789 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
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/alg_tests.rs
+++ b/src/alg_tests.rs
@@ -31,7 +31,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
@@ -103,7 +103,7 @@
 }
 
 fn testdata() -> BetterTls {
-    let mut data_file = File::open("third-party/bettertls/bettertls.tests.json.bz2")
+    let mut data_file = File::open(concat!(env!("SOURCEPACKAGEDIR"),"third-party/bettertls/bettertls.tests.json.bz2"))
         .expect("failed to open data file");
     let decompressor = BzDecoder::new(&mut data_file);
 
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -54,6 +54,10 @@
     "src/x509.rs",
     "src/verify_cert.rs",
     "src/lib.rs",
+
+    "src/test_utils.rs",
+    "src/alg_tests.rs",
+    "tests/**",
 ]
 
 [package.metadata.docs.rs]