Skip to content

Commit d5c2671

Browse files
Make sure golden file matches output of regression test, during warmup (#544)
This is more of a sanity check
1 parent 22e264a commit d5c2671

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

bench/src/sjsonnet/bench/RegressionBenchmark.scala

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import org.openjdk.jmh.annotations.*
44
import org.openjdk.jmh.infra.*
55
import sjsonnet.*
66

7-
import java.io.{OutputStream, PrintStream, StringWriter}
7+
import java.io.{OutputStream, PrintStream, ByteArrayOutputStream}
88
import java.util.concurrent.TimeUnit
99

1010
object RegressionBenchmark {
@@ -31,6 +31,32 @@ class RegressionBenchmark {
3131

3232
private val dummyOut = RegressionBenchmark.createDummyOut
3333

34+
@Setup(Level.Trial)
35+
def setup(): Unit = {
36+
val baos = new ByteArrayOutputStream()
37+
val ps = new PrintStream(baos)
38+
SjsonnetMainBase.main0(
39+
Array(path),
40+
new DefaultParseCache,
41+
System.in,
42+
ps,
43+
System.err,
44+
RegressionBenchmark.testSuiteRoot,
45+
None
46+
)
47+
ps.close()
48+
baos.close()
49+
val golden = os.read(os.Path(path + ".golden", RegressionBenchmark.testSuiteRoot)).stripLineEnd
50+
if (baos.toString("UTF-8").stripLineEnd != golden) {
51+
System.err.println(
52+
"Golden output mismatch:\n%s != %s".format(
53+
baos.toString("UTF-8").stripLineEnd,
54+
golden
55+
)
56+
)
57+
}
58+
}
59+
3460
@Benchmark
3561
def main(bh: Blackhole): Unit = {
3662
bh.consume(

0 commit comments

Comments
 (0)