Tests that should be able to run under multiple hooks will probably need
to distinguish which hook called them. This patch adds hook variable
into autoqa_args, so tests can easily distinguish what the required task
is.
---
autoqa | 2 ++
doc/control.autoqa.template | 2 +-
doc/control.template | 10 +++++++---
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/autoqa b/autoqa
index 4a9ce16..a718e49 100755
--- a/autoqa
+++ b/autoqa
@@ -250,6 +250,8 @@ if opts.autotest_server:
# Ask hook to determine all arguments needed for tests. These variables will
# be then written into the control file as autoqa_args dictionary.
autoqa_args = hook.process_testdata(opts, args)
+# The test may also need the very name of the hook that executes it
+autoqa_args['hook'] = hookname
# Evaluate control.autoqa file for every test to get a list of tests to execute
tests = [test for test in os.listdir(conf['testdir'])]
diff --git a/doc/control.autoqa.template b/doc/control.autoqa.template
index f084343..511909f 100644
--- a/doc/control.autoqa.template
+++ b/doc/control.autoqa.template
@@ -22,7 +22,7 @@
# though you don't want to run it, setup all other variables
# correctly, don't stop at this one
# autoqa_args: dictionary of all variables that the test itself will receive
-# (look at hooks/<hook>/README for the documentation); please
+# (look at doc/control.template for the documentation); please
# be aware that the keys you expect might not be present in the
# dictionary when some other hook evaluates this file, so always
# first check for their presence
diff --git a/doc/control.template b/doc/control.template
index 64fc5f6..e82f00e 100644
--- a/doc/control.template
+++ b/doc/control.template
@@ -22,7 +22,11 @@ TEST_CATEGORY = 'Functional'
## Job scheduling ##
# Execute the test object here. In this example this will execute
# testclassname.py file with specified arguments. This file will receive
-# autoqa_conf variable containing autoqa config file and autoqa_args dictionary
-# containing all variables provided by hook that you can conveniently explode
-# here. Read more at hooks/<hook>/README.
+# following variables:
+# * autoqa_conf: string containing autoqa config file
+# * autoqa_args: dictionary containing all variables provided by hook (read
+# more at hooks/<hook>/README) and some additional ones:
+# - hook: name of the executing hook
+# You should pass all necessary variables for your test as method arguments.
+# You can also conveniently explode the dictionary into a list of arguments.
job.run_test('testclassname', config=autoqa_conf, **autoqa_args)
--
1.7.2.1