Return code != 0 when tests are failing

#69 ยท open ยท 0 comments

View on GitHub โ†—

axel3rd

First of all, thanks for your work. TesTcl is wonderful for accelerating & testing F5 iRules ๐Ÿ˜. A common practice in CI pipelines is to fail build when tests are failing (on pull request for sample). An easy way is to use the *return code* of test command, which is a default behavior when result is != 0. I'm trying to achieve it without success. I agree a trick could be to analyze the output log, but less beautiful way. Snippet for reproduction: ``` # File: sample.tcl rule sample { when HTTP_REQUEST { HTTP::header replace "Some-Header" "FooBar" } } ``` ``` # File: test_sample.tcl package require -exact testcl 1.0.14 namespace import ::testcl::* it "should fail" { event HTTP_REQUEST verify "Header added" "FooBar" eq {HTTP::header "Some-Header"} verify "Header does not exist should fail" "No Value" eq {HTTP::header "Header-Not-Exist"} run sample.tcl sample } ``` Command execution (Using #51, really useful ... and problem seems not linked to Docker): ``` $ docker run -it --rm -v $(pwd):/app jones2748/docker-testcl jtcl /app/test_sample.tcl ************************************************************************** * it should fail ************************************************************************** verification of 'Header added' done. -> Test failure!! -> -> Verification 'Header does not exist should fail' failed - expression: {No Value} eq {} error Verification 'Header does not exist should fail' failed - expression: {No Value} eq {} $ echo $? 0 ``` Is it a way to achieve it with TesTcl or the problem is in used components (like [jtcl](https://github.com/jtcl-project/jtcl) ... not active project since 7 years ... so perhaps less easy ๐Ÿ˜ข). Many thanks.

Comments