Control: tag 949959 + patch

On Mon 2020-01-27 11:55:28 -0500, Daniel Kahn Gillmor wrote:
> So it would be good to be able to indicate in debcargo.toml some
> additional autopkgtest dependencies.
>
> Simplest might be to add a dependency for *all* generated autopkgtests,
> but i can imagine there are some subtler requirements which will need to
> be for specific autopkgtests in the future.

Wolfgang created this patch (on the dev/debian_949959 branch in salsa)
to implement this mechanism.

It looks reasonable to me, and it compiles fine.  I'm in the process of
testing it now.

   --dkg

From 9a250f348f31294ccdc11eb629a2b53341ef6814 Mon Sep 17 00:00:00 2001
From: Wolfgang Silbermayr <wolfg...@silbermayr.at>
Date: Tue, 28 Jan 2020 12:50:59 +0100
Subject: [PATCH] Implement extra_test_deps config option at top level

Add an extra_test_deps to top level of debcargo.toml where autopkgtest
dependencies can be added. A first simple implementation of this feature
for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=949959

Might be extended later by adding the same field to the [packages.lib*]
entries if dependencies are required by some tests only, but must not be
present on others.
---
 debcargo.toml.example |  3 +++
 src/config.rs         |  2 ++
 src/debian/mod.rs     | 10 ++++++++--
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/debcargo.toml.example b/debcargo.toml.example
index b463f1d..74658ab 100644
--- a/debcargo.toml.example
+++ b/debcargo.toml.example
@@ -45,6 +45,9 @@
 # exceptional cases where the method gives a false-positive, add them here.
 #whitelist = ["libgit2/**"]
 
+# Additional dependencies for the autopkgtests. Gets added to all tests.
+#extra_test_deps = ["llvm", "clang"]
+
 # Whether to allow prerelease deps, by rewriting these to the released version.
 # This should only be enabled for certain crates if really necessary, and first
 # you should check that they can actually build when this is enabled.
diff --git a/src/config.rs b/src/config.rs
index d0d8583..43a9a89 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -18,6 +18,7 @@ pub struct Config {
     pub overlay: Option<PathBuf>,
     pub excludes: Option<Vec<String>>,
     pub whitelist: Option<Vec<String>>,
+    pub extra_test_deps: Option<Vec<String>>,
     pub allow_prerelease_deps: bool,
     pub summary: String,
     pub description: String,
@@ -61,6 +62,7 @@ impl Default for Config {
             overlay: None,
             excludes: None,
             whitelist: None,
+            extra_test_deps: None,
             allow_prerelease_deps: false,
             summary: "".to_string(),
             description: "".to_string(),
diff --git a/src/debian/mod.rs b/src/debian/mod.rs
index 7969ee8..a06b522 100644
--- a/src/debian/mod.rs
+++ b/src/debian/mod.rs
@@ -503,6 +503,12 @@ pub fn prepare_debian_folder(
         };
 
         if lib {
+            let mut test_depends = dev_depends.clone();
+            if let Some(ref extra) = config.extra_test_deps {
+                test_depends.extend(extra.clone());
+                test_depends.sort();
+                test_depends.dedup();
+            }
             // debian/tests/control
             let mut testctl = io::BufWriter::new(file("tests/control")?);
             write!(
@@ -513,7 +519,7 @@ pub fn prepare_debian_folder(
                     &crate_name,
                     &crate_version,
                     vec!["--all-features"],
-                    &dev_depends,
+                    &test_depends,
                     if all_features_test_broken {
                         vec!["flaky"]
                     } else {
@@ -576,7 +582,7 @@ pub fn prepare_debian_folder(
                     } else {
                         vec!["--features", feature]
                     },
-                    &dev_depends,
+                    &test_depends,
                     if test_is_broken {
                         vec!["flaky"]
                     } else {
-- 
2.24.1

Attachment: signature.asc
Description: PGP signature

Reply via email to