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

Last change on this file since 2609 was 2609, checked in by Bruno Cornec, 4 years ago

YAML does not save/restore chains with spaces in it, so remove from test for now

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