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

     1  doc_meta: |
     2    folder: call-func
     3    title: multiple layers overriding
     4    head: |
     5      This showcases the vars in callee will be overriden if there is a same name var passed from caller. This is a feature of call func
     6  
     7    sections:
     8      - title: Demo
     9        log: yes
    10  
    11  notes:
    12    - need a new design of caller vars passing down to callee
    13    - the reg only regs the var to the protected stack vars, which is based from caller's vars
    14    - in callee task, for vars, including taskScope vars, reg
    15      vars or dvar, support a option to return the var value
    16      to be registered and merged to caller's vars
    17    - the callee task should not have any direct access to RuntimeVarsAndDvarsMerged
    18    - func in callee should use caller's vars as base only, the reg cmd regs to caller's vars
    19  
    20  vars:
    21    global_a: aaa
    22    global_b: bbb
    23  
    24  tasks:
    25    -
    26      name: task
    27      task:
    28        -
    29          func: call
    30          vars:
    31            local_a: aaa
    32            local_b: bbb
    33            tom: my name is tom
    34          do:
    35            - subtask1
    36  
    37    -
    38      name: subtask1
    39      task:
    40        -
    41          func: cmd
    42          do:
    43            - name: print
    44              cmd: '{{.tom}}'
    45  
    46            -
    47              name: assert
    48              cmd:
    49                - '{{eq .tom "my name is tom"}}'
    50  
    51  
    52        -
    53          func: cmd
    54          vars:
    55            tom: 'hi i am tom'
    56          do:
    57            - name: print
    58              cmd: '{{.tom}}'
    59  
    60            -
    61              name: assert
    62              cmd:
    63                - '{{eq .tom "my name is tom"}}'
    64  
    65        -
    66          func: call
    67          do:
    68            - subtask2
    69  
    70    -
    71      name: subtask2
    72      task:
    73        -
    74          func: cmd
    75          do:
    76            - name: print
    77              cmd: '{{.tom}}'
    78  
    79            -
    80              name: assert
    81              cmd:
    82                - '{{eq .tom "my name is tom"}}'
    83  
    84        -
    85          func: cmd
    86          vars:
    87            tom: 'hi i am tom'
    88          do:
    89            - name: print
    90              cmd: '{{.tom}}'
    91  
    92  
    93            -
    94              name: assert
    95              cmd:
    96                - '{{eq .tom "my name is tom"}}'