#!/usr/bin/perl -w # # Tests ProjectBuilder::Conf functions use strict; use ProjectBuilder::Version; use ProjectBuilder::Base; use ProjectBuilder::Conf; use ProjectBuilder::Distribution; my $res; eval { require Test::More; Test::More->import(); $res = $@; my ($tmv,$tmsv) = split(/\./,$Test::More::VERSION); if ($tmsv lt 87) { die "Test::More is not available in an appropriate version ($tmsv)"; } }; # Test::More appropriate version not found so no test will be performed here if ($res) { require Test; Test->import(); plan(tests => 1); print "# Faking tests as Test::More is not available in an appropriate version\n"; ok(1,1); exit(0); } my $nt = 0; $ENV{'TMPDIR'} = "/tmp"; pb_temp_init(); my ($projectbuilderver,$projectbuilderrev,$projectbuilderconfver) = pb_version_init(); pb_conf_init("test"); open(FILE,"> $ENV{'TMPDIR'}/conf.yml") || die "Unable to create $ENV{'TMPDIR'}/conf.yml"; if ($projectbuilderconfver < 1) { # Old conf file format # should be in alphabetic order print FILE "colon mageia-3-x86_64 = ex: test\n"; print FILE "percent mageia-3-x86_64 = %check\n"; print FILE "truc mageia-4-x86_64 = la tete a toto\n"; print FILE "yorro mageia-3-x86_64 = tartampion\n"; print FILE "zz mageia-3-x86_64 =\n"; } else { print FILE "---\n"; print FILE "colon:\n"; print FILE " mageia-3-x86_64: 'ex: test'\n"; print FILE "percent:\n"; print FILE " mageia-3-x86_64: '%check'\n"; print FILE "truc:\n"; print FILE " mageia-4-x86_64: la-tete-a-toto\n"; print FILE "yorro:\n"; print FILE " mageia-3-x86_64: tartampion\n"; print FILE "zz:\n"; print FILE " mageia-3-x86_64: ''\n"; } close(FILE); my $cnt = pb_get_content("$ENV{'TMPDIR'}/conf.yml"); my %h; my $h = \%h; $h = pb_conf_cache("$ENV{'TMPDIR'}/conf.yml",$h); pb_conf_write("$ENV{'TMPDIR'}/test.yml",$h); my $content = pb_get_content("$ENV{'TMPDIR'}/test.yml"); is($cnt, $content, "pb_conf_write Test"); $nt++; unlink("$ENV{'TMPDIR'}/conf.yml"); unlink("$ENV{'TMPDIR'}/test.yml"); done_testing($nt);