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

Last change on this file since 2278 was 2278, checked in by Bruno Cornec, 7 years ago

Fix Conf test for empty string and deb deps

File size: 1.7 KB
Line 
1#!/usr/bin/perl -w
2#
3# Tests ProjectBuilder::Base functions
4
5use strict;
6use ProjectBuilder::Version;
7use ProjectBuilder::Base;
8use ProjectBuilder::Conf;
9use ProjectBuilder::Distribution;
10
11my $res;
12eval
13{
14 require Test::More;
15 Test::More->import();
16 $res = $@;
17 my ($tmv,$tmsv) = split(/\./,$Test::More::VERSION);
18 if ($tmsv lt 87) {
19 die "Test::More is not available in an appropriate version ($tmsv)";
20 }
21};
22
23# Test::More appropriate version not found so no test will be performed here
24if ($res) {
25 require Test;
26 Test->import();
27 plan(tests => 1);
28 print "# Faking tests as Test::More is not available in an appropriate version\n";
29 ok(1,1);
30 exit(0);
31}
32
33my $nt = 0;
34
35$ENV{'TMPDIR'} = "/tmp";
36pb_temp_init();
37
38my ($projectbuilderver,$projectbuilderrev,$projectbuilderconfver) = pb_version_init();
39
40pb_conf_init("test");
41open(FILE,"> $ENV{'TMPDIR'}/conf.pb") || die "Unable to create $ENV{'TMPDIR'}/conf.pb";
42if ($projectbuilderconfver < 1) {
43 # Old conf file format
44 # should be in alphabetic order
45 print FILE "truc mageia-4-x86_64 = la tete a toto\n";
46 print FILE "yorro mageia-3-x86_64 = tartampion\n";
47 print FILE "zz mageia-3-x86_64 = yy\n";
48} else {
49 print FILE "---\n";
50 print FILE "truc:\n";
51 print FILE " mageia-4-x86_64: la tete a toto\n";
52 print FILE "yorro:\n";
53 print FILE " mageia-3-x86_64: tartampion\n";
54 print FILE "zz:\n";
55 print FILE " mageia-3-x86_64: ''\n";
56}
57close(FILE);
58my $cnt = pb_get_content("$ENV{'TMPDIR'}/conf.pb");
59
60my %h;
61my $h = \%h;
62$h = pb_conf_cache("$ENV{'TMPDIR'}/conf.pb",$h);
63pb_conf_write("$ENV{'TMPDIR'}/test.pb",$h);
64my $content = pb_get_content("$ENV{'TMPDIR'}/test.pb");
65is($cnt, $content, "pb_conf_write Test");
66$nt++;
67unlink("$ENV{'TMPDIR'}/conf.pb");
68unlink("$ENV{'TMPDIR'}/test.pb");
69
70done_testing($nt);
Note: See TracBrowser for help on using the repository browser.