sequence matters in return 2

This shows that the sequence of the return matters.

In this demo, when callee’s var value is updated in its own stack or callee stack, the return cmd will return the updated value to caller

Demo

source

Main task yaml file
    vars:
      tom: this is tom in global
      jerry: this is jerry in global
    tasks:
    - name: task
      desc: main entry
      task:
      - func: call
        name: main task
        desc: call subtask and exam the return value in following steps
        do: subtask1
      - func: cmd
        desc: |
          check value of tom
          in this case tom's value should come from subtask1
          tom's expected value:  tom created in subtask1
        do:
        - name: print
          cmd: 'in main task print3: {{.tom}}'
    - name: subtask1
      desc: subtask to test reg and return
      task:
      - func: cmd
        desc: check value of tom after it is registered in current task stack
        vars:
          john: john in sub_loop func1
        do:
        - name: reg
          desc: by default hitom is registered in to global context
          cmd:
            name: tom
            value: 'tom created in subtask1'
        - name: print
          cmd: 'in subtask1 print1: {{.tom}}'
      - func: cmd
        desc: check value of tom and it should be available in current stack
        vars:
          john: john in sub_loop func2
        do:
        - name: print
          cmd: 'in subtask1 print21: {{.tom}}'
      - func: call
        desc: call subtask and exam the return value in following steps
        do:
        - subtask2
        - subtask3
      - func: cmd
        desc: check value of tom and it should be available in current stack
        vars:
          john: john in sub_loop func2
        do:
        - name: print
          cmd: 'in subtask1 print22: {{.tom}}'
        - name: return
          cmd:
          - tom
    - name: subtask2
      desc: subtask to test reg and return
      task:
      - func: cmd
        desc: check value of tom after it is registered in current task stack
        vars:
          john: john in sub_loop func1
        do:
        - name: reg
          desc: by default hitom is registered in to global context
          cmd:
            name: tom
            value: 'tom2 created in subtask2'
        - name: print
          cmd: 'in subtask2 print1: {{.tom}}'
      - func: cmd
        desc: check value of tom and it should be available in current stack
        vars:
          john: john in sub_loop func2
        do:
        - name: print
          cmd: 'in subtask2 print2: {{.tom}}'
        - name: return
          cmd:
          - tom
    - name: subtask3
      desc: subtask3
      task:
      - func: cmd
        desc: dummy
        do:
        - name: print
          cmd: 'dummy to help build inspect task'
    
Main log file
    loading [Config]:  ./tests/functests/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/functests
                 WorkDir -> cwd
              AbsWorkDir -> /up_project/up
                TaskFile -> c0115
                 Verbose -> vvv
              ModuleName -> self
               ShellType -> /bin/sh
           MaxCallLayers -> 8
                 Timeout -> 3600000
     MaxModuelCallLayers -> 256
               EntryTask -> task
      ModRepoUsernameRef -> 
      ModRepoPasswordRef -> 
    work dir: /up_project/up
    -exec task: task
    loading [Task]:  ./tests/functests/c0115
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task: main entry ]
    -Step1: [main task: call subtask and exam the return value in following steps ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 0,
      "tom": "this is tom in global",
      "jerry": "this is jerry in global"
    })
    
    =Task2: [task ==> subtask1: subtask to test reg and return ]
    --Step1: [: check value of tom after it is registered in current task stack ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 1,
      "tom": "this is tom in global",
      "john": "john in sub_loop func1",
      "jerry": "this is jerry in global"
    })
    
    ~~SubStep1: [reg: by default hitom is registered in to global context ]
    ~~SubStep2: [print:  ]
    in subtask1 print1: tom created in subtask1
    --Step2: [: check value of tom and it should be available in current stack ]
    self: final context exec vars:
    
    (*core.Cache)({
      "tom": "tom created in subtask1",
      "jerry": "this is jerry in global",
      "up_runtime_task_layer_number": 1,
      "john": "john in sub_loop func2"
    })
    
    ~~SubStep1: [print:  ]
    in subtask1 print21: tom created in subtask1
    --Step3: [: call subtask and exam the return value in following steps ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 1,
      "tom": "tom created in subtask1",
      "jerry": "this is jerry in global"
    })
    
    ==Task3: [task/subtask1 ==> subtask2: subtask to test reg and return ]
    ---Step1: [: check value of tom after it is registered in current task stack ]
    self: final context exec vars:
    
    (*core.Cache)({
      "tom": "tom created in subtask1",
      "jerry": "this is jerry in global",
      "john": "john in sub_loop func1",
      "up_runtime_task_layer_number": 2
    })
    
    ~~~SubStep1: [reg: by default hitom is registered in to global context ]
    ~~~SubStep2: [print:  ]
    in subtask2 print1: tom2 created in subtask2
    ---Step2: [: check value of tom and it should be available in current stack ]
    self: final context exec vars:
    
    (*core.Cache)({
      "jerry": "this is jerry in global",
      "up_runtime_task_layer_number": 2,
      "tom": "tom2 created in subtask2",
      "john": "john in sub_loop func2"
    })
    
    ~~~SubStep1: [print:  ]
    in subtask2 print2: tom2 created in subtask2
    ~~~SubStep2: [return:  ]
    ==Task4: [task/subtask1 ==> subtask3: subtask3 ]
    ---Step1: [: dummy ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 2,
      "tom": "tom2 created in subtask2",
      "jerry": "this is jerry in global"
    })
    
    ~~~SubStep1: [print:  ]
    dummy to help build inspect task
    --Step4: [: check value of tom and it should be available in current stack ]
    self: final context exec vars:
    
    (*core.Cache)({
      "john": "john in sub_loop func2",
      "tom": "tom2 created in subtask2",
      "jerry": "this is jerry in global",
      "up_runtime_task_layer_number": 2
    })
    
    ~~SubStep1: [print:  ]
    in subtask1 print22: tom2 created in subtask2
    ~~SubStep2: [return:  ]
    -Step2: [
    check value of tom
    in this case tom's value should come from subtask1
    tom's expected value:  tom created in subtask1
    ]
    self: final context exec vars:
    
    (*core.Cache)({
      "tom": "tom2 created in subtask2",
      "jerry": "this is jerry in global",
      "up_runtime_task_layer_number": 2
    })
    
    ~SubStep1: [print:  ]
    in main task print3: tom2 created in subtask2
    
Logs with different verbose level
Raw logs with different verbose level