Skip to content

Commit

Permalink
Improve temp file creation in test suite
Browse files Browse the repository at this point in the history
This is to try to address following errors seen in some GitHub Action
Workflow runs on Windows:
  "Warning:  Files with unapproved licenses:
  force_original.txt"
  • Loading branch information
frankgrimes97 committed Nov 20, 2024
1 parent 6dd9d4f commit 98a0ac8
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void checkNonNativeFile()
public void testMapExceptionNoTWR()
throws IllegalArgumentException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
IOException, SecurityException {
File dummy = createFile("dummy.txt", ""); //zero length
File dummy = createTempFile("dummy", ".txt" , ""); //zero length
try (Arena arena = Arena.ofConfined()) {
Memory.map(arena, dummy, 0, dummy.length(), ByteOrder.nativeOrder());
}
Expand Down Expand Up @@ -161,7 +161,7 @@ public void testForce()
throws IllegalArgumentException, InvalidPathException, IllegalStateException, UnsupportedOperationException,
IOException, SecurityException {
String origStr = "Corectng spellng mistks";
File origFile = createFile("force_original.txt", origStr); //23
File origFile = createTempFile("force_original", ".txt", origStr); //23
assertTrue(origFile.setWritable(true, false));
long origBytes = origFile.length();
String correctStr = "Correcting spelling mistakes"; //28
Expand Down Expand Up @@ -194,8 +194,9 @@ public void testForce()
}
}

private static File createFile(String fileName, String text) throws FileNotFoundException {
File file = new File(fileName);
private static File createTempFile(String fileNamePrefix, String fileNameSuffix, String text)
throws FileNotFoundException, IOException {
File file = File.createTempFile(fileNamePrefix, fileNameSuffix);
file.deleteOnExit();
PrintWriter writer;
try {
Expand Down

0 comments on commit 98a0ac8

Please sign in to comment.