TEST: Small IN100 Python example tests fail when run alone, because they use files that other tests make and delete

Đang mở
#1,909 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 6 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
50/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cmake, python
Lĩnh vực
build-system, testing-qa

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

  1. Build with Python enabled. Run the full suite serially once. All 17 PY::OrientationAnalysis_* tests pass.

  2. Run one test again:

    ctest -R "^PY::OrientationAnalysis_ComputeGBCD-GBPDMetricBased$" --output-on-failure
    
  3. 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')>]
    
  4. 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-failed re-runs a failed chain test with the tests it needs.

Actual behavior

  • Every chain test except 01_Small_IN100_Archive fails 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.

  1. Extend CreatePythonTests (or AddPythonTest) with optional SETUP, REQUIRES and CLEANUP arguments. Map them to FIXTURES_SETUP, FIXTURES_REQUIRED and FIXTURES_CLEANUP.
  2. Give each producer test one fixture name for the file it writes. Example: 03_Small_IN100_Mesh_Statistics sets up SmallIN100_MeshStats.
  3. Give each consumer test FIXTURES_REQUIRED for the files it reads. Example: ComputeGBCD-GBPDMetricBased, 04_Small_IN100_GBCD and 05_Small_IN100_GBCD_Metric require SmallIN100_MeshStats.
  4. 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 or cmake -E rm command) with FIXTURES_CLEANUP. CTest runs it after the last test that requires the fixture.
  5. Keep the list order in SourceList.cmake. Fixtures do not change the order of a full serial run.
  6. Keep RUN_SERIAL behavior. The project does not run these tests in parallel (no ctest -j).

Notes:

  • A single test now pulls in its whole chain. For ComputeGBCD-GBPDMetricBased that 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.dream3d in the Data Archive). Then each consumer reads fixed data and the chain is shorter.
  • The PIPELINE::OrientationAnalysis::Small_IN100_Processing-* tests in src/Plugins/OrientationAnalysis/test/CMakeLists.txt (add_pipeline_test with INPUT_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. Run ctest -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.

Ngôn ngữ chính
C++
Star
18
Fork
15
Merge trung bình
4 ngày 23 giờ
Pull request đã merge (30 ngày)
42

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của BlueQuartzSoftware/simplnx

Tất cả issue của BlueQuartzSoftware/simplnx

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.