From c9476f1837246cfe59c7a8e262e404def7c6f533 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Fri, 28 Dec 2012 19:07:35 +0000 Subject: Make run-tests log everything --- diff --git a/commands/run-tests b/commands/run-tests index 63497be..1ac1ea4 100755 --- a/commands/run-tests +++ b/commands/run-tests @@ -10,12 +10,11 @@ import common from devbot import run from devbot import test -common.setup(log_name="test") - -def _clear_profile(): +def _get_profile(): profile_path = os.path.expanduser("~/.sugar/uitests") shutil.rmtree(profile_path, ignore_errors=True) + return profile_path def _get_test_path(name): @@ -26,6 +25,8 @@ parser = argparse.ArgumentParser() parser.add_argument("module", nargs="?", help="name of the module to test") args = parser.parse_args() +common.setup(log_name="test") + os.environ["SUGAR_LOGGER_LEVEL"] = "debug" os.environ["SUGAR_PROFILE"] = "uitests" os.environ["GTK_MODULES"] = "gail:atk-bridge" @@ -33,12 +34,15 @@ os.environ["GTK_MODULES"] = "gail:atk-bridge" if args.module: test.test_one(args.module) else: + print "\n= Checking =\n" + if not test.test(): sys.exit(1) - _clear_profile() - if run.run_test("sugar-runner", _get_test_path("shell.py")): - sys.exit(1) + print "* Running UI test" - if run.collect_logs(os.path.join(profile_path, "logs")): + profile_path = _get_profile() + result = run.run_test("sugar-runner", _get_test_path("shell.py")) + run.collect_logs(os.path.join(profile_path, "logs")) + if not result: sys.exit(1) diff --git a/devbot/run.py b/devbot/run.py index 23ef801..65eee8c 100644 --- a/devbot/run.py +++ b/devbot/run.py @@ -2,7 +2,6 @@ import os import string import random import subprocess -import sys import time import tempfile @@ -25,14 +24,19 @@ def run(cmd): def run_test(test_cmd, test_path): - temp_dir = tempfile.mkdtemp("sugar-build-test") + temp_dir = tempfile.mkdtemp("devbot-test-display") display_path = os.path.join(temp_dir, "display") args = [test_cmd, "--display-path", display_path, "--virtual"] - test_cmd_process = subprocess.Popen(args, stdout=subprocess.PIPE) + output_fd, output_name = tempfile.mkstemp("devbot-test-output") + output_file = os.fdopen(output_fd) + + test_cmd_process = subprocess.Popen(args, + stdout=output_file, + stderr=subprocess.STDOUT) while True: if not os.path.exists(display_path): @@ -54,6 +58,13 @@ def run_test(test_cmd, test_path): test_cmd_process.terminate() + output_file.seek(0) + with open(config.log_path, "a") as f: + f.write(output_file.read()) + + output_file.close() + os.unlink(output_name) + return result diff --git a/devbot/test.py b/devbot/test.py index 2acd721..44ddfa6 100644 --- a/devbot/test.py +++ b/devbot/test.py @@ -31,6 +31,8 @@ def _test_module(module): result = True if module.has_tests: + print "* Checking %s" % module.name + os.chdir(module.get_build_dir()) xvfb_proc, orig_display = xvfb.start() -- cgit v0.9.1