aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorGlenn Watson <gw@intuitionlibrary.com>2015-05-28 11:05:02 +1000
committerGlenn Watson <gw@intuitionlibrary.com>2015-06-01 09:36:24 +1000
commitbe7ae0c7326a802bd5a86fe9b73673296399d0ed (patch)
treef8d774dc172bf45af6a2c6a39cb3b7a5b2f71f63 /python
parentb1a773a15bd2e022aa45c3672e51467e994badfe (diff)
downloadservo-be7ae0c7326a802bd5a86fe9b73673296399d0ed.tar.gz
servo-be7ae0c7326a802bd5a86fe9b73673296399d0ed.zip
Add jQuery test runner and mach integration.
Diffstat (limited to 'python')
-rw-r--r--python/servo/command_base.py38
-rw-r--r--python/servo/post_build_commands.py38
-rw-r--r--python/servo/testing_commands.py41
3 files changed, 79 insertions, 38 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py
index a46fd21dfc1..b6541830933 100644
--- a/python/servo/command_base.py
+++ b/python/servo/command_base.py
@@ -121,6 +121,44 @@ class CommandBase(object):
self._cargo_build_id = open(filename).read().strip()
return self._cargo_build_id
+ def get_binary_path(self, release, dev):
+ base_path = path.join("components", "servo", "target")
+ release_path = path.join(base_path, "release", "servo")
+ dev_path = path.join(base_path, "debug", "servo")
+
+ # Prefer release if both given
+ if release and dev:
+ dev = False
+
+ release_exists = path.exists(release_path)
+ dev_exists = path.exists(dev_path)
+
+ if not release_exists and not dev_exists:
+ print("No Servo binary found. Please run './mach build' and try again.")
+ sys.exit()
+
+ if release and release_exists:
+ return release_path
+
+ if dev and dev_exists:
+ return dev_path
+
+ if not dev and not release and release_exists and dev_exists:
+ print("You have multiple profiles built. Please specify which "
+ "one to run with '--release' or '--dev'.")
+ sys.exit()
+
+ if not dev and not release:
+ if release_exists:
+ return release_path
+ else:
+ return dev_path
+
+ print("The %s profile is not built. Please run './mach build%s' "
+ "and try again." % ("release" if release else "dev",
+ " --release" if release else ""))
+ sys.exit()
+
def build_env(self, gonk=False, hosts_file_path=None):
"""Return an extended environment dictionary."""
env = os.environ.copy()
diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py
index 385e71ebee7..5105fda0ff1 100644
--- a/python/servo/post_build_commands.py
+++ b/python/servo/post_build_commands.py
@@ -32,44 +32,6 @@ def read_file(filename, if_exists=False):
@CommandProvider
class MachCommands(CommandBase):
- def get_binary_path(self, release, dev):
- base_path = path.join("components", "servo", "target")
- release_path = path.join(base_path, "release", "servo")
- dev_path = path.join(base_path, "debug", "servo")
-
- # Prefer release if both given
- if release and dev:
- dev = False
-
- release_exists = path.exists(release_path)
- dev_exists = path.exists(dev_path)
-
- if not release_exists and not dev_exists:
- print("No Servo binary found. Please run './mach build' and try again.")
- sys.exit()
-
- if release and release_exists:
- return release_path
-
- if dev and dev_exists:
- return dev_path
-
- if not dev and not release and release_exists and dev_exists:
- print("You have multiple profiles built. Please specify which "
- "one to run with '--release' or '--dev'.")
- sys.exit()
-
- if not dev and not release:
- if release_exists:
- return release_path
- else:
- return dev_path
-
- print("The %s profile is not built. Please run './mach build%s' "
- "and try again." % ("release" if release else "dev",
- " --release" if release else ""))
- sys.exit()
-
@Command('run',
description='Run Servo',
category='post-build')
diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py
index 81361b0081f..44220022db4 100644
--- a/python/servo/testing_commands.py
+++ b/python/servo/testing_commands.py
@@ -225,6 +225,26 @@ class MachCommands(CommandBase):
execfile(run_file, run_globals)
return run_globals["update_tests"](**kwargs)
+ @Command('test-jquery',
+ description='Run the jQuery test suite',
+ category='testing')
+ @CommandArgument('--release', '-r', action='store_true',
+ help='Run the release build')
+ @CommandArgument('--dev', '-d', action='store_true',
+ help='Run the dev build')
+ def test_jquery(self, release, dev):
+ return self.jquery_test_runner("test", release, dev)
+
+ @Command('update-jquery',
+ description='Update the jQuery test suite expected results',
+ category='testing')
+ @CommandArgument('--release', '-r', action='store_true',
+ help='Run the release build')
+ @CommandArgument('--dev', '-d', action='store_true',
+ help='Run the dev build')
+ def update_jquery(self):
+ return self.jquery_test_runner("update", release, dev)
+
@Command('test-css',
description='Run the web platform tests',
category='testing',
@@ -291,3 +311,24 @@ class MachCommands(CommandBase):
return default
return path
+
+ def jquery_test_runner(self, cmd, release, dev):
+ self.ensure_bootstrapped()
+ base_dir = path.abspath(path.join("tests", "jquery"))
+ jquery_dir = path.join(base_dir, "jquery")
+ run_file = path.join(base_dir, "run_jquery.py")
+
+ # Clone the jQuery repository if it doesn't exist
+ if not os.path.isdir(jquery_dir):
+ subprocess.check_call(
+ ["git", "clone", "-b", "servo", "--depth", "1", "https://github.com/servo/jquery", jquery_dir])
+
+ # Run pull in case the jQuery repo was updated since last test run
+ subprocess.check_call(
+ ["git", "-C", jquery_dir, "pull"])
+
+ # Check that a release servo build exists
+ bin_path = path.abspath(self.get_binary_path(release, dev))
+
+ return subprocess.check_call(
+ [run_file, cmd, bin_path, base_dir])