From: <no...@so...> - 2008-01-21 18:45:11
|
Update of /cvsroot/ijbswa/current/tools In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv9397/tools Modified Files: privoxy-regression-test.pl Log Message: - Factor enlist_new_test() out of load_action_files(). - Let --test-number work independent of the chosen level. Index: privoxy-regression-test.pl =================================================================== RCS file: /cvsroot/ijbswa/current/tools/privoxy-regression-test.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- privoxy-regression-test.pl 18 Jan 2008 19:33:00 -0000 1.1 +++ privoxy-regression-test.pl 21 Jan 2008 18:43:16 -0000 1.2 @@ -221,6 +221,67 @@ return ($token, $value); } +sub enlist_new_test ($$$$$$) { + + my ($regression_tests, $token, $value, $si, $ri, $number) = @_; + + if ($token eq 'set header') { + + l(LL_FILE_LOADING, "Header to set: " . $value); + ${$regression_tests}[$si][$ri]{'type'} = CLIENT_HEADER_TEST; + # Implicit default + $$regression_tests[$si][$ri]{'level'} = CLIENT_HEADER_TEST; + + } elsif ($token eq 'request header') { + + l(LL_FILE_LOADING, "Header to request: " . $value); + $$regression_tests[$si][$ri]{'type'} = SERVER_HEADER_TEST; + # Implicit default + $$regression_tests[$si][$ri]{'expected-status-code'} = 200; + $$regression_tests[$si][$ri]{'level'} = SERVER_HEADER_TEST; + + } elsif ($token eq 'trusted cgi request') { + + l(LL_FILE_LOADING, "CGI URL to test in a dumb way: " . $value); + $$regression_tests[$si][$ri]{'type'} = TRUSTED_CGI_REQUEST; + # Implicit default + $$regression_tests[$si][$ri]{'expected-status-code'} = 200; + $$regression_tests[$si][$ri]{'level'} = TRUSTED_CGI_REQUEST; + + } elsif ($token eq 'fetch test') { + + l(LL_FILE_LOADING, "URL to test in a dumb way: " . $value); + $$regression_tests[$si][$ri]{'type'} = DUMB_FETCH_TEST; + # Implicit default + $$regression_tests[$si][$ri]{'expected-status-code'} = 200; + $$regression_tests[$si][$ri]{'level'} = DUMB_FETCH_TEST; + + } elsif ($token eq 'method test') { + + l(LL_FILE_LOADING, "Method to test: " . $value); + $$regression_tests[$si][$ri]{'type'} = METHOD_TEST; + # Implicit default + $$regression_tests[$si][$ri]{'expected-status-code'} = 200; + $$regression_tests[$si][$ri]{'level'} = METHOD_TEST; + + } else { + + die "Incomplete '" . $token . "' support detected."; + + } + + check_for_forbidden_characters($value); + + $$regression_tests[$si][$ri]{'data'} = $value; + + # For function that only get passed single tests + $$regression_tests[$si][$ri]{'section-id'} = $si; + $$regression_tests[$si][$ri]{'regression-test-id'} = $ri; + $$regression_tests[$si][$ri]{'number'} = $number - 1; + l(LL_FILE_LOADING, + "Regression test " . $number . " (section:" . $si . "):"); +} + sub load_action_files ($) { # initialized here @@ -229,11 +290,10 @@ my $actionfiles_ref = shift; my @actionfiles = @{$actionfiles_ref}; - my $number; my $si = 0; # Section index my $ri = -1; # Regression test index - my $number_of_regression_tests = 0; + my $count = 0; my $ignored = 0; @@ -267,64 +327,8 @@ # Beginning of new regression test. $ri++; - $number_of_regression_tests++; - - l(LL_FILE_LOADING, "Regression test " . $number_of_regression_tests . " (section:" . $si . "):"); - - if ($token eq 'set header') { - - l(LL_FILE_LOADING, "Header to set: " . $value); - $regression_tests[$si][$ri]{'type'} = CLIENT_HEADER_TEST; - # Implicit default - $regression_tests[$si][$ri]{'level'} = CLIENT_HEADER_TEST; - - } elsif ($token eq 'request header') { - - l(LL_FILE_LOADING, "Header to request: " . $value); - $regression_tests[$si][$ri]{'type'} = SERVER_HEADER_TEST; - # Implicit default - $regression_tests[$si][$ri]{'expected-status-code'} = 200; - $regression_tests[$si][$ri]{'level'} = SERVER_HEADER_TEST; - - } elsif ($token eq 'trusted cgi request') { - - l(LL_FILE_LOADING, "CGI URL to test in a dumb way: " . $value); - $regression_tests[$si][$ri]{'type'} = TRUSTED_CGI_REQUEST; - # Implicit default - $regression_tests[$si][$ri]{'expected-status-code'} = 200; - $regression_tests[$si][$ri]{'level'} = TRUSTED_CGI_REQUEST; - - } elsif ($token eq 'fetch test') { - - l(LL_FILE_LOADING, "URL to test in a dumb way: " . $value); - $regression_tests[$si][$ri]{'type'} = DUMB_FETCH_TEST; - # Implicit default - $regression_tests[$si][$ri]{'expected-status-code'} = 200; - $regression_tests[$si][$ri]{'level'} = DUMB_FETCH_TEST; - - } elsif ($token eq 'method test') { - - l(LL_FILE_LOADING, "Method to test: " . $value); - $regression_tests[$si][$ri]{'type'} = METHOD_TEST; - # Implicit default - $regression_tests[$si][$ri]{'expected-status-code'} = 200; - $regression_tests[$si][$ri]{'level'} = METHOD_TEST; - - } else { - - die "Incomplete '" . $token . "' support detected."; - - } - - check_for_forbidden_characters($value); - - $regression_tests[$si][$ri]{'data'} = $value; - - # For function that only get passed single tests - $regression_tests[$si][$ri]{'section-id'} = $si; - $regression_tests[$si][$ri]{'regression-test-id'} = $ri; - $regression_tests[$si][$ri]{'file'} = $actionfile; - + $count++; + enlist_new_test(\@regression_tests, $token, $value, $si, $ri, $count); } if ($si == -1 || $ri == -1) { @@ -389,7 +393,7 @@ } } - l(LL_FILE_LOADING, "Done loading " . $number_of_regression_tests . " regression tests." + l(LL_FILE_LOADING, "Done loading " . $count . " regression tests." . " Of which " . $ignored. " will be ignored)\n"); } @@ -421,7 +425,6 @@ my $tests = 0; my $failures; my $skipped = 0; - my $test_number = 0; for my $s (0 .. @regression_tests - 1) { @@ -432,9 +435,11 @@ die "Section id mismatch" if ($s != $regression_tests[$s][$r]{'section-id'}); die "Regression test id mismatch" if ($r != $regression_tests[$s][$r]{'regression-test-id'}); + my $number = $regression_tests[$s][$r]{'number'}; + if ($regression_tests[$s][$r]{'ignore'} or level_is_unacceptable($regression_tests[$s][$r]{'level'}) - or test_number_is_unacceptable($test_number)) { + or test_number_is_unacceptable($number)) { $skipped++; @@ -448,7 +453,6 @@ $tests++; } $r++; - $test_number++; } } $failures = $tests - $successes; @@ -1132,6 +1136,8 @@ $message .= " for test "; $message .= $number; $message .= '/'; + $message .= $test{'number'}; + $message .= '/'; $message .= $test{'section-id'}; $message .= '/'; $message .= $test{'regression-test-id'}; |