-
Notifications
You must be signed in to change notification settings - Fork 35
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
Regression: regal test can't test itself #199
Comments
There's a module loader mechanism in the ast/compile.go. Perhaps that could be used to bring in regal's own rules...? Not sure at a glance if it'll help 🤞 |
That's interesting, thanks! I took a look but it's not clear to me how that function works, despite having looked at the tests that make use of it 😅 Seems like it'll just keep getting called forever until the modules map is empty or an error is returned. If I run |
That test is weird, granted. The module loader allows you to load extra modules out of band, like, when they are needed, because a certain import directive is present. There test asserts that it works like that until it reaches a fix point: no further extra modules are needed. |
As I understand the code, the Then, the compiler will add them if the length is non-zero: https://github.com/open-policy-agent/opa/blob/main/ast/compile.go#L1631 So perhaps the solution would be to instead of unconditionally loading the bundle into the compiler as I did, add a |
I think that's what I tried doing, but evidently unsuccessfully. If you'd like to have a shot at it, feel free to do so! 😃 |
I am also on vacation at the moment, so my capacity is a bit limited 🌴 But if the weather takes a turn for the worse, I might be able to take a look. No promises though. |
Sounds good! This isn't annoying anyone but me, most likely 😆 And I can work around it. Enjoy your vacation! 🏖️ |
I've been thinking about this some more, I think the ModuleLoader approach won't help us here. Sorry for muddying the waters. I'll have a look at the code, too 😃 |
This was fixed in #286 Thanks again, Stephan! |
Running
regal test bundle
(orgo run main.go test bundle
) now seems to lead to the same files getting loaded twice. I'm guessing that since #197 we now include the bundled files in the test command, and we load them from the filesystem, this dupication is what's triggering the condition.Not sure what the best approach would be for fixing it, while still having the command work for custom rules.
The text was updated successfully, but these errors were encountered: