Skip to content

fix file overwrite - #8210

Merged
timosachsenberg merged 1 commit into
developfrom
fix_test
Sep 15, 2025
Merged

timosachsenberg merged 1 commit into
developfrom
fix_test

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Sep 15, 2025 •

Copy link
Copy Markdown
Contributor

Description

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

Advanced commands (admins / reviewer only)

Click to expand
  • /reformat (experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Summary by CodeRabbit

  • Tests
    • Improved test reliability by using temporary files for reading and writing, ensuring isolation and automatic cleanup.
    • Added a fallback to reuse existing input when secondary test data is unavailable, reducing flakiness across environments.
    • Enhanced file existence checks to prevent failures due to missing test assets.
    • No impact on runtime behavior or public APIs.

@coderabbitai

coderabbitai Bot commented Sep 15, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Switches the Deisotoper test to use temporary files for writing outputs, adds a conditional fallback when a second input file is missing, and includes file utilities. Temporary files are created via File::getTempDirectory/getUniqueName, used for store/load, and then deleted. No algorithmic or public API changes.

Changes

Cohort / File(s) Summary of Changes
Test temp I/O and fallback handling
src/tests/class_tests/openms/source/Deisotoper_test.cpp
Included OpenMS/SYSTEM/File.h. Replaced fixed output paths with unique temp files (create, store, remove). Added existence check for Deisotoper_input2.mzML with fallback to Deisotoper_input1.mzML. Applied same temp-file approach for second output. No core algorithm changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Test as Deisotoper_test
  participant File as File utils
  participant IO as mzML I/O

  Test->>File: getTempDirectory()
  Test->>File: getUniqueName()
  File-->>Test: temp_path_1
  Test->>IO: store(MSSpectrum, temp_path_1)
  Note over Test,IO: Output 1 written to ephemeral file
  Test->>File: exists(Deisotoper_input2.mzML)?
  alt input2 exists
    Test->>IO: load(Deisotoper_input2.mzML)
  else fallback
    Test->>IO: load(Deisotoper_input1.mzML)
  end
  Test->>File: getUniqueName()
  File-->>Test: temp_path_2
  Test->>IO: store(MSSpectrum, temp_path_2)
  Note over Test,File: Cleanup temporary files
  Test->>File: remove(temp_path_1)
  Test->>File: remove(temp_path_2)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hop through temps with tidy cheer,
Write, read, then poof—no traces here.
If input two has gone astray,
I borrow one to save the day.
Ears up high, tests squeak “alright!”
Swift files vanish into night. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "fix file overwrite" concisely and accurately reflects the primary change in the diff, which modifies Deisotoper_test.cpp to use ephemeral temporary files and fallbacks instead of writing to fixed test-data paths to avoid overwriting files. It clearly communicates the main intent (preventing file overwrite) and is brief enough for quick scanning. While it does not name the specific test, it still conveys the essential purpose of the changes.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_test

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/tests/class_tests/openms/source/Deisotoper_test.cpp (3)

149-151: Use test harness temp-file helper (NEW_TMP_FILE) instead of manual path concat.
Improves portability (no manual "/") and guarantees cleanup even on exceptions.

-  String temp_file1 = File::getTempDirectory() + "/" + File::getUniqueName() + "_Deisotoper_output1.mzML";
-  MzMLFile().store(temp_file1, input1);
-  File::remove(temp_file1);
+  NEW_TMP_FILE(tmp_out1);
+  MzMLFile().store(tmp_out1, input1);

155-164: Avoid silent fallback; make intent explicit and keep path const.
Fallback may mask missing test data and reduce coverage; at least log it. Also prefer const for the path.

-  String input2_path = OPENMS_GET_TEST_DATA_PATH("Deisotoper_input2.mzML");
+  const String input2_path = OPENMS_GET_TEST_DATA_PATH("Deisotoper_input2.mzML");
   if (File::exists(input2_path))
   {
     MzMLFile().load(input2_path, input2);
   }
   else
   {
+    std::cerr << "Warning: Deisotoper_input2.mzML not found; falling back to Deisotoper_input1.mzML. Test coverage may be reduced.\n";
     // Fallback: reuse input1 dataset if the second input is not available
     MzMLFile().load(OPENMS_GET_TEST_DATA_PATH("Deisotoper_input1.mzML"), input2);
   }

Please confirm that reusing input1 here is acceptable for the intended assertions (none currently depend on input2 differing).


179-181: Same as above: prefer NEW_TMP_FILE for output2.
Removes manual separator handling and explicit cleanup.

-  String temp_file2 = File::getTempDirectory() + "/" + File::getUniqueName() + "_Deisotoper_output2.mzML";
-  MzMLFile().store(temp_file2, input2);
-  File::remove(temp_file2);
+  NEW_TMP_FILE(tmp_out2);
+  MzMLFile().store(tmp_out2, input2);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a08706 and 15085f0.

📒 Files selected for processing (1)
  • src/tests/class_tests/openms/source/Deisotoper_test.cpp (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/tests/class_tests/openms/**/*.cpp

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Write unit tests for new functionality

Files:

  • src/tests/class_tests/openms/source/Deisotoper_test.cpp
🧠 Learnings (4)
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/**/*.cpp : Write unit tests for new functionality

Applied to files:

  • src/tests/class_tests/openms/source/Deisotoper_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/tests/class_tests/openms/*Test.cpp : Follow naming convention: `ClassNameTest.cpp` for `ClassName`

Applied to files:

  • src/tests/class_tests/openms/source/Deisotoper_test.cpp
📚 Learning: 2025-08-05T12:43:11.681Z
Learnt from: CR
PR: OpenMS/OpenMS#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)

Applied to files:

  • src/tests/class_tests/openms/source/Deisotoper_test.cpp
📚 Learning: 2025-09-03T12:58:20.032Z
Learnt from: timosachsenberg
PR: OpenMS/OpenMS#8177
File: src/tests/topp/CMakeLists.txt:1857-1865
Timestamp: 2025-09-03T12:58:20.032Z
Learning: OpenMS tests: When adding new TOPP tests in src/tests/topp/CMakeLists.txt that compare outputs via FuzzyDiff, always add set_tests_properties("<tool>_<n>_out<m>" PROPERTIES DEPENDS "<tool>_<n>") to avoid flakiness under parallel CTest runs.

Applied to files:

  • src/tests/class_tests/openms/source/Deisotoper_test.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build-and-test (macos-13, xcode, 14.2)
  • GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
  • GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
  • GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
  • GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
  • GitHub Check: cppcheck-test
🔇 Additional comments (1)
src/tests/class_tests/openms/source/Deisotoper_test.cpp (1)

22-22: Include for File utilities — LGTM.
Required for File::exists/getTempDirectory/getUniqueName/remove.

@timosachsenberg
timosachsenberg merged commit b8795a1 into develop Sep 15, 2025
@timosachsenberg
timosachsenberg deleted the fix_test branch September 15, 2025 11:06
@coderabbitai coderabbitai Bot mentioned this pull request Dec 23, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant