github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0192.yml (about)

     1  doc_meta: |
     2    folder: flow-controll
     3    title: finally/resuce support in task level
     4    head: |
     5      Showcases that all tasks with finally block will be guranteed to do the final code block
     6  
     7    sections:
     8      - title: Demo
     9        log: yes
    10  
    11    related:
    12      refs:
    13        - title: shell func
    14          link: ../../quick-start/c0002/
    15        - title: error handling
    16          link: ../../test-debug/error_handling/
    17        - title: finally and rescue
    18          link: ../../flow-controll/c0174/
    19        - title: finally in task
    20          link: ../../flow-controll/c0191/
    21        - title: finally in task
    22          link: ../../flow-controll/c0189/
    23        - title: finally block
    24          link: ../../flow-controll/c0183/
    25        - title: finally block
    26          link: ../../flow-controll/c0184/
    27        - title: finally block
    28          link: ../../flow-controll/c0187/
    29        - title: finally block
    30          link: ../../flow-controll/f0188/
    31        - title: finally block
    32          link: ../../flow-controll/f0185/
    33        - title: finally block
    34          link: ../../flow-controll/f0186/
    35  
    36  notes:
    37    - add finally support to tasks level
    38  
    39  vars:
    40    global_aa: aa
    41  
    42  tasks:
    43  
    44    -
    45      name: task
    46      task:
    47        -
    48          func: block
    49          desc: loop through test cases
    50          vars:
    51            local_bb: bb
    52          dvars:
    53            - name: task_tt
    54              value: tt
    55              flags: [taskScope]
    56          loop:
    57            - item1
    58            - item2
    59          do:
    60            -
    61              func: shell
    62              do:
    63                - 'echo "main task start"'
    64  
    65            - func: call
    66              do: cc
    67  
    68      finally:
    69        -
    70          func: shell
    71          vars:
    72            finally_task: ff
    73          do:
    74            - 'echo "main task final"'
    75  
    76    -
    77      name: cc
    78      task:
    79        -
    80          func: shell
    81          do:
    82            - echo "in cc ...."
    83      finally:
    84        -
    85          func: shell
    86          vars:
    87            finally_cc: cc
    88          name: close_file
    89          desc: |
    90            ensure the opened file is closed
    91          do:
    92            - 'echo "close the file {{.loopitem}}"'