Skip to content

Commit

Permalink
- B fixed issue with opening multiple files of Linux
Browse files Browse the repository at this point in the history
fixes #429
  • Loading branch information
LarsEckart committed Nov 6, 2023
1 parent 68eb07a commit e649445
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static String which(String command)
{
String command1 = "which " + command;
Process p = Runtime.getRuntime().exec(command1);
String output = FileUtils.readStream(p.getInputStream()).trim();
p.waitFor();
String output = FileUtils.readStream(p.getInputStream()).trim();
int exitValue = p.exitValue();
return exitValue == 0 ? output : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.spun.util.tests;

import com.spun.util.io.FileUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.File;

import static org.junit.jupiter.api.Assertions.assertEquals;

class LinuxOpenerTest
{
@Disabled("This test takes a lot of time to run and opens a browser window")
@Test
void testMultipleFilesOnLinux() throws Exception
{
File tempFile = File.createTempFile("test", ".html");
FileUtils.writeFile(tempFile, "<html><body><h1>Applesauce</h1></body></html>");
int countCorrect = 0;
int totalRuns = 10;
for (int i = 0; i < totalRuns; i++)
{
if (LinuxOpener.executeOnLinux(tempFile.getAbsolutePath(), "open"))
{
countCorrect++;
}
}
assertEquals(totalRuns, countCorrect);
}
}

0 comments on commit e649445

Please sign in to comment.