diff options
author | Florian Hahn <flo@fhahn.com> | 2016-01-28 00:58:15 +0100 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2016-02-04 16:00:09 +0100 |
commit | dfdbcabc2e9803a1beb975af8c3aa37331476f85 (patch) | |
tree | 5ee88933118bfa47d0b18c110489c7c05852bf31 /python/servo/testing_commands.py | |
parent | 46b3eb653579a40632f91497a3d48f1d7fbd40cc (diff) | |
download | servo-dfdbcabc2e9803a1beb975af8c3aa37331476f85.tar.gz servo-dfdbcabc2e9803a1beb975af8c3aa37331476f85.zip |
Add infrastructure for compiletests
Also adds compilefail tests for some lints, closes #5646.
Diffstat (limited to 'python/servo/testing_commands.py')
-rw-r--r-- | python/servo/testing_commands.py | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 142a59e766f..d9d26366d20 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -109,7 +109,10 @@ class MachCommands(CommandBase): "include_arg": "include"}), ("unit", {"kwargs": {}, "paths": [path.abspath(path.join("tests", "unit"))], - "include_arg": "test_name"}) + "include_arg": "test_name"}), + ("compiletest", {"kwargs": {"release": release}, + "paths": [path.abspath(path.join("tests", "compiletest"))], + "include_arg": "test_name"}) ]) suites_by_prefix = {path: k for k, v in suites.iteritems() if "paths" in v for path in v["paths"]} @@ -207,6 +210,65 @@ class MachCommands(CommandBase): if result != 0: return result + @Command('test-compiletest', + description='Run compiletests', + category='testing') + @CommandArgument('--package', '-p', default=None, help="Specific package to test") + @CommandArgument('test_name', nargs=argparse.REMAINDER, + help="Only run tests that match this pattern or file path") + @CommandArgument('--release', default=False, action="store_true", + help="Run with a release build of servo") + def test_compiletest(self, test_name=None, package=None, release=False): + if test_name is None: + test_name = [] + + self.ensure_bootstrapped() + + if package: + packages = {package} + else: + packages = set() + + test_patterns = [] + for test in test_name: + # add package if 'tests/compiletest/<package>' + match = re.search("tests/compiletest/(\\w+)/?$", test) + if match: + packages.add(match.group(1)) + # add package & test if '<package>/<test>', 'tests/compiletest/<package>/<test>.rs', or similar + elif re.search("\\w/\\w", test): + tokens = test.split("/") + packages.add(tokens[-2]) + test_prefix = tokens[-1] + if test_prefix.endswith(".rs"): + test_prefix = test_prefix[:-3] + test_prefix += "::" + test_patterns.append(test_prefix) + # add test as-is otherwise + else: + test_patterns.append(test) + + if not packages: + packages = set(os.listdir(path.join(self.context.topdir, "tests", "compiletest"))) + + packages.remove("helper") + + args = ["cargo", "test"] + for crate in packages: + args += ["-p", "%s_compiletest" % crate] + args += test_patterns + + env = self.build_env() + if release: + env["BUILD_MODE"] = "release" + args += ["--release"] + else: + env["BUILD_MODE"] = "debug" + + result = call(args, env=env, cwd=self.servo_crate()) + if result != 0: + return result + @Command('test-ref', description='Run the reference tests', category='testing') |