def new_config(): """Prompt user for config variables and generate new config. Returns: A new ConfigDict. """ config = ConfigDict() config["module-path"] = qprompt.ask_str("Top-level module path") python_version = qprompt.ask_str( 'Python version (blank for auto detection)') config['python-version'] = python_version timeout = qprompt.ask_str('Test execution timeout (seconds)') config['timeout'] = float(timeout) config['excluded-modules'] = [] config["test-command"] = qprompt.ask_str("Test command") menu = qprompt.Menu() for at_pos, engine_name in enumerate(execution_engine_names()): menu.add(str(at_pos), engine_name) config["execution-engine"] = ConfigDict() config['execution-engine']['name'] = menu.show(header="Execution engine", returns="desc") return config
def new_config(): """Prompt user for config variables and generate new config. Returns: A new ConfigDict. """ config = ConfigDict() config["module-path"] = qprompt.ask_str("Top-level module path", blk=False, vld=os.path.exists, hlp=MODULE_PATH_HELP) timeout = qprompt.ask_str( "Test execution timeout (seconds)", vld=float, blk=False, hlp="The number of seconds to let a test run before terminating it.", ) config["timeout"] = float(timeout) config["excluded-modules"] = [] config["test-command"] = qprompt.ask_str("Test command", blk=False, hlp=TEST_COMMAND_HELP) menu = qprompt.Menu() for at_pos, distributor_name in enumerate(distributor_names()): menu.add(str(at_pos), distributor_name) config["distributor"] = ConfigDict() config["distributor"]["name"] = menu.show(header="Distributor", returns="desc") return config
def filter(self, work_db: WorkDB, args: Namespace): """Mark as skipped all work item that is not new""" config = ConfigDict() if args.config is not None: config = load_config(args.config) branch = config.sub("git", "git-filter").get("branch", "master") self._skip_filtered(work_db, branch)
def new_config(): """Prompt user for config variables and generate new config. Returns: A new ConfigDict. """ config = ConfigDict() config["module-path"] = qprompt.ask_str("Top-level module path", blk=False, vld=os.path.exists, hlp=MODULE_PATH_HELP) python_version = qprompt.ask_str( 'Python version (blank for auto detection)', vld=_validate_python_version, hlp=PYTHON_VERSION_HELP) config['python-version'] = python_version timeout = qprompt.ask_str( 'Test execution timeout (seconds)', vld=float, blk=False, hlp="The number of seconds to let a test run before terminating it.") config['timeout'] = float(timeout) config['excluded-modules'] = [] config["test-command"] = qprompt.ask_str("Test command", blk=False, hlp=TEST_COMMAND_HELP) menu = qprompt.Menu() for at_pos, engine_name in enumerate(execution_engine_names()): menu.add(str(at_pos), engine_name) config["execution-engine"] = ConfigDict() config['execution-engine']['name'] = menu.show(header="Execution engine", returns="desc") config["cloning"] = ConfigDict() config['cloning']['method'] = 'copy' config['cloning']['commands'] = [] config['interceptors'] = ConfigDict() config['interceptors']['enabled'] = [ 'spor', 'pragma_no_mutate', 'operators-filter' ] config['operators-filter'] = ConfigDict() config['operators-filter']['exclude-operators'] = None return config
def test_get_config_returns_correct_config(work_db): config = ConfigDict() config['color'] = 'blue' work_db.set_config(config) actual_config = work_db.get_config() assert actual_config['color'] == 'blue'
def test_load_from_valid_config_file(tmpdir): config_path = tmpdir / 'config.conf' config = ConfigDict() config['key'] = 'value' with config_path.open(mode='wt', encoding='utf-8') as handle: handle.write(serialize_config(config)) assert load_config(str(config_path))['key'] == 'value'
def intercept(work_db: WorkDB, config: ConfigDict): """Mark as skipped all work item with filtered operator """ exclude_operators = config.get('exclude-operators') re_exclude_operators = re.compile('|'.join('(:?%s)' % e for e in exclude_operators)) for item in work_db.pending_work_items: if re_exclude_operators.match(item.operator_name): log.info( "operator skipping %s %s %s %s %s %s", item.job_id, item.operator_name, item.occurrence, item.module_path, item.start_pos, item.end_pos, ) work_db.set_result( item.job_id, WorkResult( output="Filtered operator", worker_outcome=WorkerOutcome.SKIPPED, ), )
def test_load_valid_stdin(mocker): temp_stdin = io.StringIO() temp_stdin.name = 'stringio' config = ConfigDict() config['key'] = 'value' temp_stdin.write(serialize_config(config)) temp_stdin.seek(0) mocker.patch('sys.stdin', temp_stdin) assert load_config()['key'] == 'value'
def test_set_config(work_db): config = ConfigDict() config['color'] = 'blue' work_db.set_config(config)