github.com/bazelbuild/rules_webtesting@v0.2.0/web/internal/wrap_web_test_suite.bzl (about)

     1  # Copyright 2016 Google Inc.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #      http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  """Definition of wrap_web_test_suite."""
    15  
    16  load("//web:web.bzl", "web_test_suite")
    17  load(":constants.bzl", "DEFAULT_WRAPPED_TEST_TAGS")
    18  
    19  def wrap_web_test_suite(
    20          name,
    21          browsers,
    22          rule,
    23          args = None,
    24          browser_overrides = None,
    25          config = None,
    26          flaky = None,
    27          local = None,
    28          shard_count = None,
    29          size = None,
    30          tags = None,
    31          test_suite_tags = None,
    32          timeout = None,
    33          visibility = None,
    34          web_test_data = None,
    35          wrapped_test_tags = None,
    36          **remaining_keyword_args):
    37      """Defines a test_suite of web_test targets that wrap a given rule.
    38  
    39      Args:
    40          name: The base name of the test.
    41          browsers: A sequence of lavels specifying the browsers to use.
    42          rule: The rule for the wrapped target.
    43          args: Args for web_test targets generated by this extension.
    44          browser_overrides: Dictionary; optional; default is an empty dictionary. A
    45            dictionary mapping from browser names to browser-specific web_test
    46            attributes, such as shard_count, flakiness, timeout, etc. For example:
    47            {'//browsers:chrome-native': {'shard_count': 3, 'flaky': 1}
    48             '//browsers:firefox-native': {'shard_count': 1, 'timeout': 100}}.
    49          config: Label; optional; Configuration of web test features.
    50          flaky: A boolean specifying that the test is flaky. If set, the test will
    51            be retried up to 3 times (default: 0)
    52          local: boolean; optional.
    53          shard_count: The number of test shards to use per browser. (default: 1)
    54          size: A string specifying the test size. (default: 'large')
    55          tags: A list of test tag strings to apply to each generated web_test target.
    56          test_suite_tags: A list of tag strings for the generated test_suite.
    57          timeout: A string specifying the test timeout (default: computed from size)
    58          visibility: List of labels; optional.
    59          web_test_data: Data dependencies for the web_test.
    60          wrapped_test_tags: A list of test tag strings to use for the wrapped test
    61          **remaining_keyword_args: Arguments for the wrapped test target.
    62      """
    63  
    64      # Check explicitly for None so that users can set this to the empty list
    65      if wrapped_test_tags == None:
    66          wrapped_test_tags = DEFAULT_WRAPPED_TEST_TAGS
    67  
    68      size = size or "large"
    69  
    70      wrapped_test_name = name + "_wrapped_test"
    71  
    72      rule(
    73          name = wrapped_test_name,
    74          args = args,
    75          flaky = flaky,
    76          local = local,
    77          shard_count = shard_count,
    78          size = size,
    79          tags = wrapped_test_tags,
    80          timeout = timeout,
    81          visibility = ["//visibility:private"],
    82          **remaining_keyword_args
    83      )
    84  
    85      web_test_suite(
    86          name = name,
    87          args = args,
    88          browsers = browsers,
    89          browser_overrides = browser_overrides,
    90          config = config,
    91          data = web_test_data,
    92          flaky = flaky,
    93          local = local,
    94          shard_count = shard_count,
    95          size = size,
    96          tags = tags,
    97          test = wrapped_test_name,
    98          test_suite_tags = test_suite_tags,
    99          timeout = timeout,
   100          visibility = visibility,
   101      )