1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # Tests ProjectBuilder::YAML functions
|
---|
4 |
|
---|
5 | use strict;
|
---|
6 | use Data::Dumper;
|
---|
7 | use ProjectBuilder::Base;
|
---|
8 | use ProjectBuilder::YAML;
|
---|
9 |
|
---|
10 | my $res;
|
---|
11 | eval
|
---|
12 | {
|
---|
13 | require Test::More;
|
---|
14 | Test::More->import();
|
---|
15 | $res = $@;
|
---|
16 | my ($tmv,$tmsv) = split(/\./,$Test::More::VERSION);
|
---|
17 | if ($tmsv lt 87) {
|
---|
18 | die "Test::More is not available in an appropriate version ($tmsv)";
|
---|
19 | }
|
---|
20 | };
|
---|
21 |
|
---|
22 | # Test appropriate version not found so no test will be performed here
|
---|
23 | if ($res) {
|
---|
24 | require Test;
|
---|
25 | Test->import();
|
---|
26 | plan(tests => 1);
|
---|
27 | print "# Faking tests as Test::More is not available in an appropriate version\n";
|
---|
28 | ok(1,1);
|
---|
29 | exit(0);
|
---|
30 | }
|
---|
31 |
|
---|
32 | my $nt = 0;
|
---|
33 |
|
---|
34 | $ENV{'TMPDIR'} = "/tmp";
|
---|
35 | pb_temp_init();
|
---|
36 | open(FILE,"> $ENV{'TMPDIR'}/conf1.yml") || die "Unable to create $ENV{'TMPDIR'}/conf1.yml";
|
---|
37 | print FILE "---\n";
|
---|
38 | print FILE "colon:\n";
|
---|
39 | print FILE " mageia-3-x86_64: 'ex: test'\n";
|
---|
40 | print FILE "percent:\n";
|
---|
41 | print FILE " mageia-3-x86_64: '%check'\n";
|
---|
42 | print FILE "truc:\n";
|
---|
43 | print FILE " mageia-4-x86_64: 'la tete a toto'\n";
|
---|
44 | print FILE "yorro:\n";
|
---|
45 | print FILE " mageia-3-x86_64: tartampion\n";
|
---|
46 | print FILE "zz:\n";
|
---|
47 | print FILE " mageia-3-x86_64: ''\n";
|
---|
48 | close(FILE);
|
---|
49 |
|
---|
50 | my $tab1 = pb_LoadFile("$ENV{'TMPDIR'}/conf1.yml");
|
---|
51 | #open(FILE,"> $ENV{'TMPDIR'}/conf1bis.yml") || die "Unable to create $ENV{'TMPDIR'}/conf1bis.yml";
|
---|
52 | #print FILE Dumper($tab1);
|
---|
53 | #close(FILE);
|
---|
54 | my $cnt = pb_get_content("$ENV{'TMPDIR'}/conf1.yml");
|
---|
55 | my $tab2 = pb_Dump($tab1);
|
---|
56 | #open(FILE,"> $ENV{'TMPDIR'}/test1bis.yml") || die "Unable to create $ENV{'TMPDIR'}/test1bis.yml";
|
---|
57 | #print FILE Dumper($tab2);
|
---|
58 | #close(FILE);
|
---|
59 | open(FILE,"> $ENV{'TMPDIR'}/test1.yml") || die "Unable to create $ENV{'TMPDIR'}/test1.yml";
|
---|
60 | print FILE "$tab2";
|
---|
61 | close(FILE);
|
---|
62 | my $content = pb_get_content("$ENV{'TMPDIR'}/test1.yml");
|
---|
63 | is($cnt, $content, "pb_DumpFile Test");
|
---|
64 | $nt++;
|
---|
65 | unlink("$ENV{'TMPDIR'}/conf1.yml");
|
---|
66 | unlink("$ENV{'TMPDIR'}/test1.yml");
|
---|
67 |
|
---|
68 | done_testing($nt);
|
---|