mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1311991 - Add a basic cramtest mach command, r=gps
This is a pretty bad runner. My goal for now is to get something really basic working and then improve it over time as more tests get added. Run tests with: ./mach cramtest path/to/dir Any extra args will be forwarded to the cram binary, e.g: ./mach cramtest -i path/to/dir Cram help can be seen with: ./mach python -m cram -- -h MozReview-Commit-ID: 67jYHfYQjWu --HG-- extra : rebase_source : 1ee1dc5ddcdc4559402be019996bd757afe824ab
This commit is contained in:
parent
57303dc36f
commit
67e137395b
@ -6,6 +6,7 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
@ -511,6 +512,45 @@ class JsapiTestsCommand(MachCommandBase):
|
||||
return jsapi_tests_result
|
||||
|
||||
|
||||
@CommandProvider
|
||||
class CramTest(MachCommandBase):
|
||||
@Command('cramtest', category='testing',
|
||||
description="Mercurial style .t tests for command line applications.")
|
||||
@CommandArgument('test_paths', nargs='*', metavar='N',
|
||||
help="Test paths to run. Each path can be a test file or directory. "
|
||||
"If omitted, the entire suite will be run.")
|
||||
@CommandArgument('cram_args', nargs=argparse.REMAINDER,
|
||||
help="Extra arguments to pass down to the cram binary. See "
|
||||
"'./mach python -m cram -- -h' for a list of available options.")
|
||||
def cramtest(self, cram_args=None, test_paths=None, test_objects=None):
|
||||
self._activate_virtualenv()
|
||||
import mozinfo
|
||||
from manifestparser import TestManifest
|
||||
|
||||
if test_objects is None:
|
||||
from mozbuild.testing import TestResolver
|
||||
resolver = self._spawn(TestResolver)
|
||||
if test_paths:
|
||||
# If we were given test paths, try to find tests matching them.
|
||||
test_objects = resolver.resolve_tests(paths=test_paths, flavor='cram')
|
||||
else:
|
||||
# Otherwise just run everything in CRAMTEST_MANIFESTS
|
||||
test_objects = resolver.resolve_tests(flavor='cram')
|
||||
|
||||
if not test_objects:
|
||||
message = 'No tests were collected, check spelling of the test paths.'
|
||||
self.log(logging.WARN, 'cramtest', {}, message)
|
||||
return 1
|
||||
|
||||
mp = TestManifest()
|
||||
mp.tests.extend(test_objects)
|
||||
tests = mp.active_tests(disabled=False, **mozinfo.info)
|
||||
|
||||
python = self.virtualenv_manager.python_path
|
||||
cmd = [python, '-m', 'cram'] + cram_args + [t['relpath'] for t in tests]
|
||||
return subprocess.call(cmd, cwd=self.topsrcdir)
|
||||
|
||||
|
||||
def get_parser(argv=None):
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument(dest="suite_name",
|
||||
|
Loading…
Reference in New Issue
Block a user