android_webview/javatests/PRESUBMIT.py
def _CheckNoSandboxedRendererSwitch(input_api, output_api):
  """Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER
  command line flag. Tests should instead use @OnlyRunIn(MULTI_PROCESS).
  """

  # This will not catch multi-line annotations (which are valid if adding
  # multiple switches), but is better than nothing (and avoids false positives).
  sandboxed_renderer_pattern = input_api.re.compile(
      r'^\s*@CommandLineFlags\.Add\(.*'
      r'\bAwSwitches\.WEBVIEW_SANDBOXED_RENDERER\b.*\)$')

  errors = []

  def _FilterFile(affected_file):
    return input_api.FilterSourceFile(
        affected_file,
        files_to_skip=input_api.DEFAULT_FILES_TO_SKIP,
        files_to_check=[r'.*\.java$'])

  for f in input_api.AffectedSourceFiles(_FilterFile):
    for line_num, line in f.ChangedContents():
      match = sandboxed_renderer_pattern.search(line)
      if match:
        errors.append("%s:%d" % (f.LocalPath(), line_num))

  results = []

  if errors:
    results.append(output_api.PresubmitPromptWarning("""
android_webview/javatests/ should not use AwSwitches.WEBVIEW_SANDBOXED_RENDERER
to run in multi-process only. Instead, use @OnlyRunIn(MULTI_PROCESS).
""", errors))

  return results
Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER
  command line flag. Tests should instead use @OnlyRunIn(MULTI_PROCESS).
  
Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER
command line flag.
Checks that tests do not add the AwSwitches . WEBVIEW_SANDBOXED_RENDERER command line flag .
def _CheckNoSandboxedRendererSwitch(input_api, output_api):
  sandboxed_renderer_pattern = input_api.re.compile(
      r'^\s*@CommandLineFlags\.Add\(.*'
      r'\bAwSwitches\.WEBVIEW_SANDBOXED_RENDERER\b.*\)$')
  errors = []
  def _FilterFile(affected_file):
    return input_api.FilterSourceFile(
        affected_file,
        files_to_skip=input_api.DEFAULT_FILES_TO_SKIP,
        files_to_check=[r'.*\.java$'])
  for f in input_api.AffectedSourceFiles(_FilterFile):
    for line_num, line in f.ChangedContents():
      match = sandboxed_renderer_pattern.search(line)
      if match:
        errors.append("%s:%d" % (f.LocalPath(), line_num))
  results = []
  if errors:
    results.append(output_api.PresubmitPromptWarning("""
android_webview/javatests/ should not use AwSwitches.WEBVIEW_SANDBOXED_RENDERER
to run in multi-process only. Instead, use @OnlyRunIn(MULTI_PROCESS).
""", errors))
  return results
def _CheckNoSandboxedRendererSwitch ( input_api , output_api ) : sandboxed_renderer_pattern = input_api . re . compile ( r'^\s*@CommandLineFlags\.Add\(.*' r'\bAwSwitches\.WEBVIEW_SANDBOXED_RENDERER\b.*\)$' ) errors = [ ] def _FilterFile ( affected_file ) : return input_api . FilterSourceFile ( affected_file , files_to_skip = input_api . DEFAULT_FILES_TO_SKIP , files_to_check = [ r'.*\.java$' ] ) for f in input_api . AffectedSourceFiles ( _FilterFile ) : for line_num , line in f . ChangedContents ( ) : match = sandboxed_renderer_pattern . search ( line ) if match : errors . append ( "%s:%d" % ( f . LocalPath ( ) , line_num ) ) results = [ ] if errors : results . append ( output_api . PresubmitPromptWarning ( """
android_webview/javatests/ should not use AwSwitches.WEBVIEW_SANDBOXED_RENDERER
to run in multi-process only. Instead, use @OnlyRunIn(MULTI_PROCESS).
""" , errors ) ) return results
Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER
command line flag.
Checks that tests do not add the AwSwitches . WEBVIEW_SANDBOXED_RENDERER command line flag .
"""Checks that tests do not add the AwSwitches.WEBVIEW_SANDBOXED_RENDERER
  command line flag. Tests should instead use @OnlyRunIn(MULTI_PROCESS).
  """ # This will not catch multi-line annotations (which are valid if adding # multiple switches), but is better than nothing (and avoids false positives).
input_api
output_api