App-Cme
view release on metacpan or search on metacpan
(require Config::Model 2.068)
* remove debug call to YYY
1.002 2015-01-10
* gen-class-pod:
* fix doc and missing command arguments
* update:
+ added -edit option to run editor after an update
* fix typo in pod doc
* dist.ini: updated © to 2015
1.001 2014-11-29
* require Config::Model 2.063 (to avoid bash_completion clash)
* improved messages printed by update command
* added 'gen-class-pod' alias for gen_class_pod
* bash_completion:
+ added help version commands update in hard-coded list of commands
* fixed syntax error
lib/App/Cme/Command/run.pm view on Meta::CPAN
See L<cme/"Global Options">.
=head1 Examples
=head2 update copyright years in C<debian/copyright>
$ cme run update-copyright -cat
app: dpkg-copyright
load: Files:~ Copyright=~"s/2016,?\s+$name/2017, $name/g"
commit: updated copyright year of $name
$ cme run update-copyright -arg "name=Dominique Dumont"
cme: using Dpkg::Copyright model
Changes applied to dpkg-copyright configuration:
- Files:"*" Copyright: '2005-2016, Dominique Dumont <dod@debian.org>' -> '2005-2017, Dominique Dumont <dod@debian.org>'
- Files:"lib/Dpkg/Copyright/Scanner.pm" Copyright:
@@ -1,2 +1,2 @@
-2014-2016, Dominique Dumont <dod@debian.org>
+2014-2017, Dominique Dumont <dod@debian.org>
2005-2012, Jonas Smedegaard <dr@jones.dk>
[master ac2e6410] updated copyright year of Dominique Dumont
1 file changed, 2 insertions(+), 2 deletions(-)
=head2 update VcsGit in debian/control
$ cme run set-vcs-git -cat
doc: update control Vcs-Browser and Vcs-git from git remote value
doc: parameters: remote (default is origin)
doc:
doc: example:
doc: cme run set-vcs-git
t/cme-command.t view on Meta::CPAN
subtest "minimal modification" => sub {
$conf_file->spew_utf8(@orig);
# test minimal modif (re-order)
my @test_cmd = (qw/modify popcon -save -backup -canonical -root-dir/, $wr_dir->stringify);
my $ok = test_app( 'App::Cme' => \@test_cmd );
is ($ok->exit_code, 0, 'all went well' ) or diag("Failed command cme @test_cmd");
is($ok->error, undef, 'threw no exceptions');
is($ok->stderr.'', '', 'modify: no log on stderr' );
is($ok->stdout.'', '', 'modify: no message on stdout' );
file_contents_like $conf_file->stringify, qr/cme/, "updated header";
# with perl 5.14 5.16, IO::Handle writes an extra \n with print.
my $re = $^V lt 5.18.1 ? qr/yes"\n+MY/ : qr/yes"\nMY/;
file_contents_like $conf_file->stringify, $re, "reordered file";
file_contents_unlike $conf_file->stringify, qr/removed/, "double comment is removed";
# check backup
ok($backup_file->is_file, "backup file was created");
file_contents_like $backup_file->stringify, qr/should be removed/, "backup file contains original comment";
};
t/cme-command.t view on Meta::CPAN
};
subtest "modification with good parameter" => sub {
$conf_file->spew_utf8(@orig);
# use -save to force a file save to update file header
my @test_cmd = (qw/modify popcon -save -root-dir/, $wr_dir->stringify, qq/PARTICIPATE=yes/);
my $ok = test_app( 'App::Cme' => \@test_cmd );
is( $ok->exit_code, 0, 'all went well' ) or diag("Failed command @test_cmd");
is($ok->stderr.'', '', 'modify: no log on stderr' );
is($ok->stdout.'', '', 'modify: no message on stdout' );
file_contents_like $conf_file->stringify, qr/cme/, "updated header";
file_contents_unlike $conf_file->stringify, qr/removed`/, "double comment is removed";
};
subtest "modification with verbose option" => sub {
$conf_file->spew_utf8(@orig);
my @test_cmd = (qw/modify popcon -verbose -root-dir/, $wr_dir->stringify, qq/PARTICIPATE=yes/);
my $ok = test_app( 'App::Cme' => \@test_cmd );
is ($ok->exit_code, 0, 'no error detected' ) or diag("Failed command @test_cmd");
is(colorstrip($ok->stderr), qq!command 'PARTICIPATE=yes': Setting leaf 'PARTICIPATE' boolean to 'yes'.\n!,
'check log content' );
t/cme-command.t view on Meta::CPAN
subtest "modification with utf8 parameter" => sub {
$conf_file->spew_utf8(@orig);
my $utf8_name = "héhoÌÃÅ";
my @test_cmd = ((qw/modify popcon -root-dir/, $wr_dir->stringify),
encode('UTF-8',qq/MY_HOSTID="$utf8_name"/) );
my $ok = test_app( 'App::Cme' => \@test_cmd );
is( $ok->error, undef, 'threw no exceptions');
is( $ok->exit_code, 0, 'all went well' ) or diag("Failed command @test_cmd");
file_contents_like $conf_file->stringify, qr/$utf8_name/,
"updated MY_HOSTID with weird utf8 hostname" ,{ encoding => 'UTF-8' };
};
my $expect_namefoobar = << 'EOF';
Changes applied to popcon configuration:
- MY_HOSTID: 'aaaaaaaaaaaaaaaaaaaa' -> '$namefoobar'
EOF
my @script_tests = (
{
t/cme-command.t view on Meta::CPAN
run => $script->stringify,
'-root-dir' => $wr_dir->stringify,
@{$test->{args} // []}
];
note("cme command: cme @$cmd");
my $ok = test_app('App::Cme' => $cmd);
is( $ok->error, undef, 'threw no exceptions');
is( $ok->exit_code, 0, "all went well" ) or diag("Failed command: @$cmd");
file_contents_like $conf_file->stringify, $test->{test},
"updated MY_HOSTID with script" ,{ encoding => 'UTF-8' };
is(colorstrip($ok->stderr), $test->{stderr} || '', 'run "'.$test->{label}.'" stderr content' );
is(colorstrip($ok->stdout.''), $test->{stdout} || '', 'run "'.$test->{label}.'": stdout content' );
};
}
# test failure case for run script
my @bad_script_tests = (
{
label => "line ".__LINE__.": missing app",
script => [ 'load ! MY_HOSTID=dontcare'],
( run in 0.298 second using v1.01-cache-2.11-cpan-05444aca049 )