]> sjero.net Git - wget/blobdiff - tests/WgetTest.pm.in
Automated merge.
[wget] / tests / WgetTest.pm.in
index b20b5d8fb752fef11381695b369a3bd13866bcfa..910ac80d8149f534121b9dd1fd69c4d5b2e1b08e 100644 (file)
@@ -1,5 +1,9 @@
 #!/usr/bin/perl -w
 
+# WARNING!
+# WgetTest.pm is a generated file! Do not edit! Edit WgetTest.pm.in
+# instead.
+
 package WgetTest;
 $VERSION = 0.01;
 
@@ -8,7 +12,7 @@ use strict;
 use Cwd;
 use File::Path;
 
-our $WGETPATH = "@top_srcdir@/src/wget";
+our $WGETPATH = "@abs_top_builddir@/src/wget";
 
 my @unexpected_downloads = ();
 
@@ -78,11 +82,13 @@ sub run {
     
     # Call wget
     chdir ("$self->{_workdir}/$self->{_name}/output");
-    # print "Calling $self->{_cmdline}\n";
+    my $cmdline = $self->{_cmdline};
+    $cmdline = $self->_substitute_port($cmdline);
+    print "Calling $cmdline\n";
     my $errcode = 
-        ($self->{_cmdline} =~ m{^/.*}) 
-            ? system ($self->{_cmdline})
-            : system ("$self->{_workdir}/../src/$self->{_cmdline}");
+        ($cmdline =~ m{^/.*}) 
+            ? system ($cmdline)
+            : system ("$self->{_workdir}/../src/$cmdline");
 
     # Shutdown server
     # if we didn't explicitely kill the server, we would have to call 
@@ -124,11 +130,17 @@ sub _setup {
     foreach my $filename (keys %{$self->{_existing}}) {
         open (FILE, ">$filename") 
             or return "Test failed: cannot open pre-existing file $filename\n";
-        
-        print FILE $self->{_existing}->{$filename}->{content}
+
+        my $file = $self->{_existing}->{$filename};
+        print FILE $file->{content}
             or return "Test failed: cannot write pre-existing file $filename\n";
-        
+
         close (FILE);
+
+        if (exists($file->{timestamp})) {
+            utime $file->{timestamp}, $file->{timestamp}, $filename
+                or return "Test failed: cannot set timestamp on pre-existing file $filename\n";
+        }
     } 
     
     chdir ("../input");
@@ -160,7 +172,9 @@ sub _verify_download {
             or return "Test failed: file $filename not downloaded\n";
         
         my $content = <FILE>;
-        $content eq $filedata->{'content'} 
+        my $expected_content = $filedata->{'content'};
+        $expected_content = $self->_substitute_port($expected_content);
+        $content eq $expected_content
             or return "Test failed: wrong content for file $filename\n";
 
         if (exists($filedata->{'timestamp'})) {