github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0189.yml (about) 1 doc_meta: | 2 folder: flow-controll 3 title: task finally always emit 4 head: | 5 Showcases that the finally block will be always fired even there is no exception / error 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 block 20 link: ../../flow-controll/c0183/ 21 - title: finally block 22 link: ../../flow-controll/c0184/ 23 - title: finally block 24 link: ../../flow-controll/c0187/ 25 - title: finally block 26 link: ../../flow-controll/f0188/ 27 - title: finally block 28 link: ../../flow-controll/f0185/ 29 - title: finally block 30 link: ../../flow-controll/f0186/ 31 32 notes: 33 - add finally support to tasks level 34 35 vars: 36 global_aa: aa 37 38 tasks: 39 - 40 name: task 41 task: 42 - 43 func: shell 44 vars: 45 local_bb: bb 46 dvars: 47 - name: task_tt 48 value: tt 49 flags: [taskScope] 50 name: step1 51 desc: step 1 52 do: 53 - echo "opening file" 54 55 desc: | 56 without rescue, the execution will return a non-zero return code in shell and also report the error 57 with rescue, the program will return 0 58 rescue: true 59 finally: 60 - 61 func: shell 62 vars: 63 finally_cc: cc 64 name: close_file 65 desc: | 66 ensure the opened file is closed 67 do: 68 - echo "close the file ....."