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

オープン
#1,909 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 6 日以内に返信

まだ誰も着手していません。

評価

難易度
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

  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.

主要言語
C++
スター
18
フォーク
15
平均マージ
4日 23時間
マージ済み PR(30日)
42

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

BlueQuartzSoftware/simplnx のほかの issue

BlueQuartzSoftware/simplnx の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。