Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestUtils.displayFile(String Filename) fails on linux #251

Closed
brianberzins opened this issue Apr 3, 2022 · 3 comments
Closed

TestUtils.displayFile(String Filename) fails on linux #251

brianberzins opened this issue Apr 3, 2022 · 3 comments

Comments

@brianberzins
Copy link
Contributor

public static void displayFile(String fileName)
{
String cmd = "";
if (File.separatorChar == '\\')
{
cmd = "cmd /C start \"Needed Title\" \"%s\" /B";
}
else
{
cmd = "open %s";
}
try
{
cmd = String.format(cmd, fileName);
Runtime.getRuntime().exec(cmd);
Thread.sleep(2000);
}
catch (Exception e)
{
throw ObjectUtils.throwAsError(e);
}
}

"open" is macOS specific and won't work out of the box on ubuntu installation.

Honestly don't know how deep you feel this is going, but I'm trying to think of reasonable additions to support Ubuntu. Using file separators won't be sufficient to distinguish between macOS and a linux distro, but I also understand that trying to support a bunch of linux distros might not be easy in this case. xdg-open seems like the most appropriate command if you want to support most linux distros.

@LarsEckart
Copy link
Contributor

I sent you an invite for tomorrow, maybe you can join us? We kinda lack a linux machine to develop on. If not, let me know, maybe I can find someone else.

@brianberzins
Copy link
Contributor Author

brianberzins commented Apr 3, 2022 via email

@brianberzins
Copy link
Contributor Author

Confirmed fixed in 15.1.0

Also showed the customized openers work worked with this:

import com.spun.util.tests.TestUtils;

TestUtils.registerOpener(f -> LinuxOpener.executeOnLinux(f, "firefox"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants