
    ߉                         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S
K	Jr  SSKJr  SSKrSrSrSrSrS rS rS rS rS rS rS rS rS rS rSS jrS rg)z>A shared library for processing and validating test arguments.    )absolute_import)division)unicode_literals)arg_file)arg_validate)
exceptions)actions)arg_parsers)base)logNzANDROID INSTRUMENTATION TESTzANDROID ROBO TESTzANDROID GAME-LOOP TESTzDEPRECATED DEVICE DIMENSIONSc                    U R                  SS[        R                  SS9  U R                  SSSSS	S
9  U R                  S[        R                  " 5       SSS9  U R                  SS[
        R                  SS9  U R                  SSSSS9  U R                  SSS9  U R                  SSS9  U R                  S[        R                  [
        R                  SS9  g)zRegister args which are common to all 'gcloud test run' commands.

Args:
  parser: An argparse parser used to add arguments that follow a command
      in the CLI.
argspec?a  An ARG_FILE:ARG_GROUP_NAME pair, where ARG_FILE is the path to a file containing groups of test arguments in yaml format, and ARG_GROUP_NAME is the particular yaml object holding a group of arg:value pairs to use. Run *$ gcloud topic arg-files* for more information and examples.)nargs	completerhelpz--async
store_trueNasync_z>Invoke a test asynchronously without waiting for test results.)actiondefaultdestr   z--client-details	KEY=VALUEa        Comma-separated, KEY=VALUE map of additional details to attach to the test
      matrix. Arbitrary KEY=VALUE pairs may be attached to a test matrix to
      provide additional context about the tests being run. When consuming the
      test results, such as in Cloud Functions or a CI system, these details can
      add additional context such as a link to the corresponding pull request.

      Example:

      ```
      --client-details=buildNumber=1234,pullRequest=https://example.com/link/to/pull-request
      ```

      To help you identify and locate your test matrix in the Firebase console,
      use the matrixLabel key.

      Example:

      ```
      --client-details=matrixLabel="Example matrix label"
      ```
      typemetavarr   z--num-flaky-test-attemptsinta{        Specifies the number of times a test execution should be reattempted if
      one or more of its test cases fail for any reason. An execution that
      initially fails but succeeds on any reattempt is reported as FLAKY.

      The maximum number of reruns allowed is 10. (Default: 0, which implies
      no reruns.) All additional attempts are executed in parallel.
      r   r   r   z--record-videoz]Enable video recording during the test. Enabled by default, use --no-record-video to disable.r   r   r   z--results-bucketa  The name of a Google Cloud Storage bucket where raw test results will be stored (default: "test-lab-<random-UUID>"). Note that the bucket must be owned by a billing-enabled project, and that using a non-default bucket will result in billing charges for the storage used.r   z--results-diraI  The name of a *unique* Google Cloud Storage object within the results bucket where raw test results will be stored (default: a timestamp with a random suffix). Caution: if specified, this argument *must be unique* for each test matrix you create, otherwise results from multiple test matrices will be overwritten or intermingled.z	--timeouta  The max time this test execution can run before it is cancelled (default: 15m). It does not include any time necessary to prepare and clean up the target device. The maximum possible testing time is 45m on physical devices and 60m on virtual devices. The _TIMEOUT_ units can be h, m, or s. If no unit is given, seconds are assumed. Examples:
- *--timeout 1h* is 1 hour
- *--timeout 5m* is 5 minutes
- *--timeout 200s* is 200 seconds
- *--timeout 100* is 100 seconds)categoryr   r   )
add_argumentr   ArgSpecCompleterr
   ArgDictr   NONNEGATIVE_INT_PARSERr   COMMONLY_USED_FLAGSTIMEOUT_PARSERparsers    4lib/googlecloudsdk/api_lib/firebase/test/arg_util.pyAddCommonTestRunArgsr*   $   s5    	))"	  # 	K  M 	 
	  6 	!..
	   	&	  ' 	P  Q 	I  J 	''&&)	  *    c           
      ^   U R                  S[        R                  SS9  U R                  S[        R                  " SSS9SS9  U R                  S	[
        R                  " S
SS9SSS9  U R                  SSSSS9  U R                  S[
        R                  " 5       SSS9  U R                  S[
        R                  " 5       SSS9  U R                  SSSS9  U R                  S[
        R                  " S
S S9S!S"S9  U R                  S#[
        R                  " S
S$9S%S&S9  U R                  S'SSS(S9  U R                  S)S*S+9  U R                  S,[        S-S9  U R                  S.[        R                  / S/QS0S19  U R                  S2[        R                  S3S9  U R                  S4[        R                  " S4SS9[        S5S69  U R                  S7[        S8S9  U R                  S9[        [
        R                  " S
S$9S:S;S<9  U R                  S=[        SSS>S?9  U R                  S@[        SSSAS?9  U R                  SBSC[        [
        R                  " 5       SDSE9  U R                  SFSG[
        R                  " [        S
SHSI9[        SJSK9  U R                  SLSM[
        R                  " S
S$9[        SNSK9  g)OzRegister args which are specific to Android test commands.

Args:
  parser: An argparse parser used to add arguments that follow a command in
      the CLI.
--appzThe path to the application binary file. The path may be in the local filesystem or in Google Cloud Storage using gs:// notation. Android App Bundles are specified as .aab, all other files are assumed to be APKs.r    r   z--app-packageT)removedzyThe Java package of the application under test. By default, the application package name is parsed from the APK manifest.)r   r   z--additional-apks   d   
min_length
max_lengthAPKzA list of up to 100 additional APKs to install, in addition to those being directly tested. The path may be in the local filesystem or in Google Cloud Storage using gs:// notation.r   z--auto-google-loginr   NzAutomatically log into the test device using a preconfigured Google account before beginning the test. Enabled by default, use --no-auto-google-login to disable.r   --directories-to-pullDIR_TO_PULLa  A list of paths that will be copied from the device's storage to the designated results bucket after the test is complete. These must be absolute paths under `/sdcard`, `/storage`, or `/data/local/tmp` (for example, `--directories-to-pull /sdcard/tempDir1,/data/local/tmp/tempDir2`). Path names are restricted to the characters ```a-zA-Z0-9_-./+```. The paths `/sdcard` and `/data` will be made available and treated as implicit path substitutions. E.g. if `/sdcard` on a particular device does not map to external storage, the system will replace it with the external storage path prefix for that device. Note that access to some directories on API levels 29 and later may also be limited by scoped storage rules.z--environment-variablesr   a        A comma-separated, key=value map of environment variables and their
      desired values. The environment variables are mirrored as extra options to
      the `am instrument -e KEY1 VALUE1 ...` command and passed to your test
      runner (typically AndroidJUnitRunner). Examples:

      Enable code coverage and provide a directory to store the coverage
      results when using Android Test Orchestrator (`--use-orchestrator`):

      ```
      --environment-variables clearPackageData=true,coverage=true,coverageFilePath=/sdcard/Download/
      ```

      Enable code coverage and provide a file path to store the coverage
      results when *not* using Android Test Orchestrator
      (`--no-use-orchestrator`):

      ```
      --environment-variables coverage=true,coverageFile=/sdcard/Download/coverage.ec
      ```

      Note: If you need to embed a comma into a `VALUE` string, please refer to
      `gcloud topic escaping` for ways to change the default list delimiter.
      z--network-profile
PROFILE_IDaO  The name of the network traffic profile, for example `--network-profile=LTE`, which consists of a set of parameters to emulate network conditions when running the test (default: no network shaping; see available profiles listed by the $ {grandparent_command} network-profiles list command). This feature only works on physical devices.)r   r   z--obb-files   OBB_FILEaU  A list of one or two Android OBB file names which will be copied to each test device before the tests will run (default: None). Each OBB file name must conform to the format as specified by Android (e.g. [main|patch].0300110.com.example.android.obb) and will be installed into <shared-storage>/Android/obb/<package-name>/ on the test device.--other-filesr3   DEVICE_PATH=FILE_PATHa        A list of device-path=file-path pairs that indicate the device paths to
      push files to the device before starting tests, and the paths of files to
      push.

      Device paths must be under absolute, approved paths
      (${EXTERNAL_STORAGE}, or ${ANDROID_DATA}/local/tmp). Source file paths may
      be in the local filesystem or in Google Cloud Storage (gs://...).

      Examples:

      ```
      --other-files /sdcard/dir1/file1.txt=local/file.txt,/storage/dir2/file2.jpg=gs://bucket/file.jpg
      ```

      This flag only copies files to the device. To install files, like OBB or
      APK files, see --obb-files and --additional-apks.
      z--performance-metricszMonitor and record performance metrics: CPU, memory, network usage, and FPS (game-loop only). Enabled by default, use --no-performance-metrics to disable.--results-history-namea  The history name for your test results (an arbitrary string label; default: the application's label from the APK manifest). All tests which use the same history name will have their results grouped together in the Firebase console in a time-ordered test history list.r   --robo-scriptaU  The path to a Robo Script JSON file. The path may be in the local filesystem or in Google Cloud Storage using gs:// notation. You can guide the Robo test to perform specific actions by recording a Robo Script in Android Studio and then specifying this argument. Learn more at https://firebase.google.com/docs/test-lab/robo-ux-test#scripting.--type)instrumentationrobo	game-loopzThe type of test to run.r    choicesr   --testzThe path to the binary file containing instrumentation tests. The given path may be in the local filesystem or in Google Cloud Storage using a URL beginning with `gs://`.z--test-packagezuThe Java package name of the instrumentation test. By default, the test package name is parsed from the APK manifest.)r   r    r   z--test-runner-classzThe fully-qualified Java class name of the instrumentation test runner (default: the last name extracted from the APK manifest).z--test-targetsTEST_TARGETa)        A list of one or more test target filters to apply (default: run all test
      targets). Each target filter must be fully qualified with the package
      name, class name, or test annotation desired. Any test filter supported by
      `am instrument -e ...` is supported. See
       https://developer.android.com/reference/androidx/test/runner/AndroidJUnitRunner
       for more information. Examples:

         * `--test-targets "package com.my.package.name"`
         * `--test-targets "notPackage com.package.to.skip"`
         * `--test-targets "class com.foo.ClassName"`
         * `--test-targets "notClass com.foo.ClassName#testMethodToSkip"`
         * `--test-targets "annotation com.foo.AnnotationToRun"`
         * `--test-targets "size large notAnnotation com.foo.AnnotationToSkip"`
      r    r   r   r   z--use-orchestratora  Whether each test runs in its own Instrumentation instance with the Android Test Orchestrator (default: Orchestrator is not used, same as specifying --no-use-orchestrator). Orchestrator is only compatible with AndroidJUnitRunner v1.1 or higher. See https://developer.android.com/training/testing/junit-runner.html#using-android-test-orchestrator for more information about Android Test Orchestrator.)r    r   r   r   z--resigna[  Make Robo re-sign the app-under-test APK for a higher quality crawl. If your app cannot properly function when re-signed, disable this feature. When an app-under-test APK is not re-signed, Robo crawl is slower and Robo has access to less information about the state of the crawled app, which reduces crawl quality. Consequently, if your Roboscript has actions on elements of RecyclerView or AdapterView, and you disable APK re-signing, those actions might require manual tweaking because Robo does not identify RecyclerView and AdapterView in this mode. Enabled by default, use `--no-resign` to disable.z--robo-directiveszTYPE:RESOURCE_NAME=INPUTa  A comma-separated (`<type>:<key>=<value>`) map of `robo_directives` that you can use to customize the behavior of Robo test. The `type` specifies the action type of the directive, which may take on values `click`, `text` or `ignore`. If no `type` is provided, `text` will be used by default. Each key should be the Android resource name of a target UI element and each value should be the text input for that element. Values are only permitted for `text` type elements, so no value should be specified for `click` and `ignore` type elements. No more than one `click` element is allowed.

To provide custom login credentials for your app, use

    --robo-directives text:username_resource=username,text:password_resource=password

To instruct Robo to click on the sign-in button, use

    --robo-directives click:sign_in_button=

To instruct Robo to ignore any UI elements with resource names which equal or start with the user-defined value, use

  --robo-directives ignore:ignored_ui_element_resource_name=

To learn more about Robo test and robo_directives, see https://firebase.google.com/docs/test-lab/android/command-line#custom_login_and_text_input_with_robo_test.

Caution: You should only use credentials for test accounts that are not associated with real users.)r   r    r   r   --scenario-numbersr      element_typer3   r4   zA list of game-loop scenario numbers which will be run as part of the test (default: all scenarios). A maximum of 1024 scenarios may be specified in one test matrix, but the maximum number may also be limited by the overall test *--timeout* setting.)r   r   r    r   z--scenario-labelsLABELa  A list of game-loop scenario labels (default: None). Each game-loop scenario may be labeled in the APK manifest file with one or more arbitrary strings, creating logical groupings (e.g. GPU_COMPATIBILITY_TESTS). If *--scenario-numbers* and *--scenario-labels* are specified together, Firebase Test Lab will first execute each scenario from *--scenario-numbers*. It will then expand each given scenario label into a list of scenario numbers marked with that label, and execute those scenarios.)r!   r   r%   r	   DeprecationActionr
   ArgListr#   ANDROID_ROBO_TESTANDROID_INSTRUMENTATION_TESTr   ANDROID_GAME_LOOP_TESTr'   s    r)   AddAndroidTestArgsrS      s    	''   	&&EB  C
 	!<6	  7 	+	  , 	 	    	 
	  8 	5  6 	!:N	  O 	!,%
	  $ 	-	  . 	N  O 	 M  N 	''6%	  ' 	'',  - 	&&'7F+;	  < 	+I  J
 	+!,
  * 	+   	 	  $ 	(  $  !%J 	CA$O%9  : 	!,%6  7r+   c           	         U R                  S[        R                  / SQSS9  U R                  S[        R                  SSS9  U R                  S	[        R                  S
SS9  U R                  S[        R                  SS9  U R                  S[        R                  [        R                  " SS9SSSS9  U R                  SSS9  U R                  SSS9  U R                  SSSSS9  g) zRegister args which are specific to iOS test commands.

Args:
  parser: An argparse parser used to add arguments that follow a command in
      the CLI.
r@   )xctestrC   rB   zThe type of iOS test to run.rD   rF   
XCTEST_ZIPa  The path to the test package (a zip file containing the iOS app and XCTest files). The given path may be in the local filesystem or in Google Cloud Storage using a URL beginning with `gs://`. Note: any .xctestrun file in this zip file will be ignored if *--xctestrun-file* is specified.)r    r   r   z--xctestrun-fileXCTESTRUN_FILEaz  The path to an .xctestrun file that will override any .xctestrun file contained in the *--test* package. Because the .xctestrun file contains environment variables along with test methods to run and/or ignore, this can be useful for customizing or sharding test suites. The given path may be in the local filesystem or in Google Cloud Storage using a URL beginning with `gs://`.z--xcode-versional        The version of Xcode that should be used to run an XCTest. Defaults to the
      latest Xcode version supported in Firebase Test Lab. This Xcode version
      must be supported by all iOS versions selected in the test matrix. The
      list of Xcode versions supported by each version of iOS can be viewed by
      running `$ {parent_command} versions list`.r.   --devicer0   r<   appendDIMENSION=VALUEa        A list of ``DIMENSION=VALUE'' pairs which specify a target device to test
      against. This flag may be repeated to specify multiple devices. The device
      dimensions are: *model*, *version*, *locale*, and *orientation*. If any
      dimensions are omitted, they will use a default value. The default value,
      and all possible values, for each dimension can be found with the
      ``list'' command for that dimension, such as `$ {parent_command} models
      list`. Omitting this flag entirely will run tests against a single device
      using defaults for every dimension.

      Examples:

      ```
      --device model=iphone8plus
      --device version=11.2
      --device model=ipadmini4,version=11.2,locale=zh_CN,orientation=landscape
      ```
      r    r   r   r   r   r>   a  The history name for your test results (an arbitrary string label; default: the bundle ID for the iOS application). All tests which use the same history name will have their results grouped together in the Firebase console in a time-ordered test history list.r   r-   zThe path to the application archive (.ipa file) for game-loop testing. The path may be in the local filesystem or in Google Cloud Storage using gs:// notation. This flag is only valid when *--type* is *game-loop* or *robo*.z--test-special-entitlementsr   Na        Enables testing special app entitlements. Re-signs an app having special
      entitlements with a new application-identifier. This currently supports
      testing Push Notifications (aps-environment) entitlement for up to one
      app in a project.

      Note: Because this changes the app's identifier, make sure none of the
      resources in your zip file contain direct references to the test app's
      bundle id.
      r   )r!   r   r%   r
   r#   r'   s    r)   AddIosTestArgsr\     s:    	''-)  + 	''	   	'',	  	- 	''5  6 	''!,
  . 	N  O 	0   	#	
	  r+   c                     A g)zRegister args which are only available in the beta run commands.

Args:
  parser: An argparse parser used to add args that follow a command.
N r'   s    r)   AddBetaArgsr_          r+   c                     A g)zRegister args which are only available in the GA run command.

Args:
  parser: An argparse parser used to add args that follow a command.
Nr^   r'   s    r)   	AddGaArgsrb     r`   r+   c                     U R                  SSS9nUR                  SS[        R                  SS9  UR                  SS	S
SS9  U R                  SSSSSS/S9  g)zRegister args which are only available in the Android beta run command.

Args:
  parser: An argparse parser used to add args that follow a command.
TzSharding options.)mutexr   z--num-uniform-shardsr   a        Specifies the number of shards across which to distribute test cases. The
      shards are run in parallel on separate devices. For example, if your test
      execution contains 20 test cases and you specify four shards, the
      instrumentation command passes arguments of `-e numShards 4` to
      AndroidJUnitRunner and each shard executes about five test cases. Based on
      the sharding mechanism AndroidJUnitRunner uses, there is no guarantee that
      test cases will be distributed with perfect uniformity.

      The number of shards specified must always be a positive number that is no
      greater than the total number of test cases. When you select one or more
      physical devices, the number of shards specified must be <= 50. When you
      select one or more Arm virtual devices, the number of shards specified
      must be <= 200. When you select only x86 virtual devices, the number of
      shards specified must be <= 500.
      r   z--test-targets-for-shardTEST_TARGETS_FOR_SHARDrY   a"        Specifies a group of packages, classes, and/or test cases to run in
      each shard (a group of test cases). Each time this flag is repeated, it
      creates a new shard. The shards are run in parallel on separate devices.
      You can repeat this flag up to 50 times when you select one or more
      physical devices, up to 200 times when you select one or more Arm virtual
      devices, and up to 500 times when you select only x86 virtual devices.

      Note: If you include the flags *--environment-variable* or
      *--test-targets* when running *--test-targets-for-shard*, the former flags
      are applied to all of the shards you create.

      Examples:

      You can also specify multiple packages, classes, or test cases in the
      same shard by separating each item with a comma. For example:

      ```
      --test-targets-for-shard
      "package com.package1.for.shard1,com.package2.for.shard1"
      ```

      ```
      --test-targets-for-shard
      "class com.foo.ClassForShard2#testMethod1,com.foo.ClassForShard2#testMethod2"
      ```

      To specify both package and class in the same shard, separate `package`
      and `class` with semicolons:

      ```
      --test-targets-for-shard
      "class com.foo.ClassForShard3;package com.package.for.shard3"
      ```
      )r   r   r   z--grant-permissionsPERMISSIONSzsWhether to grant runtime permissions on the device before the test begins. By default, all permissions are granted.Nallnone)r   r   r   rE   )	add_groupr!   r   POSITIVE_INT_PARSER)r(   sharding_optionss     r)   AddAndroidBetaArgsrl     s     %%D7J%K++
	   (  &"
	   &N 	9fo  r+   c           
      T   U R                  S[        R                  " SSS9SSS9  U R                  S[        R                  " SS	9S
SS9  U R                  S[        R                  " 5       SSS9  U R                  SS[        R                  " [        SSS9SS9  U R                  SSS9  g)zRegister args which are only available in the iOS beta run command.

Args:
  parser: An argparse parser used to add args that follow a command.
z--additional-ipasr0   r1   r2   IPAzList of up to 100 additional IPAs to install, in addition to the one being directly tested. The path may be in the local filesystem or in Google Cloud Storage using gs:// notation.r   r;   r<   r=   a        A list of device-path=file-path pairs that specify the paths of the test
      device and the files you want pushed to the device prior to testing.

      Device paths should either be under the Media shared folder (e.g. prefixed
      with /private/var/mobile/Media) or within the documents directory of the
      filesystem of an app under test (e.g. /Documents). Device paths to app
      filesystems should be prefixed by the bundle ID and a colon. Source file
      paths may be in the local filesystem or in Google Cloud Storage
      (gs://...).

      Examples:

      ```
      --other-files com.my.app:/Documents/file.txt=local/file.txt,/private/var/mobile/Media/file.jpg=gs://bucket/file.jpg
      ```
      r6   r7   a        A list of paths that will be copied from the device's storage to
      the designated results bucket after the test is complete. These must be
      absolute paths under `/private/var/mobile/Media` or `/Documents` of the
      app under test. If the path is under an app's `/Documents`, it must be
      prefixed with the app's bundle id and a colon.

      Example:

      ```
      --directories-to-pull=com.my.app:/Documents/output,/private/var/mobile/Media/output
      ```
      rI   r   rJ   rK   a3  A list of game-loop scenario numbers which will be run as part of the test (default: scenario 1). A maximum of 1024 scenarios may be specified in one test matrix, but the maximum number may also be limited by the overall test *--timeout* setting. This flag is only valid when *--type=game-loop* is also set.r   r?   a        The path to a Robo Script JSON file. The path may be in the local
      filesystem or in Google Cloud Storage using gs:// notation. You can
      guide the Robo test to perform specific actions by specifying a Robo
      Script with this argument. Learn more at
      https://firebase.google.com/docs/test-lab/robo-ux-test#scripting.
      This flag is only valid when *--type=robo* is also set.
      r   N)r!   r
   rO   r#   r   r'   s    r)   AddIosBetaArgsro   T  s     	!<9	  : 	!,%
	  $ 	 

	  $ 	CA$O8	  	 	
  	r+   c                    U R                  S[        R                  [        R                  " SS9SSSS9  U R                  SS	[
        [        R                  " SS9S
SS9  U R                  SS[
        [        R                  " SS9SSS9  U R                  SS[
        [        R                  " SS9SSS9  U R                  SS[
        [        R                  " SS[        R                  S9[        R                  " [        5      SSS9  g)zRegister the repeatable args which define the axes for a test matrix.

Args:
  parser: An argparse parser used to add arguments that follow a command
      in the CLI.
rX   r0   r<   rY   rZ   a        A list of ``DIMENSION=VALUE'' pairs which specify a target device to test
      against. This flag may be repeated to specify multiple devices. The four
      device dimensions are: *model*, *version*, *locale*, and *orientation*. If
      any dimensions are omitted, they will use a default value. The default
      value, and all possible values, for each dimension can be found with the
      ``list'' command for that dimension, such as `$ {parent_command} models
      list`. *--device* is now the preferred way to specify test devices and may
      not be used in conjunction with *--devices-ids*, *--os-version-ids*,
      *--locales*, or *--orientations*. Omitting all of the preceding
      dimension-related flags will run tests against a single device using
      defaults for all four device dimensions.

      Examples:

      ```
      --device model=Nexus6
      --device version=23,orientation=portrait
      --device model=shamu,version=22,locale=zh_CN,orientation=default
      ```
      r[   z--device-idsz-dMODEL_IDzThe list of MODEL_IDs to test against (default: one device model determined by the Firebase Test Lab device catalog; see TAGS listed by the `$ {parent_command} models list` command).rH   z--os-version-idsz-vOS_VERSION_IDzvThe list of OS_VERSION_IDs to test against (default: a version ID determined by the Firebase Test Lab device catalog).z	--localesz-lLOCALEzrThe list of LOCALEs to test against (default: a single locale determined by the Firebase Test Lab device catalog).z--orientationsz-or9   )r3   r4   rE   ORIENTATIONzThe device orientation(s) to test against (default: portrait). Specifying 'default' will pick the preferred orientation for the app.)r    r   r   r   r   N)r!   r   r%   r
   r#   DEPRECATED_DEVICE_DIMENSIONSrO   r   ORIENTATION_LISTGetMultiCompleterOrientationsCompleterr'   s    r)   AddMatrixArgsry     s)    	''!,
  4 	
+!,:  ; 	
+!,=  > 	
+!,=  > 	
+1l.K.KM--.CD  
r+   c                 |    [         R                   Vs/ s H  o3R                  U 5      (       d  M  UPM     sn$ s  snf )N)r   rv   
startswith)prefixunused_parsed_argsunused_kwargsps       r)   rx   rx     s+    !22	K2ll66J!2	KK	Ks   99c                     US   US   -   [        US   R                  5       5      -   nU R                  5        H.  nUUS   US   -   [        US   R                  5       5      -   -  nM0     [        U5      $ )aX  Build a set of all possible 'gcloud test run' args.

We need this set to test for invalid arg combinations because gcloud core
adds many args to our args.Namespace that we don't care about and don't want
to validate. We also need this to validate args coming from an arg-file.

Args:
  type_rules: a nested dictionary defining the required and optional args
    per type of test, plus any default values.
  shared_rules: a nested dictionary defining the required and optional args
    shared among all test types, plus any default values.

Returns:
  A set of strings for every gcloud-test argument.
requiredoptionaldefaults)listkeysvaluesset)
type_rulesshared_rulesall_test_args_list	type_dicts       r)   GetSetOfAllTestArgsr     s    " :j!99D
z
"
'
'
)=+ +  $$&i*	* 55j!&&(9* 	*+ ' 
	  r+   c                    U H  n[        XS5      cL  [        R                  " SR                  U[        R
                  " X   5      5      5        [        XX   5        M\  U(       d  Me  [        X5      X   :w  d  Mx  [        R                  " U5      n[        R                  " SR                  U[        [        X5      5      U[        X   5      5      5        M     g)a  Apply lower-priority arg values from a dictionary to args without values.

May be used to apply arg default values, or to merge args from another source,
such as an arg-file. Args which already have a value are never modified by
this function. Thus, if there are multiple sets of lower-priority args, they
should be applied in order from highest-to-lowest precedence.

Args:
  args: the existing argparse.Namespace. All the arguments that were provided
    to the command invocation (i.e. group and command arguments combined),
    plus any arg defaults already applied to the namespace. These args have
    higher priority than the lower_pri_args.
  lower_pri_args: a dict mapping lower-priority arg names to their values.
  issue_cli_warning: (boolean) issue a warning if an arg already has a value
    from the command line and we do not apply the lower-priority arg value
    (used for arg-files where any args specified in the file are lower in
    priority than the CLI args.).
NzApplying default {0}: {1}zDCommand-line argument "--{0} {1}" overrides file argument "{2}: {3}")getattrr   debugformatsix	text_typesetattrr   ExternalArgNameFromwarning_FormatArgValue)argslower_pri_argsissue_cli_warningargext_names        r)   ApplyLowerPriorityArgsr     s    & ct$'	ii+S]]>+>?@Bd,-		wt1^5HH//4h	kk
P6(!'$"45x!."5689 r+   c                 z    [        U [        5      (       a  SR                  U 5      $ [        R                  " U 5      $ )N )
isinstancer   joinr   r   )values    r)   r   r   $  s,    t88E?==r+   )F) __doc__
__future__r   r   r   $googlecloudsdk.api_lib.firebase.testr   r   r   googlecloudsdk.callioper	   r
   r   googlecloudsdk.corer   r   rQ   rP   rR   ru   r*   rS   r\   r_   rb   rl   ro   ry   rx   r   r   r   r^   r+   r)   <module>r      s    E &  ' 9 = ; + / ( # 
= ' 1 = ]*@P7f\~IXGTDNL!49B r+   