Repository navigation
fix file overwrite - #8210
fix file overwrite#8210
Conversation
WalkthroughSwitches 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
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)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
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.
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. Comment |
There was a problem hiding this comment.
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
📒 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.
Description
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
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.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit