]> sjero.net Git - wget/blob - tests/Test-np.px
Catch failures in Test-N-current.px.
[wget] / tests / Test-np.px
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use HTTPTest;
6
7
8 ###############################################################################
9
10 my $mainpage = <<EOF;
11 <html>
12 <head>
13   <title>Main Page</title>
14 </head>
15 <body>
16   <p>
17     Some text and a link to a <a href="http://localhost:8080/firstlevel/secondpage.html">second page</a>.
18   </p>
19 </body>
20 </html>
21 EOF
22
23 my $secondpage = <<EOF;
24 <html>
25 <head>
26   <title>Second Page</title>
27 </head>
28 <body>
29   <p>
30     Some text and a link to a <a href="http://localhost:8080/firstlevel/lowerlevel/thirdpage.html">third page</a>.
31   </p>
32 </body>
33 </html>
34 EOF
35
36 my $thirdpage = <<EOF;
37 <html>
38 <head>
39   <title>Third Page</title>
40 </head>
41 <body>
42   <p>
43     Some text and a link to a <a href="http://localhost:8080/higherlevelpage.html">higher level page</a>.
44   </p>
45 </body>
46 </html>
47 EOF
48
49 my $fourthpage = <<EOF;
50 <html>
51 <head>
52   <title>Fourth Page</title>
53 </head>
54 <body>
55   <p>
56     This page is only linked by the higher level page. Therefore, it should not
57     be downloaded. 
58   </p>
59 </body>
60 </html>
61 EOF
62
63 my $higherlevelpage = <<EOF;
64 <html>
65 <head>
66   <title>Higher Level Page</title>
67 </head>
68 <body>
69   <p>
70     This page is on a higher level in the URL path hierarchy. Therefore, it
71     should not be downloaded. Wget should not visit the following link to a 
72     <a href="http://localhost:8080/firstlevel/fourthpage.html">fourth page</a>.
73   </p>
74 </body>
75 </html>
76 EOF
77
78 # code, msg, headers, content
79 my %urls = (
80     '/firstlevel/index.html' => {
81         code => "200",
82         msg => "Dontcare",
83         headers => {
84             "Content-type" => "text/html",
85         },
86         content => $mainpage,
87     },
88     '/firstlevel/secondpage.html' => {
89         code => "200",
90         msg => "Dontcare",
91         headers => {
92             "Content-type" => "text/html",
93         },
94         content => $secondpage,
95     },
96     '/firstlevel/lowerlevel/thirdpage.html' => {
97         code => "200",
98         msg => "Dontcare",
99         headers => {
100             "Content-type" => "text/html",
101         },
102         content => $thirdpage,
103     },
104     '/firstlevel/fourthpage.html' => {
105         code => "200",
106         msg => "Dontcare",
107         headers => {
108             "Content-type" => "text/plain",
109         },
110         content => $fourthpage,
111     },
112     '/higherlevelpage.html' => {
113         code => "200",
114         msg => "Dontcare",
115         headers => {
116             "Content-type" => "text/plain",
117         },
118         content => $higherlevelpage,
119     },
120 );
121
122 my $cmdline = $WgetTest::WGETPATH . " -np -nH -r http://localhost:8080/firstlevel/";
123
124 my $expected_error_code = 0;
125
126 my %expected_downloaded_files = (
127     'firstlevel/index.html' => {
128         content => $mainpage,
129     },
130     'firstlevel/secondpage.html' => {
131         content => $secondpage,
132     },
133     'firstlevel/lowerlevel/thirdpage.html' => {
134         content => $thirdpage,
135     },
136 );
137
138 ###############################################################################
139
140 my $the_test = HTTPTest->new (name => "Test-np",
141                               input => \%urls, 
142                               cmdline => $cmdline, 
143                               errcode => $expected_error_code, 
144                               output => \%expected_downloaded_files);
145 exit $the_test->run();
146
147 # vim: et ts=4 sw=4
148