summaryrefslogtreecommitdiffstats
path: root/t/Dh_Lib
diff options
context:
space:
mode:
Diffstat (limited to 't/Dh_Lib')
-rwxr-xr-xt/Dh_Lib/00-use.t20
-rwxr-xr-xt/Dh_Lib/control-parsing.t36
-rw-r--r--t/Dh_Lib/debian/changelog5
-rw-r--r--t/Dh_Lib/debian/control19
-rwxr-xr-xt/Dh_Lib/path.t26
5 files changed, 106 insertions, 0 deletions
diff --git a/t/Dh_Lib/00-use.t b/t/Dh_Lib/00-use.t
new file mode 100755
index 0000000..dc8a966
--- /dev/null
+++ b/t/Dh_Lib/00-use.t
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Cwd;
+use Test::More tests => 2;
+
+use File::Temp qw(tempdir);
+use File::Basename qw(dirname);
+use lib dirname(dirname(__FILE__));
+
+my $test_dir = tempdir(CLEANUP => 1);
+
+chdir($test_dir);
+
+# Packages that need to be able to (at least) load without requring
+# d/control or d/compat.
+
+use_ok('Debian::Debhelper::Dh_Lib', '!dirname');
+use_ok('Debian::Debhelper::Buildsystem');
diff --git a/t/Dh_Lib/control-parsing.t b/t/Dh_Lib/control-parsing.t
new file mode 100755
index 0000000..0658256
--- /dev/null
+++ b/t/Dh_Lib/control-parsing.t
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+
+use Cwd qw(abs_path);
+use File::Basename qw(dirname);
+
+BEGIN {
+ my $dir = dirname(abs_path(__FILE__));
+ unshift(@INC, dirname($dir));
+ chdir($dir) or error("chdir($dir) failed: $!");
+};
+
+use Test::DH;
+
+use Debian::Debhelper::Dh_Lib qw(!dirname);
+
+plan(tests => 10);
+
+is_deeply([getpackages()], [qw(foo-any foo-all)], 'packages list correct and in order');
+is_deeply([getpackages('both')], [qw(foo-any foo-all)], 'packages list correct and in order');
+is_deeply([getpackages('arch')], [qw(foo-any)], 'arch:linux-any');
+is_deeply([getpackages('indep')], [qw(foo-all)], 'arch:all');
+
+
+is(package_section('foo-any'), 'devel', 'binary section');
+is(package_section('foo-all'), 'misc', 'binary section (inherit from source)');
+
+
+is(package_declared_arch('foo-any'), 'linux-any', 'binary architecture (linux-any');
+is(package_declared_arch('foo-all'), 'all', 'binary architecture (all)');
+
+ok(! package_is_arch_all('foo-any'), 'foo-any is not arch:all');
+ok(package_is_arch_all('foo-all'), 'foo-all is arch:all');
diff --git a/t/Dh_Lib/debian/changelog b/t/Dh_Lib/debian/changelog
new file mode 100644
index 0000000..5850f0e
--- /dev/null
+++ b/t/Dh_Lib/debian/changelog
@@ -0,0 +1,5 @@
+foo (1.0-1) unstable; urgency=low
+
+ * Initial release. (Closes: #XXXXXX)
+
+ -- Test <testing@nowhere> Mon, 11 Jul 2016 18:10:59 +0200
diff --git a/t/Dh_Lib/debian/control b/t/Dh_Lib/debian/control
new file mode 100644
index 0000000..b1f0aa3
--- /dev/null
+++ b/t/Dh_Lib/debian/control
@@ -0,0 +1,19 @@
+# Comment before the source field
+
+Source: foo
+Section: misc
+Priority: optional
+Maintainer: Test <testing@nowhere>
+Standards-Version: 3.9.8
+
+Package: foo-any
+Section: devel
+Architecture: linux-any
+Description: package foo-any
+ Package foo-any
+
+Package: foo-all
+Architecture: all
+Description: package foo-all
+ Package foo-all
+
diff --git a/t/Dh_Lib/path.t b/t/Dh_Lib/path.t
new file mode 100755
index 0000000..e5f9061
--- /dev/null
+++ b/t/Dh_Lib/path.t
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Test::More;
+
+use Cwd qw(abs_path);
+use File::Basename qw(dirname);
+use File::Temp qw(tempdir);
+
+BEGIN {
+ my $dir = dirname(abs_path(__FILE__));
+ unshift(@INC, dirname($dir));
+ chdir($dir) or error("chdir($dir) failed: $!");
+};
+
+use Test::DH;
+use Debian::Debhelper::Dh_Lib qw(!dirname);
+
+plan(tests => 3);
+
+ok(!is_empty_dir(__FILE__), "is_empty_dir(file) is false");
+ok(!is_empty_dir(dirname(__FILE__)), "is_empty_dir(non-empty) is false");
+
+my $tempdir = tempdir(CLEANUP => 1);
+ok(is_empty_dir($tempdir), "is_empty_dir(new-temp-dir) is true");