validate:launcher: Handle launching launching a sub launcher

If you use validate-launcher in a meson testsuite, those test now
gets integrated as one unique testsuite (with a pretty long namespace).
This commit is contained in:
Thibault Saunier 2019-01-25 22:27:07 -03:00 committed by Thibault Saunier
parent 6665652cff
commit 9b69bcad08
3 changed files with 45 additions and 5 deletions

View file

@ -19,6 +19,7 @@
import argparse
import json
import os
import sys
import re
import pickle
import platform
@ -30,6 +31,7 @@ import concurrent.futures as conc
from launcher import config
from launcher.utils import printc, Colors
from launcher.main import setup_launcher_from_args
class MesonTest(Test):
@ -166,12 +168,35 @@ class MesonTestsManager(TestsManager):
mesontests = self.get_meson_tests()
for test in mesontests:
self.add_test(MesonTest(self.get_test_name(test),
self.options, self.reporter, test))
if not self.setup_tests_from_sublauncher(test):
self.add_test(MesonTest(self.get_test_name(test),
self.options, self.reporter, test))
self._registered = True
return self.tests
def setup_tests_from_sublauncher(self, test):
cmd = test['cmd']
binary = cmd[0]
sublauncher_tests = set()
if binary != sys.argv[0]:
return sublauncher_tests
res, _, tests_launcher = setup_launcher_from_args(cmd[1:], main_options=self.options)
if res is False:
return sublauncher_tests
for sublauncher_test in tests_launcher.list_tests():
name = self.get_test_name(test)
sublauncher_tests.add(name)
sublauncher_test.generator = None
sublauncher_test.options = self.options
sublauncher_test.classname = name + '.' + sublauncher_test.classname
self.add_test(sublauncher_test)
return sublauncher_tests
class GstCheckTestsManager(MesonTestsManager):
name = "check"
@ -268,7 +293,12 @@ class GstCheckTestsManager(MesonTestsManager):
self.load_tests_info()
mesontests = self.get_meson_tests()
to_inspect = []
all_sublaunchers_tests = set()
for test in mesontests:
sublauncher_tests = self.setup_tests_from_sublauncher(test)
if sublauncher_tests:
all_sublaunchers_tests |= sublauncher_tests
continue
binary = test['cmd'][0]
test_info = self.check_binary_ts(binary)
if test_info is True:
@ -296,9 +326,11 @@ class GstCheckTestsManager(MesonTestsManager):
e.result()
for test in mesontests:
name = self.get_test_name(test)
if name in all_sublaunchers_tests:
continue
gst_tests = self.tests_info[test['cmd'][0]][1]
if not gst_tests:
name = self.get_test_name(test)
child_env = self.get_child_env(name)
self.add_test(MesonTest(name, self.options, self.reporter, test,
child_env))

View file

@ -592,6 +592,7 @@ class GstValidateTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
class GstValidateListener(socketserver.BaseRequestHandler):
def handle(self):
"""Implements BaseRequestHandler handle method"""
test = None
@ -1518,6 +1519,7 @@ class _TestsLauncher(Loggable):
tester.name not in wanted_test_manager:
continue
prev_testsuite_name = TestsManager.loading_testsuite
if self.options.user_paths:
TestsManager.loading_testsuite = tester.name
tester.register_defaults()
@ -1526,7 +1528,8 @@ class _TestsLauncher(Loggable):
TestsManager.loading_testsuite = testsuite.__name__
if testsuite.setup_tests(tester, self.options):
loaded = True
TestsManager.loading_testsuite = None
if prev_testsuite_name:
TestsManager.loading_testsuite = prev_testsuite_name
if not loaded:
printc("Could not load testsuite: %s"

View file

@ -540,7 +540,7 @@ class LauncherConfig(Loggable):
return parser
def setup_launcher_from_args(args):
def setup_launcher_from_args(args, main_options=None):
loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False)
parser = LauncherConfig.create_parser()
tests_launcher = _TestsLauncher()
@ -555,6 +555,11 @@ def setup_launcher_from_args(args):
options = LauncherConfig()
parser.parse_args(args=args, namespace=options)
if main_options:
# Override output directories and logging properties of the sub launcher.
for option in ["main_dir", "output_dir", "logsdir", "dest", "clone_dir",
"redirect_logs", "verbose"]:
setattr(options, option, getattr(main_options, option))
if not options.cleanup():
return False, None, None