예제 #1
0
def Prepare(args, catalog):
    """Load, apply defaults, and perform validation on test arguments.

  Args:
    args: an argparse namespace. All the arguments that were provided to the
      command invocation (i.e. group and command arguments combined).
    catalog: the TestingEnvironmentCatalog used to find defaults for matrix
      dimension args.

  Raises:
    InvalidArgumentException: If an argument name is unknown, an argument does
      not contain a valid value, or an argument is not valid when used with the
      given type of test.
    RequiredArgumentException: If a required arg is missing.
  """
    all_test_args_set = _GetSetOfAllTestArgs(_TEST_TYPE_ARG_RULES,
                                             _SHARED_ARG_RULES)
    args_from_file = arg_file.GetArgsFromArgFile(args.argspec,
                                                 all_test_args_set)
    _ApplyLowerPriorityArgs(args, args_from_file, True)

    test_type = _GetTestTypeOrRaise(args, _TEST_TYPE_ARG_RULES)
    _ApplyLowerPriorityArgs(args, _TEST_TYPE_ARG_RULES[test_type]['defaults'])
    _ApplyLowerPriorityArgs(args, _SHARED_ARG_RULES['defaults'])
    _ApplyLowerPriorityArgs(args, _GetDefaultsFromAndroidCatalog(catalog))
    arg_validate.ValidateArgsForTestType(args, test_type, _TEST_TYPE_ARG_RULES,
                                         _SHARED_ARG_RULES, all_test_args_set)
    arg_validate.ValidateOsVersions(args, catalog)
    arg_validate.ValidateResultsBucket(args)
    arg_validate.ValidateObbFileNames(args.obb_files)
예제 #2
0
  def Prepare(self, args):
    """Load, apply defaults, and perform validation on test arguments.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        gcloud command invocation (i.e. group and command arguments combined).
        Arg values from an optional arg-file and/or arg default values may be
        added to this argparse namespace.

    Raises:
      InvalidArgumentException: If an argument name is unknown, an argument does
        not contain a valid value, or an argument is not valid when used with
        the given type of test.
      RequiredArgumentException: If a required arg is missing.
    """
    all_test_args_set = arg_util.GetSetOfAllTestArgs(self._typed_arg_rules,
                                                     self._shared_arg_rules)
    args_from_file = arg_file.GetArgsFromArgFile(args.argspec,
                                                 all_test_args_set)
    arg_util.ApplyLowerPriorityArgs(args, args_from_file, True)

    test_type = self.GetTestTypeOrRaise(args)
    typed_arg_defaults = self._typed_arg_rules[test_type]['defaults']
    shared_arg_defaults = self._shared_arg_rules['defaults']
    dimension_defaults = _GetDefaultsFromAndroidCatalog(self._device_catalog)

    arg_util.ApplyLowerPriorityArgs(args, typed_arg_defaults)
    arg_util.ApplyLowerPriorityArgs(args, shared_arg_defaults)
    arg_util.ApplyLowerPriorityArgs(args, dimension_defaults)

    arg_validate.ValidateArgsForTestType(args,
                                         test_type,
                                         self._typed_arg_rules,
                                         self._shared_arg_rules,
                                         all_test_args_set)
    arg_validate.ValidateOsVersions(args, self._device_catalog)
    arg_validate.ValidateResultsBucket(args)
    arg_validate.ValidateObbFileNames(args.obb_files)
    arg_validate.ValidateRoboDirectivesList(args)
    arg_validate.ValidateEnvironmentVariablesList(args)
    arg_validate.ValidateDirectoriesToPullList(args)