1# Copyright 2023 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5PRESUBMIT_VERSION = '2.0.0' 6 7def CheckStdlib(input_api, output_api): 8 stdlib_dir = input_api.PresubmitLocalPath() 9 chromium_src_dir = input_api.os_path.abspath( 10 input_api.os_path.join(stdlib_dir, '..', '..')) 11 tool = input_api.os_path.join( 12 chromium_src_dir, 13 'tools', 'tracing', 'check_stdlib.py') 14 cmd = [ input_api.python3_executable, tool ] 15 test_cmd = input_api.Command( 16 name='check_stdlib', 17 cmd=cmd, 18 kwargs={}, 19 message=output_api.PresubmitError) 20 return input_api.RunTests([test_cmd]) 21 22_STDLIB_PATHS = ( 23 r"^base/tracing/stdlib/", 24 r"^base/tracing/test/", 25 r"^base/tracing/protos/" 26) 27 28def CheckPerfettoTestsTag(input_api, output_api): 29 """Checks that commits to the trace processor chrome stdlib or the 30 Perfetto diff tests contain a PERFETTO_TESTS tag in their commit 31 message.""" 32 def FileFilter(affected_file): 33 return input_api.FilterSourceFile(affected_file, 34 files_to_check=_STDLIB_PATHS) 35 36 # Only consider changes to chrome stdlib or tests paths 37 if not any (input_api.AffectedFiles(file_filter=FileFilter)): 38 return [] 39 40 if input_api.change.PERFETTO_TESTS: 41 return [] 42 43 message = ( 44 'Must provide PERFETTO_TESTS=' 45 '`autoninja -C out/Default perfetto_diff_tests && ' 46 'out/Default/bin/run_perfetto_diff_tests` line in CL description.' 47 '\nPlease ensure the Perfetto diff tests pass before submitting.' 48 ) 49 return [output_api.PresubmitNotifyResult(message)] 50