1#!/usr/bin/env python 2# 3# Copyright 2016 the V8 project authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7"""v8_inspect presubmit script 8 9See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 10for more details about the presubmit API built into gcl. 11""" 12 13compile_note = "Be sure to run your patch by the compile-scripts.py script prior to committing!" 14 15 16def _CompileScripts(input_api, output_api): 17 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] 18 19 compilation_related_files = [ 20 "js_protocol.json" 21 "compile-scripts.js", 22 "injected-script-source.js", 23 "injected_script_externs.js", 24 "check_injected_script_source.js" 25 ] 26 27 for file in compilation_related_files: 28 if (any(file in path for path in local_paths)): 29 script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), 30 "build", "compile-scripts.py") 31 proc = input_api.subprocess.Popen( 32 [input_api.python_executable, script_path], 33 stdout=input_api.subprocess.PIPE, 34 stderr=input_api.subprocess.STDOUT) 35 out, _ = proc.communicate() 36 if "ERROR" in out or "WARNING" in out or proc.returncode: 37 return [output_api.PresubmitError(out)] 38 if "NOTE" in out: 39 return [output_api.PresubmitPromptWarning(out + compile_note)] 40 return [] 41 return [] 42 43 44def CheckChangeOnUpload(input_api, output_api): 45 results = [] 46 results.extend(_CompileScripts(input_api, output_api)) 47 return results 48 49 50def CheckChangeOnCommit(input_api, output_api): 51 results = [] 52 results.extend(_CompileScripts(input_api, output_api)) 53 return results 54 55def PostUploadHook(cl, change, output_api): 56 """git cl upload will call this hook after the issue is created/modified. 57 58 This hook adds extra try bots to the CL description in order to run layout 59 tests in addition to CQ try bots. 60 """ 61 return output_api.EnsureCQIncludeTrybotsAreAdded( 62 cl, 63 [ 64 'master.tryserver.blink:linux_trusty_blink_rel', 65 'luci.chromium.try:linux_chromium_headless_rel', 66 ], 67 'Automatically added layout test trybots to run tests on CQ.') 68