
    M                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SS	KJr  S
 rS rS r " S S\5      rg)zBA shared library for processing and validating iOS test arguments.    )absolute_import)division)unicode_literals)arg_file)arg_util)arg_validate)catalog_manager)
exceptionsc                  D    S// SQSS0S.S/S/SS/0S.S/SS	/SS0S.S
.$ )aR  Returns the rules for iOS test args which depend on the test type.

This dict is declared in a function rather than globally to avoid garbage
collection issues during unit tests.

Returns:
  A dict keyed by whether type-specific args are required or optional, and
  with a nested dict containing any default values for those shared args.
test)xcode_versionxctestrun_filetest_special_entitlementsr   Frequiredoptionaldefaultsappscenario_numbers   robo_script)xctestz	game-looprobo r       ;lib/googlecloudsdk/api_lib/firebase/test/ios/arg_manager.pyTypedArgRulesr      se     h *5
 g)* 1# g2MB)5'
 r   c                  "    S// SQS0 /SSSS.S.$ )	aP  Returns the rules for iOS test args which are shared by all test types.

This dict is declared in a function rather than globally to avoid garbage
collection issues during unit tests.

Returns:
  A dict keyed by whether shared args are required or optional, and with a
  nested dict containing any default values for those shared args.
type)additional_ipasasync_client_detailsdevicedirectories_to_pullnetwork_profilenum_flaky_test_attemptsother_filesrecord_videoresults_bucketresults_dirresults_history_nametimeoutFr   Ti  )r!   r#   r&   r(   r,   r   r   r   r   r   SharedArgRulesr-   C   s0     (  D%&#
 r   c                  P    [         R                  " [        5       [        5       5      $ )z9Returns a set containing the names of every iOS test arg.)r   GetSetOfAllTestArgsr   r-   r   r   r   
AllArgsSetr0   h   s    		%	%mo~7G	HHr   c                   4    \ rS rSrSr   SS jrS rS rSrg)	IosArgsManagerm   z'Manages test arguments for iOS devices.Nc                     U=(       d    [         R                  " 5       U l        U=(       d
    [        5       U l        U=(       d
    [        5       U l        g)a,  Constructs an IosArgsManager for a single iOS test matrix.

Args:
  catalog_mgr: an IosCatalogManager object.
  typed_arg_rules: a nested dict of dicts which are keyed first on the test
    type, then by whether args are required or optional, and what their
    default values are. If None, the default from TypedArgRules() is used.
  shared_arg_rules: a dict keyed by whether shared args are required or
    optional, and with a nested dict containing any default values for those
    shared args. If None, the default dict from SharedArgRules() is used.
N)r	   IosCatalogManager_catalog_mgrr   _typed_arg_rulesr-   _shared_arg_rules)selfcatalog_mgrtyped_arg_rulesshared_arg_ruless       r   __init__IosArgsManager.__init__p   s9     $J'H'H'JD+>}D-A1ADr   c                    [         R                  " U R                  U R                  5      n[        R
                  " UR                  U5      n[         R                  " XS5        U R                  U5      nU R                  U   S   nU R                  S   n[         R                  " X5        [         R                  " X5        [        R                  " XU R                  U R                  U5        [        R                  " XR                  5        [        R                  " XR                  5        [        R                  " U5        [        R                  " U5        [        R                   " U5        [        R"                  " U5        g)aE  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.
Tr   N)r   r/   r7   r8   r   GetArgsFromArgFileargspecApplyLowerPriorityArgsGetTestTypeOrRaiser   ValidateArgsForTestTypeValidateDeviceListr6   ValidateXcodeVersionValidateResultsBucketValidateResultsDirValidateScenarioNumbers ValidateIosDirectoriesToPullList)r9   argsall_test_args_setargs_from_file	test_typetyped_arg_defaultsshared_arg_defaultss          r   PrepareIosArgsManager.Prepare   s,    !44T5J5J595K5KM001BDN ##D$?''-I..y9*E00<##D=##D>(($:O:O)-)?)?):< ##D*;*;<%%d,=,=>&&t,##D)((.11$7r   c                     UR                   (       d  SUl         UR                   U R                  ;  a0  [        R                  " SSR	                  UR                   5      5      eUR                   $ )a  If the test type is not user-specified, infer the most reasonable value.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    gcloud command invocation (i.e. group and command arguments combined).

Returns:
  The type of the test to be run (e.g. 'xctest'), and also sets the 'type'
  arg if it was not user-specified.

Raises:
  InvalidArgumentException if an explicit test type is invalid.
r   r   z'{0}' is not a valid test type.)r   r7   r
   InvalidArgumentExceptionformat)r9   rK   s     r   rC   !IosArgsManager.GetTestTypeOrRaise   sX     99diyy---//
3::499EG G99r   )r6   r8   r7   )NNN)	__name__
__module____qualname____firstlineno____doc__r=   rQ   rC   __static_attributes__r   r   r   r2   r2   m   s!    /  # $B&#8Jr   r2   N)r[   
__future__r   r   r   $googlecloudsdk.api_lib.firebase.testr   r   r   (googlecloudsdk.api_lib.firebase.test.iosr	   googlecloudsdk.callioper
   r   r-   r0   objectr2   r   r   r   <module>rb      sC    I &  ' 9 9 = D .$N"JI
NV Nr   