diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-19 17:51:19 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-19 18:19:33 +0300 |
commit | 11e6beb1f44fb74dc11e79c3bda25aebfd80ae12 (patch) | |
tree | bef1bfcecd9ad587c582a79a8dac78ca5f7569b7 /t/TestConfig.pm | |
parent | d417ed4a1875321b28c47ea5f6324479d1592309 (diff) | |
download | config-parser-11e6beb1f44fb74dc11e79c3bda25aebfd80ae12.tar.gz config-parser-11e6beb1f44fb74dc11e79c3bda25aebfd80ae12.tar.bz2 |
Improve constructor
This commit introduces the "mangle" method, which can be implemented
by the caller in order to run any additional tree modifications after
a successful parse and commit (see the new testcase for an example).
* lib/Config/Parser.pm (new): Call the init method if lexicon
hash has been loaded.
(init,inited,commit): New methods.
* t/ConfigSpec3.pm: New file.
* t/TestConfig.pm: Don't attempt to load empty files.
* t/conf08.t: New file.
Diffstat (limited to 't/TestConfig.pm')
-rw-r--r-- | t/TestConfig.pm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/t/TestConfig.pm b/t/TestConfig.pm index bd4f3f5..08f5bae 100644 --- a/t/TestConfig.pm +++ b/t/TestConfig.pm @@ -47,9 +47,12 @@ sub new { # FIXME: Filter out fh and line keywords? my $self = $class->SUPER::new(%_); $self->{_expected_errors} = $exp if $exp; - $self->parse($file->filename); - $self->{_status} = $self->commit; - + if (-s $file->filename) { + $self->parse($file->filename); + $self->{_status} = $self->commit; + } else { + $self->{_status} = 1; + } if ($exp && @{$self->{_expected_errors}}) { $self->{_status} = 0; $self->error("not all expected errors reported"); |