github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0173.yml (about) 1 doc_meta: | 2 folder: flow-controll 3 title: finally steps block 4 head: | 5 Introduce to use the func block instead of routing it to a task 6 7 sections: 8 - title: Demo 9 log: yes 10 11 12 - title: use the anonymouse func block 13 content: | 14 Compare to the example of c0172, this shows that you can simply use a steps block for the cleanup steps 15 16 related: 17 refs: 18 - title: shell func 19 link: ../../quick-start/c0002/ 20 - title: error handling 21 link: ../../test-debug/error_handling/ 22 - title: finally and rescue 23 link: ../../flow-controll/c0172/ 24 25 notes: 26 - test finally block implementation 27 28 29 vars: 30 global_aaa: aaa 31 32 tasks: 33 34 - 35 name: task 36 task: 37 38 - 39 func: cmd 40 desc: step 1 41 vars: 42 local_aaa: local_aaa 43 do: 44 - name: print 45 cmd: step 1 46 - name: panic 47 - name: print 48 cmd: extra step ......... it will never reach here 49 rescue: true 50 finally: 51 - 52 func: cmd 53 do: 54 - name: print 55 cmd: 'global aaa: {{.global_aaa}}' 56 - name: print 57 cmd: 'local aaa: {{.local_aaa}}' 58 59 - 60 func: shell 61 name: close_file 62 desc: | 63 ensure the opened file is closed 64 do: 65 - echo "close the file ....." 66 67 - 68 func: cmd 69 desc: extra steps 70 do: 71 - name: print 72 cmd: extra step 73 74 - 75 func: cmd 76 desc: step 2 77 do: 78 - name: print 79 cmd: step 2