mirror of
https://codeberg.org/scip/Config-General.git
synced 2025-12-16 20:21:01 +01:00
2.28
- fixed bug in save(), now blocks containing whitespaces will be saved using quotes, in addition the parser observes the quoting feature, added portion about this to the pod doc. pointed out by Jeff Murphy <jcmurphy@jeffmurphy.org>. - added internal list of files opened so far to avoid reading in the same file multiple times. Suggested by Michael Graham. - added new method files() which returns the above list. - added workaround for foolish perl installation on debian systems (croak() doesn't work anymore as of 5.8.4, it's a shame!) - applied patch by Michael Graham which fixes IncludeRelative feature, now an included file is being included relative to the calling config file, not the first one. - added 'make test' targets for files() and include stuff. (by Michael too) git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@54 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
2
t/cfg.20.b
Normal file
2
t/cfg.20.b
Normal file
@@ -0,0 +1,2 @@
|
||||
seen_cfg.20.b = true
|
||||
<<include t/cfg.20.c>>
|
||||
2
t/cfg.20.c
Normal file
2
t/cfg.20.c
Normal file
@@ -0,0 +1,2 @@
|
||||
seen_cfg.20.c = true
|
||||
last = cfg.20.c
|
||||
83
t/run.t
83
t/run.t
@@ -6,7 +6,7 @@
|
||||
#
|
||||
# Under normal circumstances every test should succeed.
|
||||
|
||||
BEGIN { $| = 1; print "1..19\n";}
|
||||
BEGIN { $| = 1; print "1..22\n";}
|
||||
use lib "blib/lib";
|
||||
use Config::General;
|
||||
use Data::Dumper;
|
||||
@@ -194,6 +194,87 @@ else {
|
||||
pause;
|
||||
|
||||
|
||||
# testing files() method
|
||||
my $conf20 = Config::General->new(
|
||||
-file => "t/cfg.20.a",
|
||||
-MergeDuplicateOptions => 1
|
||||
);
|
||||
my %h20 = $conf20->getall();
|
||||
|
||||
my %expected_h20 = (
|
||||
'seen_cfg.20.a' => 'true',
|
||||
'seen_cfg.20.b' => 'true',
|
||||
'seen_cfg.20.c' => 'true',
|
||||
'last' => 'cfg.20.c',
|
||||
);
|
||||
|
||||
my %files = map { $_ => 1 } $conf20->files();
|
||||
|
||||
my %expected_files = map { $_ => 1 } (
|
||||
't/cfg.20.a',
|
||||
't/cfg.20.b',
|
||||
't/cfg.20.c',
|
||||
);
|
||||
|
||||
if (&comp(\%h20, \%expected_h20) and &comp(\%files, \%expected_files)) {
|
||||
print "ok\n";
|
||||
print STDERR " .. ok # testing files() method\n";
|
||||
}
|
||||
else {
|
||||
print "20 not ok\n";
|
||||
print STDERR "20 not ok\n";
|
||||
}
|
||||
pause;
|
||||
|
||||
# testing improved IncludeRelative option
|
||||
|
||||
# First try without -IncludeRelative
|
||||
# this should fail
|
||||
eval {
|
||||
my $conf21 = Config::General->new(
|
||||
-file => "t/sub1/sub2/sub3/cfg.sub3",
|
||||
-MergeDuplicateOptions => 1,
|
||||
);
|
||||
};
|
||||
if ($@) {
|
||||
print "ok\n";
|
||||
print STDERR " .. ok # prevented from loading relative cfgs without -IncludeRelative\n";
|
||||
}
|
||||
else {
|
||||
print "21 not ok\n";
|
||||
print STDERR "21 not ok\n";
|
||||
}
|
||||
pause;
|
||||
|
||||
# Now try with -IncludeRelative
|
||||
# this should fail
|
||||
|
||||
my $conf22 = Config::General->new(
|
||||
-file => "t/sub1/sub2/sub3/cfg.sub3",
|
||||
-MergeDuplicateOptions => 1,
|
||||
-IncludeRelative => 1,
|
||||
);
|
||||
|
||||
my %h22 = $conf22->getall;
|
||||
my %expected_h22 = (
|
||||
'sub3_seen' => 'yup',
|
||||
'sub2_seen' => 'yup',
|
||||
'sub1_seen' => 'yup',
|
||||
'fruit' => 'mango',
|
||||
);
|
||||
|
||||
if (&comp(\%h22, \%expected_h22)) {
|
||||
print "ok\n";
|
||||
print STDERR " .. ok # loaded relative to included files\n";
|
||||
}
|
||||
else {
|
||||
print "22 not ok\n";
|
||||
print STDERR "22 not ok\n";
|
||||
}
|
||||
pause;
|
||||
|
||||
|
||||
|
||||
|
||||
# all subs here
|
||||
|
||||
|
||||
3
t/sub1/cfg.sub1
Normal file
3
t/sub1/cfg.sub1
Normal file
@@ -0,0 +1,3 @@
|
||||
fruit = mango
|
||||
sub3_seen = yup
|
||||
|
||||
4
t/sub1/sub2/cfg.sub2
Normal file
4
t/sub1/sub2/cfg.sub2
Normal file
@@ -0,0 +1,4 @@
|
||||
fruit = pear
|
||||
sub2_seen = yup
|
||||
|
||||
<<include ../cfg.sub1>>
|
||||
5
t/sub1/sub2/sub3/cfg.sub3
Normal file
5
t/sub1/sub2/sub3/cfg.sub3
Normal file
@@ -0,0 +1,5 @@
|
||||
fruit = apple
|
||||
sub3_seen = yup
|
||||
|
||||
<<include ../cfg.sub2>>
|
||||
|
||||
Reference in New Issue
Block a user