parameters: (
          tests: List[str], bazel_rules: BuildDict)
return_statement: return test_metadata
docstring: For given tests, generate the "extra metadata" that we need for our "build.yaml"-like output. The extra metadata is generated from the bazel rule metadata by using a bunch of heuristics.
docstring_summary: For given tests, generate the "extra metadata" that we need for our "build.yaml"-like output. The extra metadata is generated from the bazel rule metadata by using a bunch of heuristics.
docstring_tokens: For given tests generate the extra metadata that we need for our build . yaml - like output . The extra metadata is generated from the bazel rule metadata by using a bunch of heuristics .
function: def _generate_build_extra_metadata_for_tests(
          tests: List[str], bazel_rules: BuildDict) -> BuildDict:
      """For given tests, generate the "extra metadata" that we need for our "build.yaml"-like output. The extra metadata is generated from the bazel rule metadata by using a bunch of heuristics."""
      test_metadata = {}
      for test in tests:
          test_dict = {'build': 'test', '_TYPE': 'target'}
  
          bazel_rule = bazel_rules[_get_bazel_label(test)]
  
          bazel_tags = bazel_rule['tags']
          if 'manual' in bazel_tags:
              # don't run the tests marked as "manual"
              test_dict['run'] = False
  
          if bazel_rule['flaky']:
              # don't run tests that are marked as "flaky" under bazel
              # because that would only add noise for the run_tests.py tests
              # and seeing more failures for tests that we already know are flaky
              # doesn't really help anything
              test_dict['run'] = False
  
          if 'no_uses_polling' in bazel_tags:
              test_dict['uses_polling'] = False
  
          if 'grpc_fuzzer' == bazel_rule['generator_function']:
              # currently we hand-list fuzzers instead of generating them automatically
              # because there's no way to obtain maxlen property from bazel BUILD file.
              print(('skipping fuzzer ' + test))
              continue
  
          # if any tags that restrict platform compatibility are present,
          # generate the "platforms" field accordingly
          # TODO(jtattermusch): there is also a "no_linux" tag, but we cannot take
          # it into account as it is applied by grpc_cc_test when poller expansion
          # is made (for tests where uses_polling=True). So for now, we just
          # assume all tests are compatible with linux and ignore the "no_linux" tag
          # completely.
          known_platform_tags = set(['no_windows', 'no_mac'])
          if set(bazel_tags).intersection(known_platform_tags):
              platforms = []
              # assume all tests are compatible with linux and posix
              platforms.append('linux')
              platforms.append(
                  'posix')  # there is no posix-specific tag in bazel BUILD
              if not 'no_mac' in bazel_tags:
                  platforms.append('mac')
              if not 'no_windows' in bazel_tags:
                  platforms.append('windows')
              test_dict['platforms'] = platforms
  
          cmdline_args = bazel_rule['args']
          if cmdline_args:
              test_dict['args'] = list(cmdline_args)
  
          if test.startswith('test/cpp'):
              test_dict['language'] = 'c++'
  
          elif test.startswith('test/core'):
              test_dict['language'] = 'c'
          else:
              raise Exception('wrong test' + test)
  
          # short test name without the path.
          # There can be name collisions, but we will resolve them later
          simple_test_name = os.path.basename(_extract_source_file_path(test))
          test_dict['_RENAME'] = simple_test_name
  
          test_metadata[test] = test_dict
  
      # detect duplicate test names
      tests_by_simple_name = {}
      for test_name, test_dict in list(test_metadata.items()):
          simple_test_name = test_dict['_RENAME']
          if not simple_test_name in tests_by_simple_name:
              tests_by_simple_name[simple_test_name] = []
          tests_by_simple_name[simple_test_name].append(test_name)
  
      # choose alternative names for tests with a name collision
      for collision_list in list(tests_by_simple_name.values()):
          if len(collision_list) > 1:
              for test_name in collision_list:
                  long_name = test_name.replace('/', '_').replace(':', '_')
                  print((
                      'short name of "%s" collides with another test, renaming to %s'
                      % (test_name, long_name)))
                  test_metadata[test_name]['_RENAME'] = long_name
  
      return test_metadata
function_tokens: def _generate_build_extra_metadata_for_tests ( tests : List [ str ] , bazel_rules : BuildDict ) -> BuildDict : test_metadata = { } for test in tests : test_dict = { 'build' : 'test' , '_TYPE' : 'target' } bazel_rule = bazel_rules [ _get_bazel_label ( test ) ] bazel_tags = bazel_rule [ 'tags' ] if 'manual' in bazel_tags : # don't run the tests marked as "manual" test_dict [ 'run' ] = False if bazel_rule [ 'flaky' ] : # don't run tests that are marked as "flaky" under bazel # because that would only add noise for the run_tests.py tests # and seeing more failures for tests that we already know are flaky # doesn't really help anything test_dict [ 'run' ] = False if 'no_uses_polling' in bazel_tags : test_dict [ 'uses_polling' ] = False if 'grpc_fuzzer' == bazel_rule [ 'generator_function' ] : # currently we hand-list fuzzers instead of generating them automatically # because there's no way to obtain maxlen property from bazel BUILD file. print ( ( 'skipping fuzzer ' + test ) ) continue # if any tags that restrict platform compatibility are present, # generate the "platforms" field accordingly # TODO(jtattermusch): there is also a "no_linux" tag, but we cannot take # it into account as it is applied by grpc_cc_test when poller expansion # is made (for tests where uses_polling=True). So for now, we just # assume all tests are compatible with linux and ignore the "no_linux" tag # completely. known_platform_tags = set ( [ 'no_windows' , 'no_mac' ] ) if set ( bazel_tags ) . intersection ( known_platform_tags ) : platforms = [ ] # assume all tests are compatible with linux and posix platforms . append ( 'linux' ) platforms . append ( 'posix' ) # there is no posix-specific tag in bazel BUILD if not 'no_mac' in bazel_tags : platforms . append ( 'mac' ) if not 'no_windows' in bazel_tags : platforms . append ( 'windows' ) test_dict [ 'platforms' ] = platforms cmdline_args = bazel_rule [ 'args' ] if cmdline_args : test_dict [ 'args' ] = list ( cmdline_args ) if test . startswith ( 'test/cpp' ) : test_dict [ 'language' ] = 'c++' elif test . startswith ( 'test/core' ) : test_dict [ 'language' ] = 'c' else : raise Exception ( 'wrong test' + test ) # short test name without the path. # There can be name collisions, but we will resolve them later simple_test_name = os . path . basename ( _extract_source_file_path ( test ) ) test_dict [ '_RENAME' ] = simple_test_name test_metadata [ test ] = test_dict # detect duplicate test names tests_by_simple_name = { } for test_name , test_dict in list ( test_metadata . items ( ) ) : simple_test_name = test_dict [ '_RENAME' ] if not simple_test_name in tests_by_simple_name : tests_by_simple_name [ simple_test_name ] = [ ] tests_by_simple_name [ simple_test_name ] . append ( test_name ) # choose alternative names for tests with a name collision for collision_list in list ( tests_by_simple_name . values ( ) ) : if len ( collision_list ) > 1 : for test_name in collision_list : long_name = test_name . replace ( '/' , '_' ) . replace ( ':' , '_' ) print ( ( 'short name of "%s" collides with another test, renaming to %s' % ( test_name , long_name ) ) ) test_metadata [ test_name ] [ '_RENAME' ] = long_name return test_metadata