Last change
on this file since 2275 was 2275, checked in by Bruno Cornec, 7 years ago |
Fix tests so that they really work when Test::More isn't found
|
File size:
1.3 KB
|
Rev | Line | |
---|
[1904] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Tests ProjectBuilder::Base functions
|
---|
| 4 |
|
---|
| 5 | use strict;
|
---|
[2275] | 6 | use ProjectBuilder::Version;
|
---|
[1904] | 7 | use ProjectBuilder::Base;
|
---|
| 8 | use ProjectBuilder::Conf;
|
---|
[1905] | 9 | use ProjectBuilder::Distribution;
|
---|
[1904] | 10 |
|
---|
[2275] | 11 | my $res;
|
---|
[1904] | 12 | eval
|
---|
| 13 | {
|
---|
| 14 | require Test::More;
|
---|
| 15 | Test::More->import();
|
---|
[2275] | 16 | $res = $@;
|
---|
[1904] | 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
|
---|
[2275] | 24 | if ($res) {
|
---|
[1904] | 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 | pb_conf_init("test");
|
---|
[1905] | 39 | open(FILE,"> $ENV{'TMPDIR'}/conf.pb") || die "Unable to create $ENV{'TMPDIR'}/conf.pb";
|
---|
| 40 | # should be in alphabetic order
|
---|
| 41 | print FILE "truc mageia-4-x86_64 = la tete a toto\n";
|
---|
| 42 | print FILE "yorro mageia-3-x86_64 = tartampion\n";
|
---|
| 43 | print FILE "zz mageia-3-x86_64 = yy\n";
|
---|
| 44 | close(FILE);
|
---|
| 45 | my $cnt = pb_get_content("$ENV{'TMPDIR'}/conf.pb");
|
---|
[1904] | 46 |
|
---|
[1905] | 47 | my %h;
|
---|
| 48 | my $h = \%h;
|
---|
| 49 | $h = pb_conf_cache("$ENV{'TMPDIR'}/conf.pb",$h);
|
---|
| 50 | pb_conf_write("$ENV{'TMPDIR'}/test.pb",$h);
|
---|
| 51 | my $content = pb_get_content("$ENV{'TMPDIR'}/test.pb");
|
---|
[1904] | 52 | is($cnt, $content, "pb_conf_write Test");
|
---|
| 53 | $nt++;
|
---|
[1905] | 54 | unlink("$ENV{'TMPDIR'}/conf.pb");
|
---|
| 55 | unlink("$ENV{'TMPDIR'}/test.pb");
|
---|
[1904] | 56 |
|
---|
| 57 | done_testing($nt);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.