Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return code != 0 when tests are failing #69

Open
axel3rd opened this issue Jun 14, 2022 · 0 comments
Open

Return code != 0 when tests are failing #69

axel3rd opened this issue Jun 14, 2022 · 0 comments

Comments

@axel3rd
Copy link

axel3rd commented Jun 14, 2022

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 ... not active project since 7 years ... so perhaps less easy 😢).

Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant