Kaydet (Commit) bff02d54 authored tarafından Noel Grandin's avatar Noel Grandin

uitests - error if UITEST_TEST_NAME not set to anything useful

so the next poor sod who doesn't understand the instructions doesn't
waste time with the wrong way of specifying the tests

Change-Id: I9759c7f792ec80d660f70f79dc6e2589d44e360f
Reviewed-on: https://gerrit.libreoffice.org/57177
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 139750d7
...@@ -15,7 +15,10 @@ To rerun just this failed test without all others, use: ...@@ -15,7 +15,10 @@ To rerun just this failed test without all others, use:
make UITest_$2 make UITest_$2
Or to run just a specific test case method, use: Or to run just a specific test case method, use:
make UITest_$2 UITEST_TEST_NAME="package.ClassName.methodName" make UITest_$2 UITEST_TEST_NAME="Module.ClassName.methodName"
where
Module - the name of the python file (without the .py extension)
Class - is the name in the "class Class" declaration
Or to do interactive debugging, put a long sleep in the beginning of the .py Or to do interactive debugging, put a long sleep in the beginning of the .py
uitest file, and attach gdb to the running soffice process. uitest file, and attach gdb to the running soffice process.
......
...@@ -19,6 +19,8 @@ from uitest.framework import UITestCase ...@@ -19,6 +19,8 @@ from uitest.framework import UITestCase
from libreoffice.connection import OfficeConnection from libreoffice.connection import OfficeConnection
test_name_limit_found = False
def parseArgs(argv): def parseArgs(argv):
(optlist,args) = getopt.getopt(argv[1:], "hdr", (optlist,args) = getopt.getopt(argv[1:], "hdr",
["help", "debug", "soffice=", "userdir=", "dir=", "file=", "gdb"]) ["help", "debug", "soffice=", "userdir=", "dir=", "file=", "gdb"])
...@@ -73,12 +75,15 @@ def add_tests_for_file(test_file, test_suite): ...@@ -73,12 +75,15 @@ def add_tests_for_file(test_file, test_suite):
loader = importlib.machinery.SourceFileLoader(module_name, test_file) loader = importlib.machinery.SourceFileLoader(module_name, test_file)
mod = loader.load_module() mod = loader.load_module()
classes = get_test_case_classes_of_module(mod) classes = get_test_case_classes_of_module(mod)
global test_name_limit_found
for c in classes: for c in classes:
test_names = test_loader.getTestCaseNames(c) test_names = test_loader.getTestCaseNames(c)
for test_name in test_names: for test_name in test_names:
full_name = ".".join([module_name, c.__name__, test_name]) full_name = ".".join([module_name, c.__name__, test_name])
if len(test_name_limit) > 0 and not test_name_limit.startswith(full_name): if len(test_name_limit) > 0:
continue if not test_name_limit.startswith(full_name):
continue
test_name_limit_found = True
obj = c(test_name, opts) obj = c(test_name, opts)
test_suite.addTest(obj) test_suite.addTest(obj)
...@@ -102,6 +107,11 @@ if __name__ == '__main__': ...@@ -102,6 +107,11 @@ if __name__ == '__main__':
sys.exit(1) sys.exit(1)
elif "--dir" in opts: elif "--dir" in opts:
test_suite = get_test_suite_for_dir(opts) test_suite = get_test_suite_for_dir(opts)
test_name_limit = os.environ.get('UITEST_TEST_NAME', '')
print(test_name_limit_found)
if len(test_name_limit) > 0 and not test_name_limit_found:
print("UITEST_TEST_NAME '%s' does not match any test" % test_name_limit)
sys.exit(1)
elif "--file" in opts: elif "--file" in opts:
test_suite = unittest.TestSuite() test_suite = unittest.TestSuite()
add_tests_for_file(opts['--file'], test_suite) add_tests_for_file(opts['--file'], test_suite)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment