assert and inspect

Demo you can use assert and inspect

assert

It will go through a list of criteria and show the evaluation result

inspect

It allows you to inspect below:

  1. exec_vars: The runtime execution vars for current func
  2. exec_base_vars: it is the base vars which its func inherit from as base

Demo

source

Main task yaml file
    vars:
      a: global_aaa
      b: global_bbb
      c: global_ccc
    tasks:
    - name: task
      task:
      - func: block
        vars:
          a: local_aaa
          b: local_bbb
        dvars:
        - name: da
          value: local_da
        - name: db
          value: local_db
        do:
        - func: cmd
          vars:
            a: block_layer2_aaa
          do:
          - name: assert
            cmd:
            - '{{eq .a "aaa"}}'
            - '{{eq .a "block_layer2_aaa"}}'
          - name: assert
            cmd:
            - '{{eq .a "aaa"}}'
          - name: inspect
            cmd:
            - exec_vars
            - exec_base_vars
    
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 -> c0132
                 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/c0132
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "da": "local_da",
      "a": "local_aaa",
      "b": "local_bbb",
      "c": "global_ccc",
      "up_runtime_task_layer_number": 0,
      "db": "local_db"
    })
    
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "a": "block_layer2_aaa",
      "b": "local_bbb",
      "up_runtime_task_layer_number": 0,
      "db": "local_db",
      "da": "local_da",
      "c": "global_ccc"
    })
    
    ~SubStep1: [assert:  ]
     1 ASSERT FAILED: [{{eq .a "aaa"}}]
     2 ASSERT OK:     [{{eq .a "block_layer2_aaa"}}]
    ~SubStep2: [assert:  ]
     1 ASSERT FAILED: [{{eq .a "aaa"}}]
    ~SubStep3: [inspect:  ]
     1: inspect[exec_vars]
    (*core.Cache)({
      "up_runtime_task_layer_number": 0,
      "db": "local_db",
      "da": "local_da",
      "c": "global_ccc",
      "a": "block_layer2_aaa",
      "b": "local_bbb"
    })
    
     2: inspect[exec_base_vars]
    {
      "a": "global_aaa",
      "b": "global_bbb",
      "c": "global_ccc"
    }
    
    
Logs with different verbose level
Raw logs with different verbose level