def compile_typescript_test_files(): tsc_compile_errors_found = False cwd = devtools_paths.devtools_root_path() env = os.environ.copy() shared_path = os.path.join(cwd, 'test/shared') e2e_test_path = os.path.join(cwd, 'test/e2e') # Compile shared code, e.g. helper and runner. print("Compiling shared TypeScript") exec_command = [ devtools_paths.node_path(), devtools_paths.typescript_compiler_path(), '-p', shared_path ] tsc_compile_proc = popen(exec_command, cwd=cwd, env=env, capture=True) tsc_compile_proc.communicate() if tsc_compile_proc.returncode != 0: tsc_compile_errors_found = True # Compile e2e tests, e.g. helper and runner. print("Compiling e2e TypeScript") exec_command = [ devtools_paths.node_path(), devtools_paths.typescript_compiler_path(), '-p', e2e_test_path ] tsc_compile_proc = popen(exec_command, cwd=cwd, env=env, capture=True) tsc_compile_proc.communicate() if tsc_compile_proc.returncode != 0: tsc_compile_errors_found = True return tsc_compile_errors_found
def _checkWithTypeScript(input_api, output_api, tsc_arguments, script_path, script_arguments=[]): # pylint: disable=invalid-name original_sys_path = sys.path try: sys.path = sys.path + [ input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts') ] import devtools_paths finally: sys.path = original_sys_path # First run tsc to compile the TS script that we then run in the _ExecuteSubProcess call tsc_compiler_process = input_api.subprocess.Popen( [ devtools_paths.node_path(), devtools_paths.typescript_compiler_path() ] + tsc_arguments, stdout=input_api.subprocess.PIPE, stderr=input_api.subprocess.STDOUT) out, _ = tsc_compiler_process.communicate() if tsc_compiler_process.returncode != 0: return [ output_api.PresubmitError('Error compiling briges regenerator:\n' + str(out)) ] return _checkWithNodeScript(input_api, output_api, script_path, script_arguments)
def compile_typescript(typescript_targets): for target in typescript_targets: print("Compiling %s TypeScript" % (target['name'])) exec_command = [devtools_paths.node_path(), devtools_paths.typescript_compiler_path(), '-p', target['path']] exit_code = test_helpers.popen(exec_command) if exit_code != 0: return True return False
V8_DIRECTORY_PATH = path.join(ROOT_DIRECTORY, 'v8') PROTOCOL_LOCATION = path.join(ROOT_DIRECTORY, 'third_party', 'blink', 'public', 'devtools_protocol') SCRIPTS_BUILD_PATH = path.join(ROOT_DIRECTORY, 'scripts', 'build') GENERATE_ARIA_SCRIPT = path.join(SCRIPTS_BUILD_PATH, 'generate_aria.py') GENERATE_SUPPORTED_CSS_SCRIPT = path.join(SCRIPTS_BUILD_PATH, 'generate_supported_css.py') GENERATE_PROTOCOL_DEFINITIONS_SCRIPT = path.join(SCRIPTS_BUILD_PATH, 'code_generator_frontend.py') CONCATENATE_PROTOCOL_SCRIPT = path.join(ROOT_DIRECTORY, 'third_party', 'inspector_protocol', 'concatenate_protocols.py') NODE_LOCATION = devtools_paths.node_path() TSC_LOCATION = devtools_paths.typescript_compiler_path() def popen(arguments, cwd=ROOT_DIRECTORY, env=os.environ.copy()): process = subprocess.Popen([sys.executable] + arguments, cwd=cwd, env=env) process.communicate() if process.returncode != 0: sys.exit(process.returncode) def runTsc(file_to_compile): process = subprocess.Popen([NODE_LOCATION, TSC_LOCATION, file_to_compile], stdout=subprocess.PIPE, stderr=subprocess.PIPE)