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