@@ -49,6 +49,7 @@ type testCommandParams struct {
49
49
runRegex string
50
50
count int
51
51
skipExitZero bool
52
+ varValues bool
52
53
}
53
54
54
55
func newTestCommandParams () * testCommandParams {
@@ -167,7 +168,8 @@ func opaTest(args []string) int {
167
168
WithEnablePrintStatements (! testParams .benchmark ).
168
169
WithSchemas (compile .RegalSchemaSet ()).
169
170
WithUseTypeCheckAnnotations (true ).
170
- WithModuleLoader (moduleLoader (regalBundle ))
171
+ WithModuleLoader (moduleLoader (regalBundle )).
172
+ WithRewriteTestRules (testParams .varValues )
171
173
172
174
if testParams .threshold > 0 && ! testParams .coverage {
173
175
testParams .coverage = true
@@ -192,6 +194,7 @@ func opaTest(args []string) int {
192
194
SetCompiler (compiler ).
193
195
SetStore (store ).
194
196
CapturePrintOutput (true ).
197
+ EnableTracing (testParams .verbose || testParams .varValues ).
195
198
SetCoverageQueryTracer (coverTracer ).
196
199
SetRuntime (Runtime ()).
197
200
SetModules (modules ).
@@ -256,6 +259,8 @@ func testReporter(cov *cover.Cover, modules map[string]*ast.Module) tester.Repor
256
259
BenchmarkResults : testParams .benchmark ,
257
260
BenchMarkShowAllocations : testParams .benchMem ,
258
261
BenchMarkGoBenchFormat : goBench ,
262
+ FailureLine : testParams .varValues ,
263
+ LocalVars : testParams .varValues ,
259
264
}
260
265
}
261
266
} else {
@@ -358,6 +363,8 @@ func init() {
358
363
"benchmark the unit tests" )
359
364
testCommand .Flags ().StringVarP (& testParams .runRegex , "run" , "r" , "" ,
360
365
"run only test cases matching the regular expression." )
366
+ testCommand .Flags ().BoolVar (& testParams .varValues ,
367
+ "var-values" , false , "show local variable values in test output" )
361
368
362
369
addPprofFlag (testCommand .Flags ())
363
370
addBundleModeFlag (testCommand .Flags (), & testParams .bundleMode , false )
0 commit comments