def main(command_args): parser = argparse.ArgumentParser() command_line.AddLoggingArguments(parser, default='warning') dest_group = parser.add_mutually_exclusive_group(required=True) dest_group.add_argument( '-d', '--destination_root', help='The path to the root of the destination folder into which the ' 'application resources are packaged.') dest_group.add_argument( '-z', '--zip_file', help='The path to a zip file into which the application resources are ' 'packaged.') dest_group.add_argument( '-l', '--list', action='store_true', help='List to stdout the application resources relative to the current ' 'directory.') parser.add_argument( '-v', '--verbose', action='store_true', help='Enables verbose logging. For more control over the ' "logging level use '--log_level' instead.") args = parser.parse_args(command_args) log_level.InitializeLogging(args) if args.destination_root: CopyAppLauncherTools(REPOSITORY_ROOT, args.destination_root) elif args.zip_file: try: temp_dir = tempfile.mkdtemp(prefix='cobalt_app_launcher_') CopyAppLauncherTools(REPOSITORY_ROOT, temp_dir) MakeZipArchive(temp_dir, args.zip_file) finally: shutil.rmtree(temp_dir) elif args.list: src_files = [] for src_file in _GetSourceFilesList(REPOSITORY_ROOT): # Skip paths with '$' since they won't get through the Ninja generator. if '$' in src_file: continue # Relative to CWD where gyp ran this; same as '<(DEPTH)' in gyp file. src_file = os.path.relpath(src_file) # Forward slashes for gyp, even on Windows. src_file = src_file.replace('\\', '/') src_files.append(src_file) out = ' '.join(src_files) return out.strip() return 0
def main(): # TODO: Support filters. parser = argparse.ArgumentParser() parser.add_argument( '--type', required=True, type=str, help=( 'Type of the tests to run. It must be functionality, endurance or' ' performance.')) parser.add_argument( '--test_name', default=None, type=str, help=('Name of test to run. If not specified, it will run all tests in' 'the directory.')) args, _ = parser.parse_known_args() package_path = GetTestPackagePath(args.type) if package_path is None: logging.error('{%s} is not a valid test type.', args.type) return 2 all_test_names = GetAllTestNamesInPackage(package_path) specified_test_name = args.test_name if specified_test_name is not None: if not specified_test_name in all_test_names: logging.error('{%s} is not a valid test name.', specified_test_name) return 2 else: all_test_names = [specified_test_name] log_level.InitializeLogging(args) launcher_params = command_line.CreateLauncherParams() supported_features = GetSupportedFeatures(launcher_params) # Update global variables in test case. SetLauncherParams(launcher_params) SetSupportedFeatures(supported_features) unittest.installHandler() test_suite = LoadAllTests(package_path, all_test_names) return not unittest.TextTestRunner( verbosity=0, stream=sys.stdout).run(test_suite).wasSuccessful()
def main(): parser = argparse.ArgumentParser() parser.add_argument('-v', '--verbose', required=False, action='store_true') parser.add_argument( '--server_binding_address', default='127.0.0.1', help='Binding address used to create the test server.') parser.add_argument( '--proxy_address', default=None, help=('Address to the proxy server that all black box' 'tests are run through. If not specified, the' 'server binding address is used.')) parser.add_argument( '--proxy_port', default=None, help=('Port used to create the proxy server that all' 'black box tests are run through. If not' 'specified, a random free port is used.')) parser.add_argument( '--test_name', default=None, help=('Name of test to be run. If not specified, all ' 'tests are run.')) parser.add_argument( '--wpt_http_port', default=None, help=('Port used to create the web platform test http' 'server. If not specified, a random free port is' 'used.')) parser.add_argument( '--device_ips', default=None, nargs='*', help=('IPs of test devices that will be allowed to connect. If not' 'specified, all IPs will be allowed to connect.')) args, _ = parser.parse_known_args() log_level.InitializeLogging(args) test_object = BlackBoxTests(args.server_binding_address, args.proxy_address, args.proxy_port, args.test_name, args.wpt_http_port, args.device_ips) sys.exit(test_object.Run())
def testSunnyDayVerboseOverride(self, initialize_logging_mock): args = argparse.Namespace() args.verbose = True log_level.InitializeLogging(args) initialize_logging_mock.assert_called_with(logging.DEBUG)
def testSunnyDayCorrectLevels(self, initialize_logging_mock): for name, level in log_level._NAME_TO_LEVEL.items(): args = argparse.Namespace() args.log_level = name log_level.InitializeLogging(args) initialize_logging_mock.assert_called_with(level)
def testRainyDayEmptyArgs(self, initialize_logging_mock): log_level.InitializeLogging(argparse.Namespace()) initialize_logging_mock.assert_called_with(logging.INFO)
def testRainyDayNoArgs(self, initialize_logging_mock): log_level.InitializeLogging(None) initialize_logging_mock.assert_called_with(logging.INFO)