How to use run_suites method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

mach_commands.py

Source:mach_commands.py Github

copy

Full Screen

1# This Source Code Form is subject to the terms of the Mozilla Public2# License, v. 2.0. If a copy of the MPL was not distributed with this3# file, You can obtain one at http://mozilla.org/MPL/2.0/.4from __future__ import print_function, unicode_literals5import os6import sys7from mach.decorators import (8 CommandArgument,9 CommandProvider,10 Command,11)12from mozbuild.base import MachCommandBase13UNKNOWN_TEST = '''14I was unable to find tests in the argument(s) given.15You need to specify a test directory, filename, test suite name, or16abbreviation.17It's possible my little brain doesn't know about the type of test you are18trying to execute. If you suspect this, please request support by filing19a bug at20https://bugzilla.mozilla.org/enter_bug.cgi?product=Testing&component=General.21'''.strip()22UNKNOWN_FLAVOR = '''23I know you are trying to run a %s test. Unfortunately, I can't run those24tests yet. Sorry!25'''.strip()26MOCHITEST_CHUNK_BY_DIR = 427MOCHITEST_TOTAL_CHUNKS = 528TEST_SUITES = {29 'cppunittest': {30 'aliases': ('Cpp', 'cpp'),31 'mach_command': 'cppunittest',32 'kwargs': {'test_file': None},33 },34 'crashtest': {35 'aliases': ('C', 'Rc', 'RC', 'rc'),36 'mach_command': 'crashtest',37 'kwargs': {'test_file': None},38 },39 'crashtest-ipc': {40 'aliases': ('Cipc', 'cipc'),41 'mach_command': 'crashtest-ipc',42 'kwargs': {'test_file': None},43 },44 'jetpack': {45 'aliases': ('J',),46 'mach_command': 'jetpack-test',47 'kwargs': {},48 },49 'check-spidermonkey': {50 'aliases': ('Sm', 'sm'),51 'mach_command': 'check-spidermonkey',52 'kwargs': {'valgrind': False},53 },54 'mochitest-a11y': {55 'mach_command': 'mochitest',56 'kwargs': {'flavor': 'a11y', 'test_paths': None},57 },58 'mochitest-browser': {59 'aliases': ('bc', 'BC', 'Bc'),60 'mach_command': 'mochitest-browser',61 'kwargs': {'flavor': 'browser-chrome', 'test_paths': None},62 },63 'mochitest-chrome': {64 'mach_command': 'mochitest',65 'kwargs': {'flavor': 'chrome', 'test_paths': None},66 },67 'mochitest-devtools': {68 'aliases': ('dt', 'DT', 'Dt'),69 'mach_command': 'mochitest-browser',70 'kwargs': {'subsuite': 'devtools', 'test_paths': None},71 },72 'mochitest-ipcplugins': {73 'make_target': 'mochitest-ipcplugins',74 },75 'mochitest-plain': {76 'mach_command': 'mochitest',77 'kwargs': {'flavor': 'mochitest', 'test_paths': None},78 },79 'reftest': {80 'aliases': ('RR', 'rr', 'Rr'),81 'mach_command': 'reftest',82 'kwargs': {'test_file': None},83 },84 'reftest-ipc': {85 'aliases': ('Ripc',),86 'mach_command': 'reftest-ipc',87 'kwargs': {'test_file': None},88 },89 'valgrind': {90 'aliases': ('V', 'v'),91 'mach_command': 'valgrind-test',92 'kwargs': {},93 },94 'xpcshell': {95 'aliases': ('X', 'x'),96 'mach_command': 'xpcshell-test',97 'kwargs': {'test_file': 'all'},98 },99}100# Maps test flavors to metadata on how to run that test.101TEST_FLAVORS = {102 'a11y': {103 'mach_command': 'mochitest',104 'kwargs': {'flavor': 'a11y', 'test_paths': []},105 },106 'browser-chrome': {107 'mach_command': 'mochitest',108 'kwargs': {'flavor': 'browser-chrome', 'test_paths': []},109 },110 'chrashtest': { },111 'chrome': {112 'mach_command': 'mochitest',113 'kwargs': {'flavor': 'chrome', 'test_paths': []},114 },115 'mochitest': {116 'mach_command': 'mochitest',117 'kwargs': {'flavor': 'mochitest', 'test_paths': []},118 },119 'reftest': { },120 'steeplechase': { },121 'webapprt-chrome': {122 'mach_command': 'mochitest',123 'kwargs': {'flavor': 'webapprt-chrome', 'test_paths': []},124 },125 'xpcshell': {126 'mach_command': 'xpcshell-test',127 'kwargs': {'test_paths': []},128 },129}130for i in range(1, MOCHITEST_TOTAL_CHUNKS + 1):131 TEST_SUITES['mochitest-%d' %i] = {132 'aliases': ('M%d' % i, 'm%d' % i),133 'mach_command': 'mochitest',134 'kwargs': {135 'flavor': 'mochitest',136 'chunk_by_dir': MOCHITEST_CHUNK_BY_DIR,137 'total_chunks': MOCHITEST_TOTAL_CHUNKS,138 'this_chunk': i,139 'test_paths': None,140 },141 }142TEST_HELP = '''143Test or tests to run. Tests can be specified by filename, directory, suite144name or suite alias.145The following test suites and aliases are supported: %s146''' % ', '.join(sorted(TEST_SUITES))147TEST_HELP = TEST_HELP.strip()148@CommandProvider149class Test(MachCommandBase):150 @Command('test', category='testing', description='Run tests (detects the kind of test and runs it).')151 @CommandArgument('what', default=None, nargs='*', help=TEST_HELP)152 def test(self, what):153 from mozbuild.testing import TestResolver154 # Parse arguments and assemble a test "plan."155 run_suites = set()156 run_tests = []157 resolver = self._spawn(TestResolver)158 for entry in what:159 # If the path matches the name or alias of an entire suite, run160 # the entire suite.161 if entry in TEST_SUITES:162 run_suites.add(entry)163 continue164 suitefound = False165 for suite, v in TEST_SUITES.items():166 if entry in v.get('aliases', []):167 run_suites.add(suite)168 suitefound = True169 if suitefound:170 continue171 # Now look for file/directory matches in the TestResolver.172 relpath = self._wrap_path_argument(entry).relpath()173 tests = list(resolver.resolve_tests(paths=[relpath]))174 run_tests.extend(tests)175 if not tests:176 print('UNKNOWN TEST: %s' % entry, file=sys.stderr)177 if not run_suites and not run_tests:178 print(UNKNOWN_TEST)179 return 1180 status = None181 for suite_name in run_suites:182 suite = TEST_SUITES[suite_name]183 if 'mach_command' in suite:184 res = self._mach_context.commands.dispatch(185 suite['mach_command'], self._mach_context,186 **suite['kwargs'])187 if res:188 status = res189 elif 'make_target' in suite:190 res = self._run_make(target=suite['make_target'],191 pass_thru=True)192 if res:193 status = res194 flavors = {}195 for test in run_tests:196 flavors.setdefault(test['flavor'], []).append(test)197 for flavor, tests in sorted(flavors.items()):198 if flavor not in TEST_FLAVORS:199 print(UNKNOWN_FLAVOR % flavor)200 status = 1201 continue202 m = TEST_FLAVORS[flavor]203 if 'mach_command' not in m:204 print(UNKNOWN_FLAVOR % flavor)205 status = 1206 continue207 res = self._mach_context.commands.dispatch(208 m['mach_command'], self._mach_context,209 test_objects=tests, **m['kwargs'])210 if res:211 status = res212 return status213@CommandProvider214class MachCommands(MachCommandBase):215 @Command('cppunittest', category='testing',216 description='Run cpp unit tests (C++ tests).')217 @CommandArgument('test_files', nargs='*', metavar='N',218 help='Test to run. Can be specified as one or more files or ' \219 'directories, or omitted. If omitted, the entire test suite is ' \220 'executed.')221 def run_cppunit_test(self, **params):222 from mozlog.structured import commandline223 import runcppunittests as cppunittests224 log = commandline.setup_logging("cppunittest",225 {},226 {"tbpl": sys.stdout})227 if len(params['test_files']) == 0:228 testdir = os.path.join(self.distdir, 'cppunittests')229 progs = cppunittests.extract_unittests_from_args([testdir], None)230 else:231 progs = cppunittests.extract_unittests_from_args(params['test_files'], None)232 # See if we have crash symbols233 symbols_path = os.path.join(self.distdir, 'crashreporter-symbols')234 if not os.path.isdir(symbols_path):235 symbols_path = None236 tester = cppunittests.CPPUnitTests()237 try:238 result = tester.run_tests(progs, self.bindir, symbols_path, interactive=True)239 except Exception as e:240 log.error("Caught exception running cpp unit tests: %s" % str(e))241 result = False242 return 0 if result else 1243@CommandProvider244class CheckSpiderMonkeyCommand(MachCommandBase):245 @Command('check-spidermonkey', category='testing', description='Run SpiderMonkey tests (JavaScript engine).')246 @CommandArgument('--valgrind', action='store_true', help='Run jit-test suite with valgrind flag')247 def run_checkspidermonkey(self, **params):248 import subprocess249 import sys250 bin_suffix = ''251 if sys.platform.startswith('win'):252 bin_suffix = '.exe'253 js = os.path.join(self.bindir, 'js%s' % bin_suffix)254 print('Running jit-tests')255 jittest_cmd = [os.path.join(self.topsrcdir, 'js', 'src', 'jit-test', 'jit_test.py'),256 js, '--no-slow', '--tbpl']257 if params['valgrind']:258 jittest_cmd.append('--valgrind')259 jittest_result = subprocess.call(jittest_cmd)260 print('running jstests')261 jstest_cmd = [os.path.join(self.topsrcdir, 'js', 'src', 'tests', 'jstests.py'),262 js, '--tbpl']263 jstest_result = subprocess.call(jstest_cmd)264 print('running jsapi-tests')265 jsapi_tests_cmd = [os.path.join(self.bindir, 'jsapi-tests%s' % bin_suffix)]266 jsapi_tests_result = subprocess.call(jsapi_tests_cmd)267 print('running check-style')268 check_style_cmd = [sys.executable, os.path.join(self.topsrcdir, 'config', 'check_spidermonkey_style.py')]269 check_style_result = subprocess.call(check_style_cmd, cwd=os.path.join(self.topsrcdir, 'js', 'src'))270 all_passed = jittest_result and jstest_result and jsapi_tests_result and check_style_result...

Full Screen

Full Screen

TestRunner.py

Source:TestRunner.py Github

copy

Full Screen

...7class MncgTestRunner():8 def __init__(self):9 self.sendemail = SendEmail()10 #批量读取python文件获取所有测试用例,并发送测试报告11 def run_suites(self,testcasename):12 now = time.strftime("%Y-%m-%d %H.%M.%S")13 filename = test_report + "\\" + now + "result.html"14 file = open(filename, "wb")15 #加载testcase,下所有的测试用例16 all_cases = unittest.defaultTestLoader.discover(test_dir, pattern=testcasename)17 runner = HTMLTestRunner(stream=file, title="测试结果", description="测试用例执行情况")18 runner.run(all_cases)19 file.close()20 new_report = self.sendemail.newReport(test_report)21 self.sendemail.sendReport(new_report)22if __name__ == '__main__':23 ll = MncgTestRunner()...

Full Screen

Full Screen

test_swift.py

Source:test_swift.py Github

copy

Full Screen

...17 sys.exit(1)18 if len(sys.argv) == 3:19 filter_path = sys.argv[2]20 if sys.argv[1] == 'all':21 run_suites(sorted(INTERPRETERS.keys()))22 elif sys.argv[1] == 'c':23 run_suites(C_SUITES)24 elif sys.argv[1] == 'swift':25 run_suites(SWIFT_SUITES)26 elif sys.argv[1] not in INTERPRETERS:27 print('Unknown interpreter "{}"'.format(sys.argv[1]))28 sys.exit(1)29 else:30 if not run_suite(sys.argv[1]):31 sys.exit(1)32if __name__ == '__main__':...

Full Screen

Full Screen

test_all.py

Source:test_all.py Github

copy

Full Screen

...10main_suite = unittest.TestSuite(11 [unittest.TestLoader().loadTestsFromTestCase(main_tests.TestGetPath)]12)13complete_suite = unittest.TestSuite([graph_pkg_suite, main_suite])14def run_suites():15 result = unittest.TestResult()16 runner = unittest.TextTestRunner()17 print(runner.run(complete_suite))18if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful