
    	                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dZ	dZ
dZd	Zd
ZdZ G d dej                        Zd Zy)a.  Module to define and determine exit codes for 'gcloud test' commands.

Note: Cloud-SDK-eng is reserving exit codes 1..9 for http errors, invalid args,
bad filename, etc. Gcloud command surfaces are free to use exit codes 10..20.
Gaps in exit_code numbering are left in case future expansion is needed.
    )absolute_import)division)unicode_literals)
exceptions)log
               c                   "     e Zd ZdZ fdZ xZS )TestOutcomeErrorz=The Tool Results backend did not return a valid test outcome.c                 8    t         t        |   |t               y )N)	exit_code)superr   __init__INFRASTRUCTURE_ERR)selfmsg	__class__s     5lib/googlecloudsdk/api_lib/firebase/test/exit_code.pyr   zTestOutcomeError.__init__*   s    	
D*3:L*M    )__name__
__module____qualname____doc__r   __classcell__)r   s   @r   r   r   '   s    EN Nr   r   c                    | r| j                   st        j                  d       t        S | j                   |j                  k(  s| j                   |j
                  k(  rt        S | j                   |j                  k(  rt        S | j                   |j                  k(  rt        S | j                   |j                  k(  rt        S t        dj                  | j                               )a  Map a test roll-up outcome into the appropriate gcloud test exit_code.

  Args:
    outcome: a toolresults_v1.Outcome message.
    summary_enum: a toolresults.Outcome.SummaryValueValuesEnum reference.

  Returns:
    The exit_code which corresponds to the test execution's rolled-up outcome.

  Raises:
    TestOutcomeError: If Tool Results service returns an invalid outcome value.
  z<Tool Results service did not provide a roll-up test outcome.z(Unknown test outcome summary value '{0}')summaryr   warningINCONCLUSIVEsuccessflakyROLLUP_SUCCESSfailureROLLUP_FAILUREskippedUNSUPPORTED_ENVinconclusiver   format)outcomesummary_enums     r   ExitCodeFromRollupOutcomer-   .   s     
KKNOoo---	L..	.__,,,__,,,__111077H	J Jr   N)r   
__future__r   r   r   googlecloudsdk.corer   core_exceptionsr   r$   r&   r!   r(   MATRIX_CANCELLEDr   Errorr   r-    r   r   <module>r4      sW     '  ' = #   N,, NJr   