Issue
I have Eclipse installed as a Flatpak via Flathub. When I try to run a JUnit 4 suite defined to run all tests within a project, it fails with this exception:
java.lang.IllegalArgumentException: Cannot read testname file.
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:266)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:225)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
I looked into the source for RemoteTestRunner
and found that it is trying to read a file whose path was provided to the runner:
else if("-testnamefile".equals(args[i].toLowerCase())) { //$NON-NLS-1$
String testNameFile= args[i+1];
try {
readTestNames(testNameFile);
} catch (IOException e) {
throw new IllegalArgumentException("Cannot read testname file."); //$NON-NLS-1$
}
i++;
}
So I examined the command line for the test execution and did find that argument:
-testNameFile /tmp/testNames8297875472451881369.txt
The exception message isn't lying - that file does not exist. The name of the file changes each time it is run, but the file is never created.
I verified from a terminal inside Eclipse and from the Flatpak container via flatpak run --command=sh org.eclipse.Java
that I can create, modify, and delete files at /tmp
.
This is where I'm stuck. I'm not sure what is supposed to create this temporary file with the test names in it or why it is failing to do so. I see no evidence in Eclipse logs of a failure to write this file. Permissions don't seem to be an issue.
One last observation I did make is that when I open a terminal inside Eclipse and run ls -al /tmp
I see all the files from my host machine's /tmp
directory. I thought Flatpak specifically blocked /tmp
even when file permissions are set to host. However, when I run the sandbox from a terminal (using flatpak run
), I see a sandbox version of /tmp
that does not match the host. In either case, I can read, write, and modify files in /tmp
.
Solution
Turns out this was a bug in the Flatpak permissions and not a configuration issue. This was resolved by the team maintaining the Eclipse Flatpak quickly.
For those that are interested, the Flatpak needed to request read/write access to /tmp
.
Here is the issue: https://github.com/flathub/org.eclipse.Java/issues/42
Here is the pull request that fixed it: https://github.com/flathub/org.eclipse.Java/pull/43
Answered By - Greg