def run( ctx, manifest, tests, dry_run, interactive, output, verbose, debug, simple_test_selector, keep_tmpdir, mysql, mysql_schemas, ): set_simple_logging(logging.INFO) manifest_env = load_manifest_env(manifest) maybe_use_local_test_paths(manifest_env) db_helper = no_db_helper if dry_run: return run_discover_tests(ctx, manifest_env, output, mysql) test_flags: TestFlags = TestFlags( interactive, verbose, debug, keep_tmpdir, blackhole=not mysql, # NOTE: We need network to talk to MySQL ) selected_tests: List[str] = [] if simple_test_selector is not None and tests: raise click.BadParameter( "Use either --simple-test-selector, or [...TESTS]", ctx) elif simple_test_selector is not None: suite, test = simple_test_selector.split(",", 1) if suite != "run-tests": raise click.BadParameter( 'suite should always be "%s"' % SUITE, ctx, param_hint="simple_test_selector", ) selected_tests.append(test) else: selected_tests.extend(tests) if mysql: if dry_run: # We can dry-run for ephemeral tests pass elif len(selected_tests) <= 1: # One test is allowed to use an ephemeral db. This is OK, because # TestPilot actually asks us to run tests one by one. db_helper = ephemeral_db_helper else: # Too many tests! This won't work. raise click.BadParameter( "mysql tests allow at most 1 test at a time", ctx, param_hint="simple_test_selector", ) with db_helper(mysql_schemas) as test_env: run_tests(ctx, manifest_env, output, selected_tests, test_flags, test_env)
def run( ctx, manifest, tests, dry_run, interactive, output, verbose, debug, simple_test_selector, keep_tmpdir, tmpdir, mysql_client, mysql_schemas, devdb, py3_skip_list, ): manifest = os.path.abspath(manifest) if is_libfb_present(): from eden.mononoke.tests.integration.facebook.lib_runner import ( load_manifest_env, ) from libfb.py.log import set_simple_logging set_simple_logging(logging.INFO) manifest_env: ManifestEnv = load_manifest_env(manifest) else: with open(manifest) as f: manifest_env: ManifestEnv = json.load(f) maybe_use_local_test_paths(manifest_env) if dry_run: return run_discover_tests(ctx, manifest_env, output, mysql_client, py3_skip_list) test_flags: TestFlags = TestFlags( interactive, verbose, debug, keep_tmpdir, tmpdir, disable_all_network_access=( # NOTE: We need network to talk to MySQL not debug and not mysql_client and "DISABLE_ALL_NETWORK_ACCESS" in manifest_env), ) selected_tests: List[str] = [] if simple_test_selector is not None and tests: raise click.BadParameter( "Use either --simple-test-selector, or [...TESTS]", ctx) elif simple_test_selector is not None: suite, test = simple_test_selector.split(",", 1) if suite != "run-tests": raise click.BadParameter( 'suite should always be "%s"' % SUITE, ctx, param_hint="simple_test_selector", ) selected_tests.append(test) else: selected_tests.extend(tests) if is_libfb_present(): from eden.mononoke.tests.integration.facebook.lib_runner import fb_test_context with fb_test_context(ctx, dry_run, mysql_client, mysql_schemas, devdb, selected_tests) as test_env: run_tests(ctx, manifest_env, output, selected_tests, test_flags, test_env) else: run_tests(ctx, manifest_env, output, selected_tests, test_flags, test_env={})
def run( ctx, manifest, tests, dry_run: bool, interactive, output: str, verbose, debug, simple_test_selector, keep_tmpdir, tmpdir, mysql_client: bool, mysql_schemas, devdb: str, discovered_tests, ) -> None: manifest = os.path.abspath(manifest) if is_libfb_present(): from eden.mononoke.tests.integration.facebook.lib_buck import find_buck_out from libfb.py.log import set_simple_logging def load_manifest_env(manifest_path: str) -> Dict[str, str]: buck_out = find_buck_out(manifest_path) with open(manifest_path) as f: manifest_env = json.load(f) def process_value(key: str, value: str, buck_out: str) -> str: if key.startswith("VERBATIM_"): return value return os.path.join(buck_out, value) return { k: process_value(k, v, buck_out) for k, v in manifest_env.items() } set_simple_logging(logging.INFO) manifest_env: ManifestEnv = load_manifest_env(manifest) else: with open(manifest) as f: manifest_env: ManifestEnv = json.load(f) maybe_use_local_test_paths(manifest_env) if dry_run and discovered_tests: return format_discovered_tests(list(discovered_tests), ctx, output) test_flags: TestFlags = TestFlags( interactive, verbose, debug, keep_tmpdir, tmpdir, disable_all_network_access=( # NOTE: We need network to talk to MySQL not debug and not mysql_client and "DISABLE_ALL_NETWORK_ACCESS" in manifest_env), ) selected_tests: List[str] = [] if simple_test_selector is not None and tests: raise click.BadParameter( f"Found --simple-test-selector {simple_test_selector}. Use either --simple-test-selector, or [...TESTS]", ctx, ) elif simple_test_selector is not None: suite, test = simple_test_selector.split(",", 1) if suite != SUITE: raise click.BadParameter( 'suite should always be "%s"' % SUITE, ctx, param_hint="simple_test_selector", ) selected_tests.append(test) else: selected_tests.extend(tests) try: from eden.mononoke.tests.integration.facebook.lib_runner import fb_test_context except ImportError: run_tests(ctx, manifest_env, output, selected_tests, test_flags, test_env={}) else: with fb_test_context(ctx, dry_run, mysql_client, mysql_schemas, devdb, selected_tests) as test_env: run_tests(ctx, manifest_env, output, selected_tests, test_flags, test_env)
] op_result = out_variant_op_result + ["\n\n"] + view_op_result test_result = out_variant_test_result + ["\n\n"] + view_test_result write_cpp(op_result, options.generated_ops_cpp_path) write_test_cpp(test_result, options.generated_ops_test_cpp_path) print("\ntotal grouped native ops: %d" % len(gen.get_grouped_native_functions(native_functions))) print("grouped native ops with out variant: %d" % len(native_functions_groups)) supported_functions_num = sum( [len(groups) for groups in supported_functions_groups]) print("generated functions groups with out variant: %d" % supported_functions_num) print("\nview grouped native ops: %d" % len(native_functions_view_groups)) supported_view_functions_num = sum( [len(groups) for groups in supported_functions_view_groups]) print("generated functions view groups: %d" % supported_view_functions_num) print("\noverall generated : %d" % (supported_functions_num + supported_view_functions_num)) if __name__ == "__main__": set_simple_logging(escape_newlines=False) main()