Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/run.py
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-12-03 14:01:09 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-03 14:01:09 (GMT)
commitb61ccac7a65e807e89257ca3274e97a23030657c (patch)
treecac6de54198c16c50f9ccf4782d5348744441db9 /devbot/run.py
parent862a50854740ae40365602f9718eb26bcf16c194 (diff)
Use sugar-runner for ui tests
Diffstat (limited to 'devbot/run.py')
-rw-r--r--devbot/run.py55
1 files changed, 50 insertions, 5 deletions
diff --git a/devbot/run.py b/devbot/run.py
index e6699c8..9f52bbf 100644
--- a/devbot/run.py
+++ b/devbot/run.py
@@ -3,14 +3,13 @@
import os
import string
import random
+import shutil
+import subprocess
+import time
from devbot import environ
from devbot import config
-def run(args):
- environ.setup()
- os.execlp(args[0], *args)
-
def run_sugar():
profile_env = os.environ.get("SUGAR_PROFILE", None)
profile_pref = config.get_pref("PROFILE")
@@ -22,6 +21,8 @@ def run_sugar():
print "Cannot run two instances with the same profile."
return
+ environ.setup()
+
args = ["sugar-runner"]
resolution = config.get_pref("RESOLUTION")
@@ -32,7 +33,51 @@ def run_sugar():
if output:
args.extend(["--output", output])
- run(args)
+ os.execlp(args[0], *args)
+
+def run_test(test_path, virtual=False):
+ os.environ["SUGAR_LOGGER_LEVEL"] = "debug"
+ os.environ["SUGAR_PROFILE"] = "uitests"
+ os.environ["GTK_MODULES"] = "gail:atk-bridge"
+
+ environ.setup()
+
+ args = ["sugar-runner"]
+ if virtual:
+ args.append("--virtual")
+
+ sugar_process = subprocess.Popen(args, stdout=subprocess.PIPE)
+ for i in range(0, 2):
+ line = sugar_process.stdout.readline()
+ name, value = line.split("=", 1)
+ os.environ[name.strip()] = value.strip()
+
+ profile_path = os.path.expanduser("~/.sugar/uitests")
+ shutil.rmtree(profile_path, ignore_errors=True)
+
+ time.sleep(5)
+
+ try:
+ subprocess.check_call(["python", test_path])
+ result = True
+ except subprocess.CalledProcessError:
+ result = False
+
+ sugar_proces.terminate()
+
+ logs = {}
+ logs_path = os.path.join(profile_path, "logs")
+ for filename in os.listdir(logs_path):
+ if filename.endswith(".log"):
+ path = os.path.join(logs_path, filename)
+ with open(path) as f:
+ logs[filename] = f.read()
+
+ with open(os.path.join(config.logs_dir, "test.log"), "w") as f:
+ for filename, log in logs.items():
+ f.write("===== %s =====\n\n%s" % (filename, log))
+
+ return result
def _get_random_id():
return ''.join(random.choice(string.letters) for i in xrange(8))