integration-tester creates implicit Rego packages for every document fragment that is detected as Rego, then compiled the whole conglomeration together in order to preflight compilation and syntax errors before making any cluster changes.
Since the Rego parser only ever sees the Rego language as strings, however, line numbers for error messages are relative to the fragment where the error is, not relative to the test document as a whole. This makes it awkward to correlate errors back to the original source (requires a bit of guesswork).
For example, this error is in part 1, but because it is a duplicate variable definition, we don't know until we compile the whole thing. Since the Rego compiler doesn't have the right line offsets to start with, it can't emit the right error location. The Rego parser has API to pass in the filename of a string to compile, but no API to set the initial line offsets.
$ ./run-test-case.sh ./httpproxy/012-https-fallback-certificate.yaml
TAP version 13
# reading document from ./httpproxy/012-https-fallback-certificate.yaml
# decoding document with 8 parts from ./httpproxy/012-https-fallback-certificate.yaml
# decoded part 0 as Kubernetes (lines 1-10)
# decoded part 1 as Rego (lines 12-42)
# decoded part 2 as Kubernetes (lines 44-121)
# decoded part 3 as Kubernetes (lines 123-131)
# decoded part 4 as Kubernetes (lines 133-141)
# decoded part 5 as Kubernetes (lines 143-158)
# decoded part 6 as Rego (lines 160-186)
# decoded part 7 as Rego (lines 188-214)
ok 1 - validating document "./httpproxy/012-https-fallback-certificate.yaml"
# test run ID is 52f423e6-504e-4e41-97ec-aa8c6349f05a
# Fatal - 1 error occurred: internal/check/ACnGakFqooos:28: rego_compile_error: var msg assigned above
not ok 2 - compiling test document
---
- Message: '1 error occurred: internal/check/ACnGakFqooos:28: rego_compile_error:
var msg assigned above'
Severity: Fatal
Timestamp: "2020-08-03T14:25:30.585828+10:00"
...
# skipping
ok 3 - deleting test objects
1..3
integration-tester
creates implicit Rego packages for every document fragment that is detected as Rego, then compiled the whole conglomeration together in order to preflight compilation and syntax errors before making any cluster changes.Since the Rego parser only ever sees the Rego language as strings, however, line numbers for error messages are relative to the fragment where the error is, not relative to the test document as a whole. This makes it awkward to correlate errors back to the original source (requires a bit of guesswork).
For example, this error is in part 1, but because it is a duplicate variable definition, we don't know until we compile the whole thing. Since the Rego compiler doesn't have the right line offsets to start with, it can't emit the right error location. The Rego parser has API to pass in the filename of a string to compile, but no API to set the initial line offsets.