1
0
mirror of https://github.com/mirror/wget.git synced 2025-04-14 21:40:42 +08:00

Use test file name for temp working directory name

* testenv/test/base_test.py (__init__): Use test file name for name,
  remove 'name' parameter
* testenv/test/http_test.py (__init__): Remove 'name' parameter
* testenv/*.py: Remove TEST_NAME

Using a fixed string (TEST_NAME) to build the working directory
for testing caused random failures (or successes) when tests
share the same TEST_NAME value. Not easy to find without digging
into the python test suite code.
We now use the test file name, which is unique within the test
environment.
This commit is contained in:
Tim Rühsen 2016-04-08 16:31:08 +02:00
parent d286d5408b
commit 926e42d467
34 changed files with 4 additions and 69 deletions

2
testenv/Test--convert-links--content-on-error.py Executable file → Normal file
View File

@ -6,7 +6,6 @@ from misc.wget_file import WgetFile
"""
This test ensures that Wget link conversion works also on HTTP error pages.
"""
TEST_NAME = "Test--convert-links--content-on-error"
############# File Definitions ###############################################
a_x_FileContent = """
<!DOCTYPE html>
@ -70,7 +69,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test--https-crl.py Executable file → Normal file
View File

@ -8,7 +8,6 @@ import os
"""
This test ensures that Wget can download files from HTTPS Servers
"""
TEST_NAME = "HTTPS CRL"
if os.getenv('SSL_TESTS') is None:
exit (77)
@ -43,7 +42,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test,

2
testenv/Test--https.py Executable file → Normal file
View File

@ -8,7 +8,6 @@ import os
"""
This test ensures that Wget can download files from HTTPS Servers
"""
TEST_NAME = "HTTPS Downloads"
if os.getenv('SSL_TESTS') is None:
exit (77)
@ -48,7 +47,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test,

2
testenv/Test--rejected-log.py Executable file → Normal file
View File

@ -6,7 +6,6 @@ from misc.wget_file import WgetFile
"""
This test executed Wget in recursive mode with a rejected log outputted.
"""
TEST_NAME = "Rejected Log"
############# File Definitions ###############################################
mainpage = """
<html>
@ -93,7 +92,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test--spider-r.py Executable file → Normal file
View File

@ -6,7 +6,6 @@ from misc.wget_file import WgetFile
"""
This test executed Wget in Spider mode with recursive retrieval.
"""
TEST_NAME = "Recursive Spider"
############# File Definitions ###############################################
mainpage = """
<html>
@ -97,7 +96,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-504.py Executable file → Normal file
View File

@ -18,7 +18,6 @@ from misc.wget_file import WgetFile
considered 504 as a general Server Error, it would be a fatal failure and
Wget would request File1 only once.
"""
TEST_NAME = "504 Gateway Timeouts"
############# File Definitions ###############################################
File1 = """All happy families are alike;
Each unhappy family is unhappy in its own way"""
@ -63,7 +62,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-Content-disposition-2.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures that Wget parses the Content-Disposition header
correctly and creates the appropriate file when the said filename exists.
"""
TEST_NAME = "Content Disposition Clobber"
############# File Definitions ###############################################
File1 = "Teapot"
File2 = "The Teapot Protocol"
@ -45,7 +44,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-Content-disposition.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures that Wget parses the Content-Disposition header
correctly and creates a local file accordingly.
"""
TEST_NAME = "Content Disposition Header"
############# File Definitions ###############################################
File1 = """All that is gold does not glitter,
Not all those who wander are lost;
@ -47,7 +46,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-Head.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures that Wget correctly handles responses to HEAD requests
and does not actually download any data
"""
TEST_NAME = "HEAD Requests"
############# File Definitions ###############################################
File1 = "You shall not pass!"
@ -35,7 +34,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-O.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures that Wget correctly handles the -O command for output
filenames.
"""
TEST_NAME = "Output Filename Command"
############# File Definitions ###############################################
File1 = "Test Contents."
@ -36,7 +35,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-Parallel-Proto.py Executable file → Normal file
View File

@ -8,7 +8,6 @@ from misc.wget_file import WgetFile
This is a Prototype Test File for multiple servers.
Ideally this File should be copied and edited to write new tests.
"""
TEST_NAME = "Parallel Prototype"
############# File Definitions ###############################################
File1 = "Would you like some Tea?"
File2 = "With lemon or cream?"
@ -44,7 +43,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test,

2
testenv/Test-Post.py Executable file → Normal file
View File

@ -6,7 +6,6 @@ from misc.wget_file import WgetFile
"""
Simple test for HTTP POST Requests usiong the --method command
"""
TEST_NAME = "HTTP POST Requests"
############# File Definitions ###############################################
File1 = """A reader lives a thousand lives before he dies, said Jojen.
The man who never reads lives only one"""
@ -39,7 +38,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-Proto.py Executable file → Normal file
View File

@ -8,7 +8,6 @@ from misc.wget_file import WgetFile
This is a Prototype Test File.
Ideally this File should be copied and edited to write new tests.
"""
TEST_NAME = "Prototype"
############# File Definitions ###############################################
File1 = "Would you like some Tea?"
File2 = "With lemon or cream?"
@ -65,7 +64,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test,

2
testenv/Test-auth-basic-fail.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures that Wget returns the correct exit code when Basic
authentcation failes due to a username/password error.
"""
TEST_NAME = "Basic Authentication Failure"
############# File Definitions ###############################################
File1 = "I am an invisble man."
@ -42,7 +41,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-auth-basic.py Executable file → Normal file
View File

@ -8,7 +8,6 @@ from misc.wget_file import WgetFile
Also, we ensure that Wget saves the host after a successfull auth and
doesn't wait for a challenge the second time.
"""
TEST_NAME = "Basic Authorization"
############# File Definitions ###############################################
File1 = "I am an invisble man."
File2 = "I too am an invisible man."
@ -50,7 +49,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-auth-both.py Executable file → Normal file
View File

@ -8,7 +8,6 @@ from misc.wget_file import WgetFile
Also, we ensure that Wget saves the host after a successfull auth and
doesn't wait for a challenge the second time.
"""
TEST_NAME = "Multiple authentication support"
############# File Definitions ###############################################
File1 = "Would you like some Tea?"
File2 = "With lemon or cream?"
@ -78,7 +77,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-auth-digest.py Executable file → Normal file
View File

@ -6,7 +6,6 @@ from misc.wget_file import WgetFile
"""
This test ensures Wget's Digest Authorization Negotiation.
"""
TEST_NAME = "Digest Authorization"
############# File Definitions ###############################################
File1 = "Need a cookie?"
File2 = "Want cookies with milk!"
@ -57,7 +56,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-auth-no-challenge-url.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures Wget's Basic Authorization Negotiation, when credentials
are provided in-URL
"""
TEST_NAME = "Auth no challenge in URL"
############# File Definitions ###############################################
File1 = "Need a cookie?"
@ -45,7 +44,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-auth-no-challenge.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures Wget's Basic Authorization Negotiation, when the
--auth-no-challenge command is used.
"""
TEST_NAME = "Auth No Challenge Command"
############# File Definitions ###############################################
File1 = "Need a cookie?"
@ -45,7 +44,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-auth-retcode.py Executable file → Normal file
View File

@ -8,7 +8,6 @@ from misc.wget_file import WgetFile
a 403 Forbidden by the Server.
"""
TEST_NAME = "Forbidden Retcode"
############# File Definitions ###############################################
File1 = "Apples and Oranges? Really?"
@ -41,7 +40,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-auth-with-content-disposition.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures that Wget handles Content-Disposition correctly when
coupled with Authentication
"""
TEST_NAME = "Authentication with Content Disposition"
############# File Definitions ###############################################
File1 = "Need a cookie?"
@ -45,7 +44,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-c-full.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
Test Wget's response when the file requested already exists on disk with
a filesize greater than or equal to the requested file.
"""
TEST_NAME = "Test continue option"
############# File Definitions ###############################################
File1 = "abababababababababababababababababababababababababababababababababab"
File2 = "ababababababababababababababababababab"
@ -44,7 +43,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-condget.py Executable file → Normal file
View File

@ -6,7 +6,6 @@ from misc.wget_file import WgetFile
"""
Simple test for HTTP Conditional-GET Requests using the -N command
"""
TEST_NAME = "HTTP Conditional-GET Requests"
############# File Definitions ###############################################
# Keep same length !
Cont1 = """THIS IS 1 FILE"""
@ -131,7 +130,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-cookie-401.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures that Wget stores the cookie even in the event of a
401 Unauthorized Response
"""
TEST_NAME = "Basic Cookie 401 Response"
############# File Definitions ###############################################
File1 = """All happy families are alike;
Each unhappy family is unhappy in its own way"""
@ -50,7 +49,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-cookie-domain-mismatch.py Executable file → Normal file
View File

@ -7,7 +7,6 @@ from misc.wget_file import WgetFile
This test ensures that Wget identifies bad servers trying to set cookies
for a different domain and rejects them.
"""
TEST_NAME = "Cookie Domain Mismatch"
############# File Definitions ###############################################
File1 = "Would you care for a cup of coffee?"
File2 = "Anyone for chocochip cookies?"
@ -49,7 +48,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-cookie-expires.py Executable file → Normal file
View File

@ -8,7 +8,6 @@ from misc.wget_file import WgetFile
Simultaneuously, we also check if multiple cookies to the same domain
are handled correctly
"""
TEST_NAME = "Cookie Expires"
############# File Definitions ###############################################
File1 = "Hello World!"
File2 = "'Ello! This is Amazing!"
@ -72,7 +71,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-cookie.py Executable file → Normal file
View File

@ -6,7 +6,6 @@ from misc.wget_file import WgetFile
"""
This test ensures that Wget's cookie jar support works correctly.
"""
TEST_NAME = "Basic Cookie Functionality"
############# File Definitions ###############################################
File1 = """All happy families are alike;
Each unhappy family is unhappy in its own way"""
@ -48,7 +47,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-hsts.py Executable file → Normal file
View File

@ -10,7 +10,6 @@ import os
This test makes sure Wget can parse a given HSTS database and apply the indicated HSTS policy.
"""
TEST_NAME = "HSTS basic test"
print (os.getenv('SSL_TESTS'))
if os.getenv('SSL_TESTS') is None:
exit (77)
@ -63,7 +62,6 @@ test_options = {
}
test = HTTPTest(
name = TEST_NAME,
pre_hook = pre_test,
post_hook = post_test,
test_params = test_options,

2
testenv/Test-metalink-http.py Executable file → Normal file
View File

@ -9,7 +9,6 @@ from base64 import b64encode
"""
This is to test Metalink as HTTP file support in Wget.
"""
TEST_NAME = "Metalink in HTTP"
# Helper function for hostname, port and digest substitution
def SubstituteServerInfo (text, host, port, digest):
@ -109,7 +108,6 @@ post_test = {
}
http_test = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test,

2
testenv/Test-metalink-xml.py Executable file → Normal file
View File

@ -8,7 +8,6 @@ import hashlib
"""
This is to test Metalink as XML file support in Wget.
"""
TEST_NAME = "Metalink in XML"
############# File Definitions ###############################################
File1 = "Would you like some Tea?"
File1_lowPref = "Do not take this"
@ -69,7 +68,6 @@ post_test = {
}
http_test = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test,

2
testenv/Test-redirect-crash.py Executable file → Normal file
View File

@ -20,7 +20,6 @@ redirected = [
"File%20formats/Images/SVG,%20Scalable%20Vector%20Graphics/html,%20W3C%20v1.2%20rec%20(tiny)/directory/"
]
TEST_NAME = "Redirection crash"
############# File Definitions ###############################################
Index = ""
for i in urls:
@ -65,7 +64,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

2
testenv/Test-reserved-chars.py Executable file → Normal file
View File

@ -11,7 +11,6 @@ This test ensures that Wget keeps reserved characters in URLs in non-UTF-8 chars
# so we need to set LC_ALL="C" in order to reproduce it.
environ["LC_ALL"] = "C"
TEST_NAME = "URLs with reserved characters"
######### File Definitions #########
RequestList = [
[
@ -50,7 +49,6 @@ post_test = {
}
err = HTTPTest (
name=TEST_NAME,
pre_hook=pre_test,
test_params=test_options,
post_hook=post_test

View File

@ -4,6 +4,7 @@ import shlex
import traceback
import re
import time
import sys
from subprocess import call
from misc.colour_terminal import print_red, print_blue
from exc.test_failed import TestFailed
@ -22,12 +23,12 @@ class BaseTest:
* instantiate_server_by(protocol)
"""
def __init__(self, name, pre_hook, test_params, post_hook, protocols, req_protocols):
def __init__(self, pre_hook, test_params, post_hook, protocols, req_protocols):
"""
Define the class-wide variables (or attributes).
Attributes should not be defined outside __init__.
"""
self.name = name
self.name = os.path.basename(os.path.realpath(sys.argv[0]))
# if pre_hook == None, then {} (an empty dict object) is passed to
# self.pre_configs
self.pre_configs = pre_hook or {}

View File

@ -13,14 +13,12 @@ class HTTPTest(BaseTest):
# immediately after the call to Wget returns.
def __init__(self,
name="Unnamed Test",
pre_hook=None,
test_params=None,
post_hook=None,
protocols=(HTTP,),
req_protocols=None):
super(HTTPTest, self).__init__(name,
pre_hook,
super(HTTPTest, self).__init__(pre_hook,
test_params,
post_hook,
protocols,