Changeset 1905 in ProjectBuilder
- Timestamp:
- Oct 9, 2014, 12:14:42 PM (11 years ago)
- Location:
- devel/pb-modules
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Conf.pm
r1904 r1905 29 29 30 30 our @ISA = qw(Exporter); 31 our @EXPORT = qw(pb_conf_init pb_conf_add pb_conf_read pb_conf_read_if pb_conf_write pb_conf_get pb_conf_get_if pb_conf_print pb_conf_get_all );31 our @EXPORT = qw(pb_conf_init pb_conf_add pb_conf_read pb_conf_read_if pb_conf_write pb_conf_get pb_conf_get_if pb_conf_print pb_conf_get_all pb_conf_cache); 32 32 ($VERSION,$REVISION) = pb_version_init(); 33 33 … … 118 118 open(CONF,$cf) || confess "Unable to open $cf"; 119 119 while(<CONF>) { 120 next if (/^#/); 120 121 if (/^\s*([A-z0-9-_.]+)\s+([[A-z0-9-_.]+)\s*=\s*(.*)$/) { 121 122 pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n"); … … 233 234 234 235 my $conffile = shift; 235 my $h = $_; 236 237 open(CONF,"> $conffile") || confess "Unbale to wirte into $conffile"; 236 my $h = shift; 237 238 confess "No configuration file defined to write into !" if (not defined $conffile); 239 confess "No hash defined to read from !" if (not defined $h); 240 open(CONF,"> $conffile") || confess "Unable to write into $conffile"; 238 241 239 242 foreach my $p (keys %$h) { 240 foreach my $key ($p) { 241 print CONF "$p $key = $p->{$key}\n"; 243 my $j = $h->{$p}; 244 foreach my $k (keys %$j) { 245 print CONF "$p $k = $j->{$k}\n"; 242 246 } 243 247 } -
devel/pb-modules/t/Conf.t
r1904 r1905 6 6 use ProjectBuilder::Base; 7 7 use ProjectBuilder::Conf; 8 use ProjectBuilder::Distribution; 8 9 9 10 eval … … 28 29 29 30 my $nt = 0; 30 is($path, $test->{$uri}[4], "pb_get_uri Test path $uri");31 $nt++;32 }33 31 34 32 $ENV{'TMPDIR'} = "/tmp"; … … 36 34 37 35 pb_conf_init("test"); 38 my $cf = pb_distro_conffile(); 39 my $cnt = pb_get_content($cf); 36 open(FILE,"> $ENV{'TMPDIR'}/conf.pb") || die "Unable to create $ENV{'TMPDIR'}/conf.pb"; 37 # should be in alphabetic order 38 print FILE "truc mageia-4-x86_64 = la tete a toto\n"; 39 print FILE "yorro mageia-3-x86_64 = tartampion\n"; 40 print FILE "zz mageia-3-x86_64 = yy\n"; 41 close(FILE); 42 my $cnt = pb_get_content("$ENV{'TMPDIR'}/conf.pb"); 40 43 41 my %h = pb_conf_cache($cf,\%h); 42 pb_conf_write("$PBTMP/test.pb",\%h); 43 my $content = pb_get_content("$PBTMP/test.pb"); 44 my %h; 45 my $h = \%h; 46 $h = pb_conf_cache("$ENV{'TMPDIR'}/conf.pb",$h); 47 pb_conf_write("$ENV{'TMPDIR'}/test.pb",$h); 48 my $content = pb_get_content("$ENV{'TMPDIR'}/test.pb"); 44 49 is($cnt, $content, "pb_conf_write Test"); 45 50 $nt++; 51 unlink("$ENV{'TMPDIR'}/conf.pb"); 52 unlink("$ENV{'TMPDIR'}/test.pb"); 46 53 47 54 done_testing($nt);
Note:
See TracChangeset
for help on using the changeset viewer.