[libcode-tidyall-perl] 247/374: add separate Conf test

Jonas Smedegaard js at alioth.debian.org
Sun Sep 29 22:26:29 UTC 2013


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libcode-tidyall-perl.

commit 10aec0c932e78c488b36428d0f723d0803fb5966
Author: Jonathan Swartz <swartz at pobox.com>
Date:   Fri Sep 14 14:48:53 2012 -0400

    add separate Conf test
---
 lib/Code/TidyAll/t/Conf.pm |   50 ++++++++++++++++++++++++++++++++++++++++++++
 t/Conf.t                   |    3 +++
 2 files changed, 53 insertions(+)

diff --git a/lib/Code/TidyAll/t/Conf.pm b/lib/Code/TidyAll/t/Conf.pm
new file mode 100644
index 0000000..5c808b2
--- /dev/null
+++ b/lib/Code/TidyAll/t/Conf.pm
@@ -0,0 +1,50 @@
+package Code::TidyAll::t::Conf;
+use Code::TidyAll;
+use Code::TidyAll::Util qw(dirname tempdir_simple write_file);
+use Test::Class::Most parent => 'Code::TidyAll::Test::Class';
+
+my $conf1;
+
+sub test_conf_file : Tests {
+    my $self      = shift;
+    my $root_dir  = tempdir_simple();
+    my $conf_file = "$root_dir/tidyall.ini";
+    write_file( $conf_file, $conf1 );
+
+    my $ct       = Code::TidyAll->new_from_conf_file($conf_file);
+    my %expected = (
+        backup_ttl      => '5m',
+        backup_ttl_secs => '300',
+        no_backups      => undef,
+        no_cache        => 1,
+        root_dir        => dirname($conf_file),
+        data_dir        => "$root_dir/.tidyall.d",
+        plugins         => {
+            '+Code::TidyAll::Test::Plugin::UpperText' => { select => '**/*.txt' },
+            '+Code::TidyAll::Test::Plugin::RepeatFoo' => { select => '**/foo* **/bar*', times => 3 }
+        }
+    );
+    while ( my ( $method, $value ) = each(%expected) ) {
+        cmp_deeply( $ct->$method, $value, "$method" );
+    }
+
+    my $conf2 = $conf1;
+    $conf2 =~ s/times/timez/;
+    write_file( $conf_file, $conf2 );
+    throws_ok { my $ct = Code::TidyAll->new_from_conf_file($conf_file)->plugin_objects }
+    qr/unknown option 'timez'/;
+
+}
+
+$conf1 = '
+backup_ttl = 5m
+no_cache = 1
+
+[+Code::TidyAll::Test::Plugin::UpperText]
+select = **/*.txt
+
+[+Code::TidyAll::Test::Plugin::RepeatFoo]
+select = **/foo*
+select = **/bar*
+times = 3
+';
diff --git a/t/Conf.t b/t/Conf.t
new file mode 100644
index 0000000..bf79d16
--- /dev/null
+++ b/t/Conf.t
@@ -0,0 +1,3 @@
+#!/usr/bin/perl
+use Code::TidyAll::t::Conf;
+Code::TidyAll::t::Conf->runtests;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcode-tidyall-perl.git



More information about the Pkg-perl-cvs-commits mailing list