Testsuite: Assume '' for missing VERSION_ID
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sat, 12 Nov 2016 21:48:37 +0000 (22:48 +0100)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Sat, 12 Nov 2016 21:49:11 +0000 (22:49 +0100)
test/lib/Exim/Runtest.pm
test/t/00-basic.t
test/t/samples/debian.sid/etc/os-release [new file with mode: 0644]
test/t/samples/debian8+debian-version/etc/debian_version [new file with mode: 0644]
test/t/samples/debian8+os-release/etc/debian_version [new file with mode: 0644]
test/t/samples/debian8+os-release/etc/os-release [new file with mode: 0644]
test/t/samples/etc.debian8-debian-version/debian_version [deleted file]
test/t/samples/etc.debian8-os-release/debian_version [deleted file]
test/t/samples/etc.debian8-os-release/os-release [deleted file]
test/t/samples/etc.fedora24/os-release [deleted file]
test/t/samples/fedora24/etc/os-release [new file with mode: 0644]

index 32537f5432fa8788db1bea2b9a2b104390c28af1..ce91084f40b9d42a9d3ecc4e125c4e70ea2c4218 100644 (file)
@@ -119,7 +119,7 @@ sub flavour {
     if (open(my $f, '<', "$etc/os-release")) {
         local $_ = join '', <$f>;
         my ($id) = /^ID="?(.*?)"?\s*$/m;
-        my ($version) = /^VERSION_ID="?(.*?)"?\s*$/m;
+        my $version = /^VERSION_ID="?(.*?)"?\s*$/m ? $1 : '';
         return "$id$version";
     }
 
index 49d6f68718ee416cce714473df005c24fa55b360..092591e442b7d5be9f5561a3018a1e28dadccdea 100644 (file)
@@ -40,9 +40,10 @@ subtest 'exim_binary' => sub {
 };
 
 subtest 'flavour' => sub {
-    is flavour('t/samples/etc.debian8-os-release'), 'debian8' => 'got flavour debian8 from os-release';
-    is flavour('t/samples/etc.debian8-debian-version'), 'debian8' => 'got flavour debian8 from debian_version';
-    is flavour('t/samples/etc.fedora24'), 'fedora24' => 'got flavour fedora24 from os-release';
+    is flavour('t/samples/debian8+os-release/etc'), 'debian8' => 'got flavour debian8 from os-release';
+    is flavour('t/samples/debian8+debian-version/etc'), 'debian8' => 'got flavour debian8 from debian_version';
+    is flavour('t/samples/debian.sid/etc'), 'debian' => 'got flavour debian from debian sid w/o VERSION_ID';
+    is flavour('t/samples/fedora24/etc'), 'fedora24' => 'got flavour fedora24 from os-release';
     is_deeply [flavours()], ['debian8'] => 'got available flavours';
 };
 
diff --git a/test/t/samples/debian.sid/etc/os-release b/test/t/samples/debian.sid/etc/os-release
new file mode 100644 (file)
index 0000000..959aa16
--- /dev/null
@@ -0,0 +1,6 @@
+PRETTY_NAME="Debian GNU/Linux stretch/sid"
+NAME="Debian GNU/Linux"
+ID=debian
+HOME_URL="https://www.debian.org/"
+SUPPORT_URL="https://www.debian.org/support"
+BUG_REPORT_URL="https://bugs.debian.org/"
diff --git a/test/t/samples/debian8+debian-version/etc/debian_version b/test/t/samples/debian8+debian-version/etc/debian_version
new file mode 100644 (file)
index 0000000..48c26da
--- /dev/null
@@ -0,0 +1 @@
+8.6
diff --git a/test/t/samples/debian8+os-release/etc/debian_version b/test/t/samples/debian8+os-release/etc/debian_version
new file mode 100644 (file)
index 0000000..48c26da
--- /dev/null
@@ -0,0 +1 @@
+8.6
diff --git a/test/t/samples/debian8+os-release/etc/os-release b/test/t/samples/debian8+os-release/etc/os-release
new file mode 100644 (file)
index 0000000..120c51b
--- /dev/null
@@ -0,0 +1,8 @@
+PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
+NAME="Debian GNU/Linux"
+VERSION_ID="8"
+VERSION="8 (jessie)"
+ID=debian
+HOME_URL="http://www.debian.org/"
+SUPPORT_URL="http://www.debian.org/support"
+BUG_REPORT_URL="https://bugs.debian.org/"
diff --git a/test/t/samples/etc.debian8-debian-version/debian_version b/test/t/samples/etc.debian8-debian-version/debian_version
deleted file mode 100644 (file)
index 48c26da..0000000
+++ /dev/null
@@ -1 +0,0 @@
-8.6
diff --git a/test/t/samples/etc.debian8-os-release/debian_version b/test/t/samples/etc.debian8-os-release/debian_version
deleted file mode 100644 (file)
index 48c26da..0000000
+++ /dev/null
@@ -1 +0,0 @@
-8.6
diff --git a/test/t/samples/etc.debian8-os-release/os-release b/test/t/samples/etc.debian8-os-release/os-release
deleted file mode 100644 (file)
index 120c51b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
-NAME="Debian GNU/Linux"
-VERSION_ID="8"
-VERSION="8 (jessie)"
-ID=debian
-HOME_URL="http://www.debian.org/"
-SUPPORT_URL="http://www.debian.org/support"
-BUG_REPORT_URL="https://bugs.debian.org/"
diff --git a/test/t/samples/etc.fedora24/os-release b/test/t/samples/etc.fedora24/os-release
deleted file mode 100644 (file)
index f962ae6..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-NAME=Fedora
-VERSION="24 (Twenty Four)"
-ID=fedora
-VERSION_ID=24
-PRETTY_NAME="Fedora 24 (Twenty Four)"
-ANSI_COLOR="0;34"
-CPE_NAME="cpe:/o:fedoraproject:fedora:24"
-HOME_URL="https://fedoraproject.org/"
-BUG_REPORT_URL="https://bugzilla.redhat.com/"
-REDHAT_BUGZILLA_PRODUCT="Fedora"
-REDHAT_BUGZILLA_PRODUCT_VERSION=24
-REDHAT_SUPPORT_PRODUCT="Fedora"
-REDHAT_SUPPORT_PRODUCT_VERSION=24
-PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy
diff --git a/test/t/samples/fedora24/etc/os-release b/test/t/samples/fedora24/etc/os-release
new file mode 100644 (file)
index 0000000..f962ae6
--- /dev/null
@@ -0,0 +1,14 @@
+NAME=Fedora
+VERSION="24 (Twenty Four)"
+ID=fedora
+VERSION_ID=24
+PRETTY_NAME="Fedora 24 (Twenty Four)"
+ANSI_COLOR="0;34"
+CPE_NAME="cpe:/o:fedoraproject:fedora:24"
+HOME_URL="https://fedoraproject.org/"
+BUG_REPORT_URL="https://bugzilla.redhat.com/"
+REDHAT_BUGZILLA_PRODUCT="Fedora"
+REDHAT_BUGZILLA_PRODUCT_VERSION=24
+REDHAT_SUPPORT_PRODUCT="Fedora"
+REDHAT_SUPPORT_PRODUCT_VERSION=24
+PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy