source: ProjectBuilder/devel/pb-modules/t/Base.t@ 1147

Last change on this file since 1147 was 1147, checked in by Bruno Cornec, 13 years ago
  • A inimal version of Test::More is required to perform test (especially on older version). Now fixed
File size: 1.7 KB
RevLine 
[1075]1#!/usr/bin/perl -w
2#
3# Tests ProjectBuilder::Base functions
4
5use strict;
[1076]6use ProjectBuilder::Base;
[1075]7
[1106]8eval
9{
[1147]10 require Test::More;
11 Test::More->import();
12 my ($tmv,$tmsv) = split(/\./,$Test::More::VERSION);
13 if ($tmsv lt 87) {
14 die "Test::More is not available in an appropriate version ($tmsv)";
15 }
[1106]16};
17
[1147]18# Test::More appropriate version not found so no test will be performed here
[1106]19if ($@) {
[1109]20 require Test;
21 plan(tests => 1);
[1147]22 print "# Faking tests as Test::More is not available in an appropriate version\n";
[1106]23 ok(1,1);
[1147]24 exit(0);
[1106]25}
26
[1075]27my $nt = 0;
[1077]28my $test = {
29 # Full URI
30 "svn+ssh://account\@machine.sdom.tld:8080/path/to/file" => ["svn+ssh","account","machine.sdom.tld","8080","/path/to/file"],
31 # Partial URI
32 "http://machine2/path1/to/anotherfile" => ["http","","machine2","","/path1/to/anotherfile"],
33 };
[1075]34
[1077]35my ($scheme, $account, $host, $port, $path);
36foreach my $uri (keys %$test) {
37 ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
[1075]38
[1077]39 is($scheme, $test->{$uri}[0], "pb_get_uri Test protocol $uri");
40 $nt++;
[1075]41
[1077]42 is($account, $test->{$uri}[1], "pb_get_uri Test account $uri");
43 $nt++;
44
45 is($host, $test->{$uri}[2], "pb_get_uri Test host $uri");
46 $nt++;
47
48 is($port, $test->{$uri}[3], "pb_get_uri Test port $uri");
49 $nt++;
50
51 is($path, $test->{$uri}[4], "pb_get_uri Test path $uri");
52 $nt++;
53}
[1075]54
[1077]55$ENV{'TMPDIR'} = "/tmp";
56pb_temp_init();
57like($ENV{'PBTMP'}, qr|/tmp/pb\.[0-9A-z]+|, "pb_temp_init Test");
[1075]58$nt++;
59
[1077]60my $content = "This is content with TABs and spaces and \ncarriage returns\n";
61open(FILE,"> $ENV{'PBTMP'}/test") || die "Unable to create temp file";
62print FILE $content;
63close(FILE);
[1075]64
[1077]65my $cnt = pb_get_content("$ENV{'PBTMP'}/test");
66is($cnt, $content, "pb_get_content Test");
[1075]67$nt++;
68
69done_testing($nt);
Note: See TracBrowser for help on using the repository browser.