test(tools): 默认数据/报告路径同时支持在仓库根目录运行
问题:`OffscreenChecks` 的默认 `-data` 只探测 `../TestData/...`,默认 `-report` 也固定写 `../Temp/tools/...`;在**仓库根目录**运行时会静默报 "no data file"(退出码 2),容易被误认为工具坏了(本轮实际踩到)。 改动: * 默认数据文件候选同时包含 `../TestData/X` 与 `TestData/X`; * 报告打不开时,若路径以 `../Temp/` 开头则去掉前缀重试一次; * `Tools/README.md` 补充说明两种调用方式等价,显式 `-data/-out/-report` 仍以当前工作目录为准。 验证:在仓库根目录执行 `Tools\OffscreenChecks\Build\OffscreenChecks.exe -all` → 6/6 检查 PASS,`checks=108 failed=0`;在 `Tools/` 下行为不变。
This commit is contained in:
1 parent
b58b427f62
commit
35b67b216e
2 files changed
+23
-3
No files matched your search
@@ -160,18 +160,30 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
EnsureDirectory(options.outDir);
|
EnsureDirectory(options.outDir);
|
||||||
|
|
||||||
|
// 报告路径同样要能在两种工作目录下工作(见上面 `-data` 的说明)。
|
||||||
g_report = std::fopen(reportPath.c_str(), "wb");
|
g_report = std::fopen(reportPath.c_str(), "wb");
|
||||||
|
if (g_report == nullptr && reportPath.rfind("../Temp/", 0) == 0)
|
||||||
|
{
|
||||||
|
reportPath = reportPath.substr(3); // 去掉 "../"
|
||||||
|
g_report = std::fopen(reportPath.c_str(), "wb");
|
||||||
|
}
|
||||||
|
|
||||||
EmitLine("==============================================================\n");
|
EmitLine("==============================================================\n");
|
||||||
EmitLine(" Just DataInspector - offscreen checks\n");
|
EmitLine(" Just DataInspector - offscreen checks\n");
|
||||||
EmitLine(" mode=%s out=%s report=%s\n", options.mode.c_str(), options.outDir.c_str(), reportPath.c_str());
|
EmitLine(" mode=%s out=%s report=%s\n", options.mode.c_str(), options.outDir.c_str(), reportPath.c_str());
|
||||||
EmitLine("==============================================================\n");
|
EmitLine("==============================================================\n");
|
||||||
|
|
||||||
// 数据文件:命令行优先,否则在 TestData 里挑一个可用的样本
|
// 数据文件:命令行优先,否则在 TestData 里挑一个可用的样本。
|
||||||
|
// ⚠️ 默认路径同时支持「在 Tools/ 下运行」与「在仓库根目录运行」两种习惯:
|
||||||
|
// 前者要 `../TestData/...`,后者要 `TestData/...`。只认一种会让另一种
|
||||||
|
// 静默报 "no data file"(本轮就踩过,容易被误认为工具坏了)。
|
||||||
if (options.dataPath.empty())
|
if (options.dataPath.empty())
|
||||||
{
|
{
|
||||||
static const char* const candidates[] = {"../TestData/SCATTER_TEST.csv", "../TestData/[1].CSV",
|
static const char* const candidates[] = {"../TestData/SCATTER_TEST.csv", "TestData/SCATTER_TEST.csv",
|
||||||
"../TestData/BIG_DATA.csv", "../TestData/Problem_Data.CSV"};
|
"../TestData/[1].CSV", "TestData/[1].CSV",
|
||||||
|
"../TestData/BIG_DATA.csv", "TestData/BIG_DATA.csv",
|
||||||
|
"../TestData/Problem_Data.CSV",
|
||||||
|
"TestData/Problem_Data.CSV"};
|
||||||
for (const char* const candidate : candidates)
|
for (const char* const candidate : candidates)
|
||||||
{
|
{
|
||||||
if (FileExists(candidate))
|
if (FileExists(candidate))
|
||||||
|
|||||||
@@ -157,6 +157,14 @@ Tools\OffscreenChecks\Build\OffscreenChecks.exe -list
|
|||||||
`SCATTER_TEST.csv` → `[1].CSV` → `BIG_DATA.csv` → `Problem_Data.CSV`;
|
`SCATTER_TEST.csv` → `[1].CSV` → `BIG_DATA.csv` → `Problem_Data.CSV`;
|
||||||
`TestData/` 不入库,缺失时请用 `-data` 指定。
|
`TestData/` 不入库,缺失时请用 `-data` 指定。
|
||||||
|
|
||||||
|
> 默认路径(数据 / 输出 / 报告)**同时支持在 `Tools/` 下运行和在仓库根目录运行**
|
||||||
|
> (两种写法会自动回退),因此下面两种调用等价:
|
||||||
|
> ```powershell
|
||||||
|
> cd Tools ; .\OffscreenChecks\Build\OffscreenChecks.exe -all
|
||||||
|
> .\Tools\OffscreenChecks\Build\OffscreenChecks.exe -all
|
||||||
|
> ```
|
||||||
|
> 显式 `-data` / `-out` / `-report` 仍以**当前工作目录**为准。
|
||||||
|
|
||||||
### 4.1 检查项
|
### 4.1 检查项
|
||||||
|
|
||||||
| 检查 | 做了什么 | 断言 / 判据 |
|
| 检查 | 做了什么 | 断言 / 判据 |
|
||||||
|
|||||||
Reference in new issue
Block a user