提交 ae272b29 编写于 作者: L Lukáš Doktor

loader: Avoid using "name" for the to-be-executed file in SimpleTest

Currently simpletest uses the "name" to define which file will be
executed as the binary. This does not look right and can break in case
one postprocesses the names in the testsuite. Let's introduce an
argument to define the name and (for now) fall-back to "name.name" in
case it's "None".
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 96ea5ef1
......@@ -879,7 +879,8 @@ class FileLoader(TestLoader):
# Module does not have an avocado test class inside but
# it's executable, let's execute it.
return self._make_test(test.SimpleTest, test_path,
subtests_filter=subtests_filter)
subtests_filter=subtests_filter,
executable=test_path)
else:
# Module does not have an avocado test class inside, and
# it's not executable. Not a Test.
......@@ -896,25 +897,29 @@ class FileLoader(TestLoader):
# Module can't be imported, and it's executable. Let's try to
# execute it.
return self._make_test(test.SimpleTest, test_path,
subtests_filter=subtests_filter)
subtests_filter=subtests_filter,
executable=test_path)
else:
return make_broken(NotATest, test_path, self.__not_test_str)
@staticmethod
def _make_test(klass, uid, description=None, subtests_filter=None):
def _make_test(klass, uid, description=None, subtests_filter=None,
**test_arguments):
"""
Create test template
:param klass: test class
:param uid: test uid (by default used as id and name)
:param description: Description appended to "uid" (for listing purpose)
:param subtests_filter: optional filter of methods for avocado tests
:param test_arguments: arguments to be passed to the klass(test_arguments)
"""
if subtests_filter and not subtests_filter.search(uid):
return []
if description:
uid = "%s: %s" % (uid, description)
return [(klass, {'name': uid})]
test_arguments["name"] = uid
return [(klass, test_arguments)]
def _make_tests(self, test_path, list_non_tests, subtests_filter=None):
"""
......@@ -942,7 +947,8 @@ class FileLoader(TestLoader):
else:
if os.access(test_path, os.X_OK):
return self._make_test(test.SimpleTest, test_path,
subtests_filter=subtests_filter)
subtests_filter=subtests_filter,
executable=test_path)
else:
return make_broken(NotATest, test_path,
self.__not_test_str)
......
......@@ -1101,7 +1101,11 @@ class SimpleTest(Test):
DATA_SOURCES = ["variant", "file"]
def __init__(self, name, params=None, base_logdir=None, job=None):
def __init__(self, name, params=None, base_logdir=None, job=None,
executable=None):
if executable is None:
executable = name.name
self._filename = executable
super(SimpleTest, self).__init__(name=name, params=params,
base_logdir=base_logdir, job=job)
self._data_sources_mapping = {"variant": [lambda: self.datadir,
......@@ -1116,7 +1120,7 @@ class SimpleTest(Test):
"""
Returns the name of the file (path) that holds the current test
"""
return os.path.abspath(self.name.name)
return os.path.abspath(self._filename)
def _log_detailed_cmd_info(self, result):
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册