summaryrefslogtreecommitdiffstats
path: root/t/debhelper-compat/syntax.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 12:53:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 12:53:53 +0000
commit90169463f86997737ed5b9c0ea2b311cd3b056b7 (patch)
tree281a0f8d9850ea58cf2a3ddb8bf087fb52520925 /t/debhelper-compat/syntax.t
parentInitial commit. (diff)
downloaddebhelper-90169463f86997737ed5b9c0ea2b311cd3b056b7.tar.xz
debhelper-90169463f86997737ed5b9c0ea2b311cd3b056b7.zip
Adding upstream version 13.15.3.upstream/13.15.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/debhelper-compat/syntax.t')
-rwxr-xr-xt/debhelper-compat/syntax.t82
1 files changed, 82 insertions, 0 deletions
diff --git a/t/debhelper-compat/syntax.t b/t/debhelper-compat/syntax.t
new file mode 100755
index 0000000..7fe0307
--- /dev/null
+++ b/t/debhelper-compat/syntax.t
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More;
+
+use File::Basename qw(dirname);
+use File::Temp qw(tempdir);
+use lib dirname(dirname(__FILE__));
+use Test::DH;
+
+use Debian::Debhelper::Dh_Lib qw(!dirname);
+
+my $TEST_DIR = dirname(__FILE__);
+
+sub test_build_depends {
+ my ($level, $build_depends) = @_;
+ my $dir = tempdir(CLEANUP => 1);
+ if (not mkdir("$dir/debian", 0777)) {
+ error("mkdir $dir/debian failed: $!");
+ }
+ open my $in, '<', "$TEST_DIR/debian/control" or
+ error("open $TEST_DIR/debian/control failed: $!");
+ open my $out, '>', "$dir/debian/control" or
+ error("open $dir/debian/control failed: $!");
+ while (<$in>) {
+ s/BUILD_DEPENDS/$build_depends/;
+ print $out $_ or
+ error("write to $dir/debian/control failed: $!");
+ }
+ close($out) or
+ error("close $dir/debian/control failed: $!");
+ close($in);
+
+ my $start_dir = Test::DH::getcwd();
+ chdir($dir) or error("chdir($dir): $!");
+
+ plan(tests => 5);
+
+ local $ENV{DH_INTERNAL_TESTSUITE_SILENT_WARNINGS} = 1;
+ Debian::Debhelper::Dh_Lib::resetpackages;
+ Debian::Debhelper::Dh_Lib::resetcompat;
+ my @pkgs = getpackages;
+ ok(scalar @pkgs == 1);
+ ok($pkgs[0] eq 'foo');
+
+ ok(compat($level));
+ ok(compat($level + 1));
+ ok(!compat($level - 1));
+
+ chdir($start_dir) or
+ error("chdir($start_dir): $!");
+}
+
+my @levels = non_deprecated_compat_levels;
+plan(tests => scalar @levels);
+
+for my $level (@levels) {
+ subtest "compat $level" => sub {
+ plan(tests => 7);
+ subtest 'only' => sub {
+ test_build_depends($level, "debhelper-compat (= $level)");
+ };
+ subtest 'first' => sub {
+ test_build_depends($level, "debhelper-compat (= $level), bar");
+ };
+ subtest 'second' => sub {
+ test_build_depends($level, "bar, debhelper-compat (= $level)");
+ };
+ subtest 'first-nl' => sub {
+ test_build_depends($level, "debhelper-compat (= $level),\n bar");
+ };
+ subtest 'second-nl' => sub {
+ test_build_depends($level, "bar,\n debhelper-compat (= $level)");
+ };
+ subtest 'nl-first' => sub {
+ test_build_depends($level, "\n debhelper-compat (= $level),\n bar");
+ };
+ subtest 'nl-second' => sub {
+ test_build_depends($level, "\n bar,\n debhelper-compat (= $level)");
+ };
+ };
+}