fix(examples): update example policies and test script#2378
fix(examples): update example policies and test script#2378Piskoo merged 1 commit intochainloop-dev:mainfrom
Conversation
…shness test Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
| if output=$($CHAINLOOP_BIN policy develop lint --policy "$policy_file" 2>&1); then | ||
| echo -e "${GREEN}✓ PASSED${NC}" | ||
| ((TESTS_PASSED++)) | ||
| ((TESTS_PASSED++)) || true |
There was a problem hiding this comment.
Hi! could you give some color on why we need this?
thanks!
There was a problem hiding this comment.
Apparently ((TESTS_PASSED++)) uses post increment so here it returns 0 which causes the script to exit (bash expr). ((++TESTS_PASSED)) would fix that as well but as defensive measure I've used || true
since from what I understood from other tests that use this utils, it is meant to return exit code with test_summary .
There was a problem hiding this comment.
but is this issue related to your change? Why wasn't it failing before? Out of curiosity what's the root cause
There was a problem hiding this comment.
No, it was failing before, I'm not sure which released version caused it to not work, unless it wasn't working since the beginning
| if output=$($CHAINLOOP_BIN policy develop lint --policy "$policy_file" 2>&1); then | ||
| echo -e "${GREEN}✓ PASSED${NC}" | ||
| ((TESTS_PASSED++)) | ||
| ((TESTS_PASSED++)) || true |
There was a problem hiding this comment.
but is this issue related to your change? Why wasn't it failing before? Out of curiosity what's the root cause
This PR fixes issue with
_testutils.shfunctions returning exit codes in lint and eval functions. Older example policies got linted withpolicy devel lint --formatto make them consistent with other examples. One of the tests in freshness policy was fixed since it was time depended. Regex is used to find result fields in the output so no additional changes were needed to adjust the script to the newevaloutput.Closes #2376