TEST: Small IN100 Python example tests fail when run alone, because they use files that other tests make and delete
维护者通常 6 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 1-2 天
- 新手友好度
- 50/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- cmake, python
调研方向
Start with CreatePythonTests and AddPythonTest in cmake/Utility.cmake, and the test list in wrapping/python/examples/pipelines/SourceList.cmake. Reproduce by clearing Bin/Data/Output and running ctest -R on a single PY::OrientationAnalysis test, such as ComputeGBCD-GBPDMetricBased. Done means that test passes alone, and the full serial suite passes twice in a row, using CTest fixtures with setup and cleanup tests.
由索引模型根据 Issue 内容生成。
描述
Summary
The Small IN100 Python example tests (PY::OrientationAnalysis_*) form a chain. Each test reads a .dream3d file that an earlier test wrote. Many tests also delete their input file at the end.
The chain works only when CTest runs the whole list, in order, in one run. CTest does not know about the chain. No test declares a dependency, so CTest cannot run the producer tests first.
So a test fails when you run it alone, re-run it after a failure, or select it with -R. It also fails on the second run of a subset, because the last test of the full chain deletes the shared input.
Checked on develop 10e4a072c and on branch topic/correct_feature_am_updates.
How the chain works
The order exists only as the list order in SourceList.cmake#L59-L82. The comments say "Depends ..." but CMake does not read them.
CreatePythonTests and AddPythonTest in cmake/Utility.cmake#L477-L545 set only the ENVIRONMENT property. No test has FIXTURES_SETUP, FIXTURES_REQUIRED, FIXTURES_CLEANUP or DEPENDS. (git grep FIXTURES_ finds nothing in the repository.)
These tests delete their input with nxtest.cleanup_test_file(...):
| Test | Reads | Deletes |
|---|---|---|
08_Small_IN100_Full_Reconstruction |
Reconstruction/Small_IN100.h5ebsd |
its input |
01_Small_IN100_Morphological_Statistics |
Reconstruction/SmallIN100_Final.dream3d |
its input |
05_Small_IN100_Crystallographic_Statistics |
Statistics/SmallIN100_Morph.dream3d |
its input |
01_Small_IN100_Quick_Mesh |
Statistics/SmallIN100_CrystalStats.dream3d |
its input |
02_Small_IN100_Smooth_Mesh |
SurfaceMesh/SmallIN100_Mesh.dream3d |
its input |
03_Small_IN100_Mesh_Statistics |
SurfaceMesh/SmallIN100_Smoothed.dream3d |
its input |
05_Small_IN100_GBCD_Metric |
SurfaceMesh/SmallIN100_MeshStats.dream3d |
its input and its output |
ComputeGBCD-GBPDMetricBased and 04_Small_IN100_GBCD also read SmallIN100_MeshStats.dream3d. ComputeBiasedFeatures also reads SmallIN100_CrystalStats.dream3d. They delete nothing, so they depend on the order of the deleting tests.
Steps to reproduce
-
Build with Python enabled. Run the full suite serially once. All 17
PY::OrientationAnalysis_*tests pass. -
Run one test again:
ctest -R "^PY::OrientationAnalysis_ComputeGBCD-GBPDMetricBased$" --output-on-failure -
The test fails. The input was deleted at the end of step 1 by
05_Small_IN100_GBCD_Metric.py(line 143):nx::core::ReadDREAM3DFilter :: Errors: [<simplnx.Error(code=-2, message='Path '.../Bin/Data/Output/SurfaceMesh/SmallIN100_MeshStats.dream3d' does not exist')>] -
The same happens for
PY::OrientationAnalysis_01_Small_IN100_Quick_Mesh:nx::core::ReadDREAM3DFilter :: Errors: [<simplnx.Error(code=-2, message='Path '.../Bin/Data/Output/Statistics/SmallIN100_CrystalStats.dream3d' does not exist')>]
Expected behavior
- A test that needs a file from another test gets that file, also when it runs alone or with
-R. ctest --rerun-failedre-runs a failed chain test with the tests it needs.
Actual behavior
- Every chain test except
01_Small_IN100_Archivefails when it runs without the tests before it. - A failure early in the chain makes every later test fail with "does not exist". This hides the first real failure in CI logs.
Suggested fix
Use CTest fixtures. Then CTest adds the required tests by itself when you select one test.
- Extend
CreatePythonTests(orAddPythonTest) with optionalSETUP,REQUIRESandCLEANUParguments. Map them toFIXTURES_SETUP,FIXTURES_REQUIREDandFIXTURES_CLEANUP. - Give each producer test one fixture name for the file it writes. Example:
03_Small_IN100_Mesh_Statisticssets upSmallIN100_MeshStats. - Give each consumer test
FIXTURES_REQUIREDfor the files it reads. Example:ComputeGBCD-GBPDMetricBased,04_Small_IN100_GBCDand05_Small_IN100_GBCD_MetricrequireSmallIN100_MeshStats. - Remove
nxtest.cleanup_test_file(import_data.file_path)from the consumer scripts. A consumer must not delete a file that another consumer may still need. Add one small cleanup test per shared file (a Python orcmake -E rmcommand) withFIXTURES_CLEANUP. CTest runs it after the last test that requires the fixture. - Keep the list order in
SourceList.cmake. Fixtures do not change the order of a full serial run. - Keep
RUN_SERIALbehavior. The project does not run these tests in parallel (noctest -j).
Notes:
- A single test now pulls in its whole chain. For
ComputeGBCD-GBPDMetricBasedthat is 01_Archive, 08, Morphological, Crystallographic, Quick_Mesh, Smooth_Mesh and Mesh_Statistics. This is slower, but the result is correct. - An alternative is to give long chains a published input archive (for example a
SmallIN100_MeshStats.dream3din the Data Archive). Then each consumer reads fixed data and the chain is shorter. - The
PIPELINE::OrientationAnalysis::Small_IN100_Processing-*tests insrc/Plugins/OrientationAnalysis/test/CMakeLists.txt(add_pipeline_testwithINPUT_FILE_LIST/DELETE_FILE_LIST) have the same design. They check that the input exists and give a clear message, but they also have no fixtures. The same fix can apply there.
How to test the fix
- Delete
Bin/Data/Output. Runctest -R "^PY::OrientationAnalysis_ComputeGBCD-GBPDMetricBased$". CTest runs the setup chain first, and the test passes. - Run
ctest -R "^PY::OrientationAnalysis_01_Small_IN100_Quick_Mesh$"on a clean data folder. It passes. - Run the full suite serially twice in a row. Both runs pass.
- After a full run, the shared intermediate files (for example
SmallIN100_MeshStats.dream3d) are deleted by the cleanup tests, as they are today.
Found during review of branch topic/correct_feature_am_updates.
- 主要语言
- C++
- 星标
- 18
- 派生
- 15
- 平均合并
- 4 天 23 小时
- 30 天内合并 PR
- 42
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
BlueQuartzSoftware/simplnx 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
BlueQuartzSoftware/simplnx#1987 ·
维护者通常 6 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 74/100
BlueQuartzSoftware/simplnx#1980 ·
维护者通常 6 天内回复
-
Testing
难度 2/5 1-3 小时 新手友好度 62/100
BlueQuartzSoftware/simplnx#1979 ·
维护者通常 6 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 65/100
BlueQuartzSoftware/simplnx#1978 ·
维护者通常 6 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
BlueQuartzSoftware/simplnx#1945 ·
维护者通常 6 天内回复
查看 BlueQuartzSoftware/simplnx 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
HarperFast/rocksdb-js#1118 ·
维护者通常 1 天内回复
-
bug triage
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
26.04 bug dark-mode Easy Hack impress symptom: visual
难度 2/5 1-3 小时 新手友好度 68/100
CollaboraOnline/online#16421 · 1 条评论 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 63/100
telegramdesktop/tdesktop#31653 ·
维护者通常 1 天内回复
-
area/cs bug
难度 2/5 1-3 小时 新手友好度 82/100
ydb-platform/ydb#59881 · 1 条评论 ·
维护者通常 1 天内回复