github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/core/test/test_doc.yaml (about) 1 - DocumentID: test 2 Title: >+ 3 `test` 4 CategoryID: commands 5 Summary: >- 6 Murex's test framework - define tests, run tests and debug shell scripts 7 Description: |- 8 `test` is used to define tests, run tests and debug Murex shell scripts. 9 Usage: |- 10 Define an inlined test 11 12 ``` 13 test define test-name { json-properties } 14 ``` 15 16 Define a state report 17 18 ``` 19 test state name { code block } 20 ``` 21 22 Define a unit test 23 24 ``` 25 test unit function|private|open|event test-name { json-properties } 26 ``` 27 28 Enable or disable boolean test states (more options available in `config`) 29 30 ``` 31 test config [ enable|!enable ] [ verbose|!verbose ] [ auto-report|!auto-report ] 32 ``` 33 34 Disable test mode 35 36 ``` 37 !test 38 ``` 39 40 Execute a function with testing enabled 41 42 ``` 43 test run { code-block } 44 ``` 45 46 Execute unit test(s) 47 48 ``` 49 test run package/module/test-name|* 50 ``` 51 52 Write report 53 54 ``` 55 test report 56 ``` 57 Examples: |- 58 Inlined test 59 60 ``` 61 function hello-world { 62 test define example { 63 "StdoutRegex": (^Hello World$) 64 } 65 66 out <test_example> "Hello Earth" 67 } 68 69 test run { hello-world } 70 ``` 71 72 Unit test 73 74 ``` 75 test unit function aliases { 76 "PreBlock": ({ 77 alias ALIAS_UNIT_TEST=example param1 param2 param3 78 }), 79 "StdoutRegex": "([- _0-9a-zA-Z]+ => .*?\n)+", 80 "StdoutType": "str", 81 "PostBlock": ({ 82 !alias ALIAS_UNIT_TEST 83 }) 84 } 85 86 function aliases { 87 # Output the aliases in human readable format 88 runtime --aliases -> formap name alias { 89 $name -> sprintf "%10s => ${esccli @alias}\n" 90 } -> cast str 91 } 92 93 test run aliases 94 ``` 95 Flags: 96 Detail: |- 97 ### Report 98 99 `test report` is only needed if `config test auto-report` is set false. 100 However `test run` automatically enables **auto-report**. 101 102 When the report is generated, be it automatically or manually triggered, it 103 flushes the table of pending reports. 104 Synonyms: 105 - test 106 - "!test" 107 Related: 108 - config 109 - namedpipe