fix: enable regression tests in AllTests.wl with proper generation and cleanup - #23
Conversation
…d cleanup AllTests.wl was failing because it loaded compare_golden.wl which auto-ran tests before output files were generated. This fix: - Add output generation loop that invokes Generato for each test case - Fix auto-run detection in compare_golden.wl to only trigger when executed directly (not when loaded via Get[]) - Modify RunGoldenTests[] to return status instead of Exit[] when called from AllTests.wl, enabling cleanup before exit - Add cleanup logic to delete generated output files after comparison
|
Code Review Thanks for this PR! This is a solid improvement to the test infrastructure. STRENGTHS:
CODE QUALITY:
POTENTIAL ISSUES:
PERFORMANCE:
SECURITY:
TEST COVERAGE:
VERDICT: Recommendation: APPROVE with changes requested CHANGES REQUESTED:
OPTIONAL:
|
|
@claude could you implement the required 2 changes |
|
Claude finished @lwJi's task in 1m 34s —— View job Implementation Complete ✓I've successfully implemented the 2 required changes from the code review:
Changes Made1. Input Validation (Shell Injection Prevention)Added
2. Error Handling for DeleteFileWrapped
Testing RecommendationPlease run
|
- Add ValidShellInput function to prevent shell injection attacks - Validate backend and testName before shell execution - Add Check wrapper for DeleteFile with warning message on failure Co-authored-by: Liwei Ji <lwJi@users.noreply.github.com>
Code Review for PR 23Thank you for this improvement to the test infrastructure! This PR successfully enables regression tests within AllTests.wl and adds proper cleanup. Strengths
Potential IssuesCRITICAL: Command Injection VulnerabilityLocation: test/AllTests.wl:33 Problem: While you validate backend and testName, you do not validate TestDir. If TestDir contains special characters, it could lead to command injection. Recommendation: Add validation for TestDir or use RunProcess instead of Run for safer command execution. MEDIUM: Error HandlingLocation: test/AllTests.wl:107-109 The warning message does not indicate what went wrong. Consider checking if file still exists after deletion attempt. LOW: Code DuplicationThe test case loading logic is duplicated between AllTests.wl and compare_golden.wl. Consider extracting this into a shared utility module. Test CoverageThe test plan is excellent with all unit tests and 7 regression tests passing, exit code verification, and cleanup verification. Recommendation: Consider adding a test case that intentionally fails to verify error handling. Code QualityPositive: Consistent formatting, clear variable naming, helpful progress messages, good use of Wolfram Language idioms. Minor: The 2>&1 redirection may not work as expected with Run in Wolfram Language. Consider adding comments explaining the ScriptCommandLine check. Security AssessmentOverall security posture is GOOD with input validation. Main recommendation is to extend validation to TestDir or use RunProcess. RecommendationAPPROVE WITH MINOR FIXES The PR successfully achieves its goals. The only blocking issue is the potential command injection via TestDir. Once addressed, this is ready to merge. Action Items:
|
Summary
wolframscript -f test/AllTests.wlto properly run regression tests by generating output files before comparisoncompare_golden.wlto distinguish standalone execution from being loaded viaGet[]Test plan
wolframscript -f test/AllTests.wl- all unit tests and 7/7 regression tests pass.hxxor.cfiles remain in test directories after completionwolframscript -f test/regression/compare_golden.wlstill worksGet["test/regression/compare_golden.wl"]in REPL loads without auto-running