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