我通过Flathub将 Eclipse 安装为 Flatpak 。当我尝试运行定义为在项目中运行所有测试的 JUnit 4 套件时,它会失败并出现以下异常:
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)
我查看了源代码RemoteTestRunner
,发现它正在尝试读取一个文件,其路径已提供给运行器:
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++;
}
因此,我检查了测试执行的命令行并确实找到了该参数:
-testNameFile /tmp/testNames8297875472451881369.txt
异常消息没有说谎 - 该文件不存在。文件的名称在每次运行时都会更改,但永远不会创建该文件。
我从 Eclipse 内部的终端和 Flatpak 容器验证了flatpak run --command=sh org.eclipse.Java
我可以在/tmp
.
这就是我卡住的地方。我不确定应该用什么来创建这个带有测试名称的临时文件,或者为什么它没有这样做。我在 Eclipse 日志中没有看到无法写入此文件的证据。权限似乎不是问题。
我所做的最后一个观察是,当我在 Eclipse 中打开终端并运行时,ls -al /tmp
我会看到主机/tmp
目录中的所有文件。我认为/tmp
即使文件权限设置为 host , Flatpak 也会特别阻止。但是,当我从终端(使用flatpak run
)运行沙箱时,我看到沙箱版本/tmp
与主机不匹配。无论哪种情况,我都可以读取、写入和修改/tmp
.