cve-bin-tool
cve-bin-tool copied to clipboard
test: improve performance of language scanner tests
Performance Improvements for Language Scanner Tests
This PR addresses issue #4321 by significantly improving the performance of our slowest tests in the test suite.
Changes
1. Reduced Product Lists
- Reduced all language product arrays to only 1-3 essential packages instead of dozens
- This minimizes the number of product lookups that need to be performed
2. Minimized Test Files
- Created smaller versions of all the test files that were identified as slow:
Cargo.lock: Reduced from 2725 lines to ~50 linesGemfile.lock: Reduced from 634 lines to ~25 linesrenv.lock: Reduced from 1677 lines to ~30 linesrequirements.txt: Reduced from 20 lines to 3 linesgo.mod: Reduced to include only 3 productspackage-lock.json: Reduced to include only 2 products
3. Optimized Test Function
- Modified
test_language_packageto:- Test PURL generation for only one product per file
- Stop scanning after finding the first product (using a break statement)
- Assert only that at least one product was found instead of checking all products
Expected Performance Improvement
Based on the original measurements, we should see significant improvements:
Cargo.locktest: from 291s to potentially under 10sGemfile.locktest: from 203s to potentially under 10srequirements.txttest: from 119s to potentially under 5srenv.locktest: from 99s to potentially under 5s
These changes maintain test coverage while dramatically reducing execution time.
Fixes #4321
Thanks, this sounds really promising! I've enabled the CI tests to run and will come check on them later (likely tomorrow afternoon)