Add command line flag to override suppression.xml path

Let the suppression script optionally write to a configuration file set
on the command line, rather than the default.

//build_overrides/build.gni can set a 'lint_suppressions_file' variable,
allowing different products to override the lint suppression
configuration. Updating this overriding suppression configuration can
otherwise be cumbersome.

Bug: 737897
Change-Id: I1551d7e6951f212e42ee79ffac568e9a5208aec9
Reviewed-on: https://chromium-review.googlesource.com/561137
Reviewed-by: Peter Wen <wnwen@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Ingemar Ådahl <ingemara@opera.com>
Cr-Original-Commit-Position: refs/heads/master@{#484621}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0972c74b68f73edc01a5553243ca26b8c723a9e2
This commit is contained in:
Ingemar Ådahl 2017-07-06 16:20:37 +00:00 коммит произвёл Commit Bot
Родитель de46ebd401
Коммит 686676803d
1 изменённых файлов: 12 добавлений и 8 удалений

Просмотреть файл

@ -9,8 +9,8 @@
# pylint: disable=no-member
import argparse
import collections
import optparse
import os
import re
import sys
@ -23,7 +23,8 @@ from pylib.constants import host_paths
_TMP_DIR_RE = re.compile(r'^/tmp/.*/(SRC_ROOT[0-9]+|PRODUCT_DIR)/')
_THIS_FILE = os.path.abspath(__file__)
_CONFIG_PATH = os.path.join(os.path.dirname(_THIS_FILE), 'suppressions.xml')
_DEFAULT_CONFIG_PATH = os.path.join(os.path.dirname(_THIS_FILE),
'suppressions.xml')
_DOC = (
'\nSTOP! It looks like you want to suppress some lint errors:\n'
'- Have you tried identifing the offending patch?\n'
@ -121,13 +122,16 @@ def _Suppress(config_path, result_path):
def main():
parser = optparse.OptionParser(usage='%prog RESULT-FILE')
_, args = parser.parse_args()
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--config',
help='Path to suppression.xml config file',
default=_DEFAULT_CONFIG_PATH)
parser.add_argument('result_path',
help='Lint results xml file',
metavar='RESULT_FILE')
args = parser.parse_args()
if len(args) != 1 or not os.path.exists(args[0]):
parser.error('Must provide RESULT-FILE')
_Suppress(_CONFIG_PATH, args[0])
_Suppress(args.config, args.result_path)
if __name__ == '__main__':