source: ProjectBuilder/devel/pb-modules/t/Conf.t@ 1905

Last change on this file since 1905 was 1905, checked in by Bruno Cornec, 10 years ago
  • pb_conf_write is indeed working and tested now (git error)
File size: 1.3 KB
Line 
1#!/usr/bin/perl -w
2#
3# Tests ProjectBuilder::Base functions
4
5use strict;
6use ProjectBuilder::Base;
7use ProjectBuilder::Conf;
8use ProjectBuilder::Distribution;
9
10eval
11{
12 require Test::More;
13 Test::More->import();
14 my ($tmv,$tmsv) = split(/\./,$Test::More::VERSION);
15 if ($tmsv lt 87) {
16 die "Test::More is not available in an appropriate version ($tmsv)";
17 }
18};
19
20# Test::More appropriate version not found so no test will be performed here
21if ($@) {
22 require Test;
23 Test->import();
24 plan(tests => 1);
25 print "# Faking tests as Test::More is not available in an appropriate version\n";
26 ok(1,1);
27 exit(0);
28}
29
30my $nt = 0;
31
32$ENV{'TMPDIR'} = "/tmp";
33pb_temp_init();
34
35pb_conf_init("test");
36open(FILE,"> $ENV{'TMPDIR'}/conf.pb") || die "Unable to create $ENV{'TMPDIR'}/conf.pb";
37# should be in alphabetic order
38print FILE "truc mageia-4-x86_64 = la tete a toto\n";
39print FILE "yorro mageia-3-x86_64 = tartampion\n";
40print FILE "zz mageia-3-x86_64 = yy\n";
41close(FILE);
42my $cnt = pb_get_content("$ENV{'TMPDIR'}/conf.pb");
43
44my %h;
45my $h = \%h;
46$h = pb_conf_cache("$ENV{'TMPDIR'}/conf.pb",$h);
47pb_conf_write("$ENV{'TMPDIR'}/test.pb",$h);
48my $content = pb_get_content("$ENV{'TMPDIR'}/test.pb");
49is($cnt, $content, "pb_conf_write Test");
50$nt++;
51unlink("$ENV{'TMPDIR'}/conf.pb");
52unlink("$ENV{'TMPDIR'}/test.pb");
53
54done_testing($nt);
Note: See TracBrowser for help on using the repository browser.