【发布时间】:2021-09-10 04:58:30
【问题描述】:
我通过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 run --command=sh org.eclipse.Java 从 Flatpak 容器验证我可以在 /tmp 创建、修改和删除文件。
这就是我卡住的地方。我不确定应该用什么来创建这个带有测试名称的临时文件,或者为什么它没有这样做。我在 Eclipse 日志中没有看到无法写入此文件的证据。权限似乎不是问题。
我所做的最后一个观察是,当我在 Eclipse 中打开终端并运行 ls -al /tmp 时,我会看到主机的 /tmp 目录中的所有文件。我以为 Flatpak 专门阻止了 /tmp even when file permissions are set to host。但是,当我从终端(使用flatpak run)运行沙箱时,我看到/tmp 的沙箱版本与主机不匹配。无论哪种情况,我都可以读取、写入和修改/tmp 中的文件。
【问题讨论】:
-
我在Eclipse Flatpak GitHub project 上发布了这个,因为我现在认为这可能是一个错误而不是配置问题。