Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Fix java tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mahesh-hegde committed Jul 4, 2023
1 parent 82881ea commit 1b8afd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.dart_lang.jnigen.apisummarizer;

import com.github.dart_lang.jnigen.apisummarizer.util.Log;
import java.io.File;
import java.io.IOException;
import org.junit.Assert;
Expand Down Expand Up @@ -31,11 +32,22 @@ private int gitDiff(String a, String b) throws IOException, InterruptedException
@Test
public void testExampleSummary() throws IOException, InterruptedException {
var tempFile = File.createTempFile("summarizer_test", ".json");
Log.info("Temporary file: %s", tempFile.getPath());
Main.main(
new String[] {
"-s", "src/test/resources", "com.example.Example", "-o", tempFile.getPath(),
});
int comparison = gitDiff(exampleClassJsonOutput, tempFile);
if (comparison != 0) {
Log.warning("New output (%s) is different than reference output.", tempFile.getPath());
}

// Fail test if git diff exited with 1
Assert.assertEquals(0, comparison);

var deleted = tempFile.delete();
if (!deleted) {
Log.warning("Cannot delete temp file %s", tempFile.getPath());
}
}
}
4 changes: 0 additions & 4 deletions jnigen/java/src/test/resources/exampleClassSummary.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[ {
"declKind" : "CLASS",
"modifiers" : [ "public" ],
"simpleName" : "Example",
"binaryName" : "com.example.Example",
"packageName" : "com.example",
"methods" : [ {
"modifiers" : [ "public" ],
"name" : "<init>",
Expand Down Expand Up @@ -140,10 +138,8 @@
}, {
"declKind" : "CLASS",
"modifiers" : [ "static", "public" ],
"simpleName" : "Aux",
"binaryName" : "com.example.Example$Aux",
"parentName" : "com.example.Example",
"packageName" : "com.example",
"methods" : [ {
"modifiers" : [ "public" ],
"name" : "<init>",
Expand Down

0 comments on commit 1b8afd7

Please sign in to comment.