Skip to content

Commit 0b9b4c3

Browse files
committed
Optimized test reports
1 parent 9f76d49 commit 0b9b4c3

5 files changed

Lines changed: 1733 additions & 2 deletions

File tree

src/main/java/de/mirkosertic/metair/ir/test/MetaIRTestHelper.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.PrintStream;
1616
import java.lang.classfile.ClassModel;
1717
import java.lang.classfile.MethodModel;
18+
import java.lang.constant.ClassDesc;
1819
import java.nio.file.Files;
1920
import java.nio.file.Path;
2021

@@ -34,10 +35,21 @@ public MethodAnalyzer analyzeAndReport(final ClassModel model, final MethodModel
3435
}
3536

3637
public MethodAnalyzer analyzeAndReport(final ResolvedMethod resolvedMethod) throws IOException {
37-
try (final PrintStream ps = new PrintStream(Files.newOutputStream(outputDirectory.resolve("bytecode.yaml")))) {
38+
try (final var ps = new PrintStream(Files.newOutputStream(outputDirectory.resolve("bytecode.yaml")))) {
3839
ps.print(resolvedMethod.methodModel().toDebugString());
3940
}
4041

42+
final ClassDesc thisType = resolvedMethod.thisClass().thisType().type();
43+
final String fullQualifiedClassNameOfMethod = thisType.packageName() + "." + thisType.displayName();
44+
final String sourceFileNameURL = "https://raw.githubusercontent.com/mirkosertic/MetaIR/refs/heads/main/src/test/java/" + fullQualifiedClassNameOfMethod.replace(".", "/") + ".java";
45+
46+
try (final PrintStream ps = new PrintStream(Files.newOutputStream(outputDirectory.resolve("report.html")))) {
47+
try (final var is = MetaIRTestHelper.class.getResourceAsStream("/report-template.html")) {
48+
final String content = new String(is.readAllBytes());
49+
ps.print(content.replace("${sourcefileurl}", sourceFileNameURL));
50+
}
51+
}
52+
4153
try {
4254
final MethodAnalyzer analyzer = resolvedMethod.analyze();
4355

@@ -56,7 +68,7 @@ public MethodAnalyzer analyzeAndReport(final ResolvedMethod resolvedMethod) thro
5668
new Sequencer<>(analyzer.ir(), debugStructuredControlflowCodeGenerator);
5769
final PrintStream sequenced = new PrintStream(Files.newOutputStream(outputDirectory.resolve("sequenced.txt")));
5870
sequenced.print(debugStructuredControlflowCodeGenerator);
59-
71+
6072
return analyzer;
6173
} catch (final IllegalParsingStateException ex) {
6274

0 commit comments

Comments
 (0)