summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominique Dumont <dod@debian.org>2022-01-14 18:22:04 +0100
committerDominique Dumont <dod@debian.org>2022-01-15 17:40:58 +0100
commitab2bbfeb88a0ebe5e49b02a512fa989f3cc53ee8 (patch)
tree2c492aba05cbfe6b9110f169598cad6eae38fcdc
parent953d63a74b2d921028aef835f06936751bf37b2b (diff)
add test for bump-dependency-version script
-rw-r--r--t/cme-scripts.t82
-rw-r--r--t/examples/config-model-systemd/control22
-rw-r--r--t/model_tests.d/dependency-cache.txt1
3 files changed, 105 insertions, 0 deletions
diff --git a/t/cme-scripts.t b/t/cme-scripts.t
new file mode 100644
index 00000000..2b3d7215
--- /dev/null
+++ b/t/cme-scripts.t
@@ -0,0 +1,82 @@
+# -*- cperl -*-
+use strict;
+use warnings;
+use utf8;
+use 5.10.1;
+use open ':std', ':encoding(utf8)';
+
+use Encode;
+
+use Path::Tiny;
+use Term::ANSIColor 2.01 qw(colorstrip);
+
+use Test::More;
+use Test::File::Contents;
+
+BEGIN {
+ # dirty trick to create a Memoize cache so that test will use this instead
+ # of getting values through the internet
+ no warnings 'once';
+ %Config::Model::Dpkg::Dependency::cache = (
+ 'libconfig-model-perl' => 'squeeze 1.205-1 wheezy 1.244-1 sid 1.247-1',
+ 'libconfig-model-tester-perl' => 'squeeze 1.205-1 wheezy 1.244-1 sid 1.247-1',
+ );
+ my $t = time ;
+ do { $_ = "$t $_"} for grep {defined $_} values %Config::Model::Dpkg::Dependency::cache ;
+
+ $Config::Model::Dpkg::Dependency::use_test_cache = 1;
+}
+
+use App::Cmd::Tester;
+use App::Cme ;
+use Config::Model qw/initialize_log4perl/;
+use Config::Model::Dpkg::Dependency;
+
+
+# work around a problem in IO::TieCombine (used by App::Cmd::Tester)
+# to avoid messing up output of stderr of tested command (See
+# ACHTUNG!! notes in IO::TieCombine doc)
+$\ = '';
+
+my $arg = shift || '';
+my ( $log, $show ) = (0) x 2;
+
+my $trace = $arg =~ /t/ ? 1 : 0;
+
+Config::Model::Exception::Any->Trace(1) if $arg =~ /e/;
+
+## testing exit status
+
+# pseudo root where config files are written by config-model
+my $wr_root = path('wr_root/cme-scripts');
+
+# cleanup before tests
+$wr_root -> remove_tree;
+
+subtest "bump_dependency" => sub {
+ my $work_dir = $wr_root->child("bump_dep_1");
+ my $debian_dir = $work_dir->child("debian");
+ $debian_dir->mkpath({mode => oct(755)});
+ my $script = path("lib/Config/Model/scripts/bump-dependency-version")->absolute;
+
+ # put control data in place
+ my $control_file = $debian_dir->child("control");
+ path('t/examples/config-model-systemd/control')->copy($control_file);
+ chdir $work_dir->stringify;
+
+ my @test_cmd = (
+ run => $script->stringify,
+ qw/--no-commit -arg pkg=libconfig-model-perl -arg version=3.456/
+ );
+ my $ok = test_app( 'App::Cme' => \@test_cmd );
+
+ is( $ok->exit_code, 0, 'all went well' ) or diag("Failed command @test_cmd: ", $ok->error);
+ my $regexp = qr/libconfig-model-perl \(>= 3.456\) <!nocheck>/;
+ like($ok->stderr.'', $regexp, 'check changes on stderr' );
+ is($ok->stdout.'', '', 'check: no message on stdout' );
+
+ file_contents_like 'debian/control', $regexp, "updated dependency in file";
+};
+
+done_testing;
+
diff --git a/t/examples/config-model-systemd/control b/t/examples/config-model-systemd/control
new file mode 100644
index 00000000..be79b023
--- /dev/null
+++ b/t/examples/config-model-systemd/control
@@ -0,0 +1,22 @@
+Source: libconfig-model-systemd-perl
+Maintainer: Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org>
+Uploaders: Dominique Dumont <dod@debian.org>
+Section: perl
+Testsuite: autopkgtest-pkg-perl
+Priority: optional
+Build-Depends-Indep: libconfig-model-perl (>= 2.143) <!nocheck>,
+ libconfig-model-tester-perl (>= 4.007) <!nocheck>,
+Standards-Version: 4.6.0
+Vcs-Browser: https://salsa.debian.org/perl-team/modules/packages/libconfig-model-systemd-perl
+Vcs-Git: https://salsa.debian.org/perl-team/modules/packages/libconfig-model-systemd-perl.git
+Homepage: https://metacpan.org/release/Config-Model-Systemd
+Rules-Requires-Root: no
+
+Package: libconfig-model-systemd-perl
+Architecture: all
+Depends: ${misc:Depends},
+ ${perl:Depends},
+ libconfig-model-perl (>= 2.143),
+Description: editor and validator for systemd configuration files
+ Config::Model::Systemd provides a configuration editor for the
+ [yada yada...] \ No newline at end of file
diff --git a/t/model_tests.d/dependency-cache.txt b/t/model_tests.d/dependency-cache.txt
index f34eeca7..b53f5b98 100644
--- a/t/model_tests.d/dependency-cache.txt
+++ b/t/model_tests.d/dependency-cache.txt
@@ -101,6 +101,7 @@ libtest-pod-perl => etch 1.24-1 lenny 1.26-2 squeeze 1.42-1 wheezy 1.44-1 sid 1.
libtest-simple-perl => etch 0.62-1 lenny 0.80-1 backports/lenny 0.94-1~bpo50+1 squeeze 0.94-1 wheezy 0.98-1 sid 0.98-1
libtiff4 => lenny-security 3.8.2-11.5 lenny 3.8.2-11.5 squeeze-security 3.9.4-5+squeeze3 squeeze 3.9.4-5+squeeze3 wheezy 3.9.6-1 sid 3.9.6-1
libtry-tiny-perl => oldoldstable 0.11-1 wheezy-backports 0.20-1~bpo70+1 oldstable 0.22-1 oldstable-kfreebsd 0.22-1 unstable 0.28-1 testing 0.28-1 stable 0.28-1
+libuv0.10-dev => oldoldoldstable 0.10.28-6
libversion-perl => etch 0.6701-1 squeeze 1:0.8200-1 wheezy 1:0.9000-1 sid 1:0.9000-1
libwx-perl => squeeze 0.9702-1 wheezy 1:0.9904-1 sid 1:0.9904-1
libx11-dev => etch 2:1.0.3-7 lenny 2:1.1.5-2 squeeze 2:1.3.3-4 wheezy 2:1.4.1-5 sid 2:1.4.1-5