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

     1  doc_meta: |
     2    folder: call-func
     3    title: chained calls and return values
     4    head: |
     5      Showcase that the return value will be used correctly in the chained call
     6  
     7    sections:
     8      - title: Demo
     9        content: |
    10          In this case, the first called sub task - facts will gather the var value of .os and then return its value to caller, then the subsequent call to testingWarning task should print correct os value
    11        log: yes
    12  
    13  notes: |
    14    bug fix the chained callee tasks should have the correct return values from previous steps
    15  
    16  tasks:
    17  
    18    -
    19      name: facts
    20      desc: gather facts
    21      task:
    22        -
    23          func: shell
    24          do:
    25            - uname
    26          reg: result
    27  
    28        - func: cmd
    29          desc: get os  - [Darwin | Linux]
    30          dvars:
    31            - name: os
    32              value: '{{ .result.Output }}'
    33              flags:
    34                - v
    35          do:
    36            - name: print
    37              cmd: 'facts OS: {{.os}}'
    38            - name: return
    39              cmd:
    40                - os
    41  
    42    -
    43      name: testingWarning
    44      desc: it should warn if the build task is for testing only
    45      task:
    46        - func: block
    47          do:
    48            - func: cmd
    49              do:
    50                - name: print
    51                  cmd: 'in sub task - building OS: {{.os}}'
    52                - name: colorPrint
    53                  cmd:
    54                    msg: ?? WARN - This is a build for testing purpose only
    55                    fg: red
    56          if: '{{ eq .os "Darwin" }}'
    57  
    58    -
    59      name: task
    60      desc: build the showcases automatically
    61      task:
    62  
    63        - func: call
    64          do:
    65            - facts
    66            - testingWarning
    67  
    68        - func: cmd
    69          do:
    70            - name: print
    71              cmd: 'in main task - building OS: {{.os}}'