Home | History | Annotate | Download | only in perf_expectations
      1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 """Presubmit script for perf_expectations.
      6 
      7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
      8 details on the presubmit API built into gcl.
      9 """
     10 
     11 PERF_EXPECTATIONS = 'tools/perf_expectations/perf_expectations.json'
     12 CONFIG_FILE = 'tools/perf_expectations/chromium_perf_expectations.cfg'
     13 
     14 def CheckChangeOnUpload(input_api, output_api):
     15   run_tests = False
     16   for path in input_api.LocalPaths():
     17     if (PERF_EXPECTATIONS == path or CONFIG_FILE == path):
     18       run_tests = True
     19 
     20   output = []
     21   if run_tests:
     22     whitelist = [r'.+_unittest\.py$']
     23     output.extend(input_api.canned_checks.RunUnitTestsInDirectory(
     24         input_api, output_api, 'tests', whitelist))
     25   return output
     26 
     27 
     28 def CheckChangeOnCommit(input_api, output_api):
     29   run_tests = False
     30   for path in input_api.LocalPaths():
     31     if (PERF_EXPECTATIONS == path or CONFIG_FILE == path):
     32       run_tests = True
     33 
     34   output = []
     35   if run_tests:
     36     whitelist = [r'.+_unittest\.py$']
     37     output.extend(input_api.canned_checks.RunUnitTestsInDirectory(
     38         input_api, output_api, 'tests', whitelist))
     39 
     40   output.extend(input_api.canned_checks.CheckDoNotSubmit(input_api,
     41                                                          output_api))
     42   return output
     43