Skip Menu |
 

This queue is for tickets about the AppConfig CPAN distribution.

Report information
The Basics
Id: 66451
Status: new
Priority: 0/
Queue: AppConfig

People
Owner: Nobody in particular
Requestors: bronto [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.56
Fixed in: (no value)



Subject: file() and args() method non equivalent
Download (untitled) / with headers
text/plain 1.1k
I am using AppConfig 1.56, which is the default that ships with Ubuntu 10.04.2. I am filing this bug since I found no evidence in the changelog that this has been fixed already. Basically, AppConfig doesn't behave the same way if variables are set the same values on the command line or in a configuration file. If I define three scalar variables named alpha, beta and gamma, and I define an unknown variable called delta before them, I expect the parser to return the same values, both if I use a config file like: delta = D alpha = A beta = B gamma = G and using the command line: ./script.pl -delta D -alpha A -beta B -gamma G I compared the results when setting/unsetting CREATE and PEDANTIC, and they are different indeed, with 18 different values out of 24. I am attaching three files to show this; - appconfig-test.t: compares expected values with actual values; - test.conf: test configuration - appconfig-file.t: just dumps the expected values that are then used in appconfig-test.t; uses Test::More because it has been derived from appconfig-test.t, but doesn't any real use of it. Is this behaviour intentional? Kind Regards --bronto
Subject: test.conf
Download test.conf
application/octet-stream 40b

Message body not shown because it is not plain text.

Subject: appconfig-test.t
Download appconfig-test.t
text/x-perl 1.4k
#!/usr/bin/perl use strict ; use warnings ; use Test::More ; use AppConfig qw{:expand :argcount} ; my @args = [ qw{-delta D -alpha A -beta B -gamma G} ] ; my %ACbase = ( CASE => 1, GLOBAL => { ARGCOUNT => ARGCOUNT_ONE, }, ) ; my $regex = q{^[a-z_]} ; my @variables = qw{alpha beta gamma} ; my $extravar = q{delta} ; my @tests = ( {}, [qw{A B G}], {PEDANTIC => 0}, [qw{A B G}], {PEDANTIC => 1}, [], {CREATE => $regex}, [qw{A B G D}], {CREATE => $regex,PEDANTIC => 0}, [qw{A B G D}], {CREATE => $regex,PEDANTIC => 1}, [qw{A B G D}], ) ; while ( my ($parms,$expected_results) = splice(@tests,0,2) ) { my %ACparms = ( %ACbase, %$parms ) ; my $create_status = exists $parms->{CREATE}? "CREATE is set to ".$parms->{CREATE} : "CREATE is not set" ; my $pedantic_status = exists $parms->{PEDANTIC}? "PEDANTIC is set to ".$parms->{PEDANTIC}: "PEDANTIC is not set" ; diag($create_status) ; diag($pedantic_status) ; my $c = AppConfig->new(\%ACparms,@variables) ; my $ret = $c->args( [@args] ) ; diag(qq{Parser returned $ret}) ; my $varindex = 0 ; foreach my $varname (@variables,$extravar) { my $parsed_value = $c->get($varname) ; my $expected_value = $expected_results->[$varindex++] ; is($parsed_value,$expected_value,qq{Comparing $varname}) ; } } done_testing() ;
Trying to add a missing file
Subject: appconfig-file.t
Download appconfig-file.t
text/x-perl 1.1k
#!/usr/bin/perl use strict ; use warnings ; use Test::More ; use AppConfig qw{:expand :argcount} ; my @args = [ qw{-delta D -alpha A -beta B -gamma G} ] ; my %ACbase = ( CASE => 1, GLOBAL => { ARGCOUNT => ARGCOUNT_ONE, }, ) ; my $regex = q{^[a-z_]} ; my @variables = qw{alpha beta gamma} ; my $extravar = q{delta} ; my @tests = ( {}, {PEDANTIC => 0}, {PEDANTIC => 1}, {CREATE => $regex}, {CREATE => $regex,PEDANTIC => 0}, {CREATE => $regex,PEDANTIC => 1}, ) ; while ( my $parms = shift @tests ) { my %ACparms = ( %ACbase, %$parms ) ; my $create_status = exists $parms->{CREATE}? "CREATE is set to ".$parms->{CREATE} : "CREATE is not set" ; my $pedantic_status = exists $parms->{PEDANTIC}? "PEDANTIC is set to ".$parms->{PEDANTIC}: "PEDANTIC is not set" ; diag($create_status) ; diag($pedantic_status) ; my $c = AppConfig->new(\%ACparms,@variables) ; my $ret = $c->file(q{test.conf}) ; diag(qq{Parser returned $ret}) ; my @parsed_values = map { defined $c->get($_)? $c->get($_) : "UNDEF" } (@variables,$extravar) ; diag(qq{Parsed values: @parsed_values}) ; } done_testing() ;


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.