mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-17 21:06:17 +00:00
validate: launcher: Introduce new parameter for log file redirecting
Allow log file redirection through the new --redirect-logs parameter. Keep the old --logs-dir stdout/stderr parameter, but reset to the default logs directory in that case, and set redirect_logs internally. This also prevents the creation of an stdout/stderr directory for writing xunit.xml. https://bugzilla.gnome.org/show_bug.cgi?id=742973
This commit is contained in:
parent
10fe72aa52
commit
4e0388c631
4 changed files with 28 additions and 20 deletions
|
@ -86,7 +86,7 @@ class Test(Loggable):
|
||||||
" You can reproduce with: %s %s\n" \
|
" You can reproduce with: %s %s\n" \
|
||||||
% (self.message, self._env_variable, self.command)
|
% (self.message, self._env_variable, self.command)
|
||||||
|
|
||||||
if not self.reporter.uses_standard_output():
|
if not self.options.redirect_logs:
|
||||||
string += " You can find logs in:\n" \
|
string += " You can find logs in:\n" \
|
||||||
" - %s" % (self.logfile)
|
" - %s" % (self.logfile)
|
||||||
for log in self.extra_logfiles:
|
for log in self.extra_logfiles:
|
||||||
|
@ -244,7 +244,7 @@ class Test(Loggable):
|
||||||
message = "Launching: %s%s\n" \
|
message = "Launching: %s%s\n" \
|
||||||
" Command: '%s %s'\n" % (Colors.ENDC, self.classname,
|
" Command: '%s %s'\n" % (Colors.ENDC, self.classname,
|
||||||
self._env_variable, self.command)
|
self._env_variable, self.command)
|
||||||
if not self.reporter.uses_standard_output():
|
if not self.options.redirect_logs:
|
||||||
message += " Logs:\n" \
|
message += " Logs:\n" \
|
||||||
" - %s" % (self.logfile)
|
" - %s" % (self.logfile)
|
||||||
for log in self.extra_logfiles:
|
for log in self.extra_logfiles:
|
||||||
|
@ -266,7 +266,7 @@ class Test(Loggable):
|
||||||
self._kill_subprocess()
|
self._kill_subprocess()
|
||||||
self.time_taken = time.time() - self._starting_time
|
self.time_taken = time.time() - self._starting_time
|
||||||
|
|
||||||
if not self.reporter.uses_standard_output():
|
if not self.options.redirect_logs:
|
||||||
self.reporter.out.seek(0)
|
self.reporter.out.seek(0)
|
||||||
self.reporter.out.write("=================\n"
|
self.reporter.out.write("=================\n"
|
||||||
"Test name: %s\n"
|
"Test name: %s\n"
|
||||||
|
@ -320,7 +320,7 @@ class GstValidateTest(Test):
|
||||||
self.scenario = scenario
|
self.scenario = scenario
|
||||||
|
|
||||||
def get_subproc_env(self):
|
def get_subproc_env(self):
|
||||||
if self.reporter.uses_standard_output():
|
if self.options.redirect_logs:
|
||||||
self.validatelogs = os.path.join(
|
self.validatelogs = os.path.join(
|
||||||
tempfile.gettempdir(), 'tmp.validate.logs')
|
tempfile.gettempdir(), 'tmp.validate.logs')
|
||||||
logfiles = self.validatelogs
|
logfiles = self.validatelogs
|
||||||
|
@ -337,7 +337,7 @@ class GstValidateTest(Test):
|
||||||
self.extra_logfiles.append(self.validatelogs)
|
self.extra_logfiles.append(self.validatelogs)
|
||||||
|
|
||||||
if 'GST_DEBUG' in os.environ and \
|
if 'GST_DEBUG' in os.environ and \
|
||||||
not self.reporter.uses_standard_output():
|
not self.options.redirect_logs:
|
||||||
gstlogsfile = self.logfile + '.gstdebug'
|
gstlogsfile = self.logfile + '.gstdebug'
|
||||||
self.extra_logfiles.append(gstlogsfile)
|
self.extra_logfiles.append(gstlogsfile)
|
||||||
subproc_env["GST_DEBUG_FILE"] = gstlogsfile
|
subproc_env["GST_DEBUG_FILE"] = gstlogsfile
|
||||||
|
@ -348,7 +348,7 @@ class GstValidateTest(Test):
|
||||||
|
|
||||||
def clean(self, full=True):
|
def clean(self, full=True):
|
||||||
Test.clean(self, full=full)
|
Test.clean(self, full=full)
|
||||||
if self.reporter.uses_standard_output():
|
if hasattr(self, 'validatelogs') and not self.options.redirect_logs:
|
||||||
try:
|
try:
|
||||||
os.remove(self.validatelogs)
|
os.remove(self.validatelogs)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -921,8 +921,6 @@ class _TestsLauncher(Loggable):
|
||||||
|
|
||||||
def set_settings(self, options, args):
|
def set_settings(self, options, args):
|
||||||
self.reporter = reporters.XunitReporter(options)
|
self.reporter = reporters.XunitReporter(options)
|
||||||
if not options.logsdir in[sys.stderr, sys.stdout]:
|
|
||||||
mkdir(options.logsdir)
|
|
||||||
|
|
||||||
self.options = options
|
self.options = options
|
||||||
wanted_testers = None
|
wanted_testers = None
|
||||||
|
@ -1140,7 +1138,7 @@ class ScenarioManager(Loggable):
|
||||||
"""
|
"""
|
||||||
scenarios = []
|
scenarios = []
|
||||||
scenario_defs = os.path.join(self.config.main_dir, "scenarios.def")
|
scenario_defs = os.path.join(self.config.main_dir, "scenarios.def")
|
||||||
if self.config.logsdir in ["stdout", "stderr"]:
|
if self.config.redirect_logs:
|
||||||
logs = open(os.devnull)
|
logs = open(os.devnull)
|
||||||
else:
|
else:
|
||||||
logs = open(
|
logs = open(
|
||||||
|
|
|
@ -57,7 +57,7 @@ class HTTPServer(loggable.Loggable):
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
""" Start the server in a subprocess """
|
""" Start the server in a subprocess """
|
||||||
if self.options.logsdir in ["stdout", "stderr"]:
|
if self.options.redirect_logs:
|
||||||
self.info("Using devnull as HTTP server log file")
|
self.info("Using devnull as HTTP server log file")
|
||||||
self._logsfile = tempfile.TemporaryFile()
|
self._logsfile = tempfile.TemporaryFile()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -208,6 +208,7 @@ class LauncherConfig(Loggable):
|
||||||
self.main_dir = utils.DEFAULT_MAIN_DIR
|
self.main_dir = utils.DEFAULT_MAIN_DIR
|
||||||
self.output_dir = None
|
self.output_dir = None
|
||||||
self.logsdir = None
|
self.logsdir = None
|
||||||
|
self.redirect_logs = False
|
||||||
self.dest = None
|
self.dest = None
|
||||||
self._using_default_paths = False
|
self._using_default_paths = False
|
||||||
self.paths = []
|
self.paths = []
|
||||||
|
@ -240,6 +241,10 @@ class LauncherConfig(Loggable):
|
||||||
self.output_dir = os.path.abspath(self.output_dir)
|
self.output_dir = os.path.abspath(self.output_dir)
|
||||||
|
|
||||||
# other output directories
|
# other output directories
|
||||||
|
if self.logsdir in ['stdout', 'stderr']:
|
||||||
|
# Allow -l stdout/stderr to work like -rl stdout/stderr
|
||||||
|
self.redirect_logs = self.logsdir
|
||||||
|
self.logsdir = None
|
||||||
if self.logsdir is None:
|
if self.logsdir is None:
|
||||||
self.logsdir = os.path.join(self.output_dir, "logs")
|
self.logsdir = os.path.join(self.output_dir, "logs")
|
||||||
if self.xunit_file is None:
|
if self.xunit_file is None:
|
||||||
|
@ -249,6 +254,14 @@ class LauncherConfig(Loggable):
|
||||||
|
|
||||||
if not os.path.exists(self.dest):
|
if not os.path.exists(self.dest):
|
||||||
os.makedirs(self.dest)
|
os.makedirs(self.dest)
|
||||||
|
if not os.path.exists(self.logsdir):
|
||||||
|
os.makedirs(self.logsdir)
|
||||||
|
|
||||||
|
if not self.redirect_logs in ['stdout', 'stderr', False]:
|
||||||
|
printc("Log redirection (%s) must be either 'stdout' or 'stderr'."
|
||||||
|
% self.redirect_logs, Colors.FAIL, True)
|
||||||
|
return False
|
||||||
|
|
||||||
if urlparse.urlparse(self.dest).scheme == "":
|
if urlparse.urlparse(self.dest).scheme == "":
|
||||||
self.dest = path2url(self.dest)
|
self.dest = path2url(self.dest)
|
||||||
|
|
||||||
|
@ -398,9 +411,7 @@ Note that all testsuite should be inside python modules, so the directory should
|
||||||
dir_group.add_argument("-o", "--output-dir", dest="output_dir",
|
dir_group.add_argument("-o", "--output-dir", dest="output_dir",
|
||||||
help="Directory where to store logs and rendered files. Default is MAIN_DIR")
|
help="Directory where to store logs and rendered files. Default is MAIN_DIR")
|
||||||
dir_group.add_argument("-l", "--logs-dir", dest="logsdir",
|
dir_group.add_argument("-l", "--logs-dir", dest="logsdir",
|
||||||
help="Directory where to store logs, default is OUTPUT_DIR/logs."
|
help="Directory where to store logs, default is OUTPUT_DIR/logs.")
|
||||||
" Note that 'stdout' and 'sdterr' are valid values that lets you get all the logs"
|
|
||||||
" printed in the terminal")
|
|
||||||
dir_group.add_argument("-R", "--render-path", dest="dest",
|
dir_group.add_argument("-R", "--render-path", dest="dest",
|
||||||
help="Set the path to which projects should be rendered, default is OUTPUT_DIR/rendered")
|
help="Set the path to which projects should be rendered, default is OUTPUT_DIR/rendered")
|
||||||
dir_group.add_argument("-p", "--medias-paths", dest="paths", action="append",
|
dir_group.add_argument("-p", "--medias-paths", dest="paths", action="append",
|
||||||
|
@ -408,6 +419,8 @@ Note that all testsuite should be inside python modules, so the directory should
|
||||||
dir_group.add_argument("-a", "--clone-dir", dest="clone_dir",
|
dir_group.add_argument("-a", "--clone-dir", dest="clone_dir",
|
||||||
help="Paths where to clone the testuite to run "
|
help="Paths where to clone the testuite to run "
|
||||||
" default is MAIN_DIR/gst-integration-testsuites")
|
" default is MAIN_DIR/gst-integration-testsuites")
|
||||||
|
dir_group.add_argument("-rl", "--redirect-logs", dest="redirect_logs",
|
||||||
|
help="Redirect logs to 'stdout' or 'sdterr'.")
|
||||||
|
|
||||||
http_server_group = parser.add_argument_group(
|
http_server_group = parser.add_argument_group(
|
||||||
"Handle the HTTP server to be created")
|
"Handle the HTTP server to be created")
|
||||||
|
|
|
@ -66,15 +66,12 @@ class Reporter(Loggable):
|
||||||
}
|
}
|
||||||
self.results = []
|
self.results = []
|
||||||
|
|
||||||
def uses_standard_output(self):
|
|
||||||
return self.out in [sys.stdout, sys.stderr]
|
|
||||||
|
|
||||||
def before_test(self, test):
|
def before_test(self, test):
|
||||||
"""Initialize a timer before starting a test."""
|
"""Initialize a timer before starting a test."""
|
||||||
if self.options.logsdir == 'stdout':
|
if self.options.redirect_logs == 'stdout':
|
||||||
self.out = sys.stdout
|
self.out = sys.stdout
|
||||||
test.logfile = 'stdout'
|
test.logfile = 'stdout'
|
||||||
elif self.options.logsdir == 'stderr':
|
elif self.options.redirect_logs == 'stderr':
|
||||||
self.out = sys.stderr
|
self.out = sys.stderr
|
||||||
test.logfile = 'stderr'
|
test.logfile = 'stderr'
|
||||||
else:
|
else:
|
||||||
|
@ -109,7 +106,7 @@ class Reporter(Loggable):
|
||||||
self.results.append(self._current_test)
|
self.results.append(self._current_test)
|
||||||
|
|
||||||
self.add_results(self._current_test)
|
self.add_results(self._current_test)
|
||||||
if not self.uses_standard_output():
|
if not self.options.redirect_logs:
|
||||||
self.out.close()
|
self.out.close()
|
||||||
|
|
||||||
self.out = None
|
self.out = None
|
||||||
|
@ -164,7 +161,7 @@ class XunitReporter(Reporter):
|
||||||
|
|
||||||
def _get_captured(self):
|
def _get_captured(self):
|
||||||
captured = ""
|
captured = ""
|
||||||
if self.out and not self.uses_standard_output():
|
if self.out and not self.options.redirect_logs:
|
||||||
self.out.seek(0)
|
self.out.seek(0)
|
||||||
value = self.out.read()
|
value = self.out.read()
|
||||||
if value:
|
if value:
|
||||||
|
|
Loading…
Reference in a new issue