1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # Tests ProjectBuilder::Conf functions
|
---|
4 |
|
---|
5 | use strict;
|
---|
6 | use ProjectBuilder::Version;
|
---|
7 | use ProjectBuilder::Base;
|
---|
8 | use ProjectBuilder::Conf;
|
---|
9 | use ProjectBuilder::Distribution;
|
---|
10 |
|
---|
11 | my $res;
|
---|
12 | eval
|
---|
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
|
---|
24 | if ($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 |
|
---|
33 | my $nt = 0;
|
---|
34 |
|
---|
35 | $ENV{'TMPDIR'} = "/tmp";
|
---|
36 | pb_temp_init();
|
---|
37 |
|
---|
38 | my ($projectbuilderver,$projectbuilderrev,$projectbuilderconfver) = pb_version_init();
|
---|
39 |
|
---|
40 | pb_conf_init("test");
|
---|
41 | open(FILE,"> $ENV{'TMPDIR'}/conf.yml") || die "Unable to create $ENV{'TMPDIR'}/conf.yml";
|
---|
42 | if ($projectbuilderconfver < 1) {
|
---|
43 | # Old conf file format
|
---|
44 | # should be in alphabetic order
|
---|
45 | print FILE "colon mageia-3-x86_64 = ex: test\n";
|
---|
46 | print FILE "percent mageia-3-x86_64 = %check\n";
|
---|
47 | print FILE "truc mageia-4-x86_64 = la tete a toto\n";
|
---|
48 | print FILE "yorro mageia-3-x86_64 = tartampion\n";
|
---|
49 | print FILE "zz mageia-3-x86_64 =\n";
|
---|
50 | } else {
|
---|
51 | print FILE "---\n";
|
---|
52 | print FILE "colon:\n";
|
---|
53 | print FILE " mageia-3-x86_64: 'ex: test'\n";
|
---|
54 | print FILE "percent:\n";
|
---|
55 | print FILE " mageia-3-x86_64: '%check'\n";
|
---|
56 | print FILE "truc:\n";
|
---|
57 | print FILE " mageia-4-x86_64: la-tete-a-toto\n";
|
---|
58 | print FILE "yorro:\n";
|
---|
59 | print FILE " mageia-3-x86_64: tartampion\n";
|
---|
60 | print FILE "zz:\n";
|
---|
61 | print FILE " mageia-3-x86_64: ''\n";
|
---|
62 | }
|
---|
63 | close(FILE);
|
---|
64 | my $cnt = pb_get_content("$ENV{'TMPDIR'}/conf.yml");
|
---|
65 |
|
---|
66 | my %h;
|
---|
67 | my $h = \%h;
|
---|
68 | $h = pb_conf_cache("$ENV{'TMPDIR'}/conf.yml",$h);
|
---|
69 | pb_conf_write("$ENV{'TMPDIR'}/test.yml",$h);
|
---|
70 | my $content = pb_get_content("$ENV{'TMPDIR'}/test.yml");
|
---|
71 | is($cnt, $content, "pb_conf_write Test");
|
---|
72 | $nt++;
|
---|
73 | unlink("$ENV{'TMPDIR'}/conf.yml");
|
---|
74 | unlink("$ENV{'TMPDIR'}/test.yml");
|
---|
75 |
|
---|
76 | done_testing($nt);
|
---|