mirror of
https://github.com/mirror/wget.git
synced 2025-03-26 12:06:06 +08:00
testenv: Allow definition of environment variables for wget execuion
* testenv/README: Added description for new EnvironmentVariable hook * testenv/conf/environment_variable.py: Added implementation of EnvironmentVariable hook * testenv/test/base_test.py: Modified exec_wget() to enable use of EnvironmentVariable hook Added new test hook called EnvironmentVariables, for defining environment variables when wget is executed in tests. This is handy for testing environment variables, which are accepted by wget. Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
28196b6807
commit
8ffebe2160
testenv
@ -224,6 +224,9 @@ executed. The currently supported options are:
|
||||
file. While all Download URL's are passed to Urls, a notable exception is
|
||||
when in-url authentication is used. In such a case, the URL is specified in
|
||||
the WgetCommands string.
|
||||
* EnvironmentVariables: A dictionary with key-value items, which will be
|
||||
defined as environment variables during the execution of wget command in
|
||||
test.
|
||||
|
||||
Post-Test Hooks:
|
||||
================================================================================
|
||||
|
14
testenv/conf/environment_variables.py
Normal file
14
testenv/conf/environment_variables.py
Normal file
@ -0,0 +1,14 @@
|
||||
from conf import hook
|
||||
|
||||
""" Test Option: EnvironmentVariables
|
||||
This hook is used to define environment variables used for execution of wget
|
||||
command in test."""
|
||||
|
||||
|
||||
@hook(alias='EnvironmentVariables')
|
||||
class URLs:
|
||||
def __init__(self, envs):
|
||||
self.envs = envs
|
||||
|
||||
def __call__(self, test_obj):
|
||||
test_obj.envs.update(**self.envs)
|
@ -51,6 +51,7 @@ class BaseTest:
|
||||
|
||||
self.wget_options = ''
|
||||
self.urls = []
|
||||
self.envs = dict()
|
||||
|
||||
self.tests_passed = True
|
||||
self.ready = False
|
||||
@ -97,12 +98,15 @@ class BaseTest:
|
||||
cmd_line = self.gen_cmd_line()
|
||||
params = shlex.split(cmd_line)
|
||||
print(params)
|
||||
envs = {"HOME": os.getcwd()}
|
||||
envs.update(**self.envs)
|
||||
print(envs)
|
||||
|
||||
if os.getenv("SERVER_WAIT"):
|
||||
time.sleep(float(os.getenv("SERVER_WAIT")))
|
||||
|
||||
try:
|
||||
ret_code = call(params, env={"HOME": os.getcwd()})
|
||||
ret_code = call(params, env=envs)
|
||||
except FileNotFoundError:
|
||||
raise TestFailed("The Wget Executable does not exist at the "
|
||||
"expected path.")
|
||||
|
Loading…
Reference in New Issue
Block a user