Upload upstream chromium 71.0.3578.0
[platform/framework/web/chromium-efl.git] / media / test / PRESUBMIT.py
1 # Copyright 2018 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 """Top-level presubmit script for media/test/.
6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools.
9 """
10
11 def _CheckTestDataReadmeUpdated(input_api, output_api):
12   """
13   Checks to make sure the README.md file is updated when changing test files.
14   """
15   test_data_dir = input_api.os_path.join('media', 'test', 'data')
16   readme_path = input_api.os_path.join('media', 'test', 'data', 'README.md')
17   test_files = []
18   readme_updated = False
19   errors = []
20   for f in input_api.AffectedFiles():
21     local_path = f.LocalPath()
22     if input_api.os_path.dirname(local_path) == test_data_dir:
23       test_files.append(f)
24       if local_path == readme_path:
25         readme_updated = True
26         break
27   if test_files and not readme_updated:
28     errors.append(output_api.PresubmitPromptWarning(
29         'When updating files in ' + test_data_dir + ', please also update '
30         + readme_path + ':', test_files))
31   return errors
32
33 def CheckChangeOnUpload(input_api, output_api):
34   return _CheckTestDataReadmeUpdated(input_api, output_api)