A robust Python utility designed to clean VectorCAST C test files by removing import failure blocks while preserving file structure and integrity. This tool is essential for VectorCAST test environment maintenance and automated test processing workflows.
- Smart Content Removal: Precisely removes
TEST.IMPORT_FAILURES:toTEST.END_IMPORT_FAILURES:blocks - File Integrity: Preserves original file structure and formatting
- Backup Protection: Automatic backup creation before file modification
- Batch Processing: Support for cleaning multiple files simultaneously
- Error Handling: Comprehensive error handling with detailed logging
- CLI Interface: Both interactive and command-line modes
- Unicode Support: Handles various text encodings gracefully
- Python 3.7 or higher
- Standard Python libraries (no additional dependencies required)
# Clone the repository
git clone https://github.com/yourusername/vectorcast-content-cleaner.git
cd vectorcast-content-cleaner
# Make the script executable (optional)
chmod +x content_cleaner.pypython content_cleaner.py# Clean a single file
python content_cleaner.py test_file.c
# Clean multiple files
python content_cleaner.py file1.c file2.c file3.c
# Clean without creating backups
python content_cleaner.py test_file.c --no-backup
# Enable verbose logging
python content_cleaner.py test_file.c --verbosepositional arguments:
files File(s) to clean. If not provided, will prompt for input
optional arguments:
-h, --help Show help message and exit
--no-backup Don't create backup files
--verbose, -v Enable verbose logging
--version Show program's version number and exit
The cleaner uses advanced regular expressions to identify and remove content blocks that match the VectorCAST import failure pattern:
// This content will be removed:
TEST.IMPORT_FAILURES:
Any content here including
multiple lines and special characters
TEST.END_IMPORT_FAILURES:- Pattern Recognition: Uses regex with multiline and dotall flags for accurate matching
- Content Preservation: Maintains surrounding code structure and whitespace
- Cleanup Process: Removes excessive whitespace that might result from block removal
- Validation: Checks file permissions and encoding before processing
VectorCAST is a comprehensive C/C++ software testing platform used for:
- Unit Testing: Automated test case generation and execution
- Integration Testing: Component-level testing with coverage analysis
- Certification: DO-178B/C, ISO 26262, and other safety-critical standards compliance
During VectorCAST test execution, import failure blocks are automatically generated when:
- Header files cannot be properly parsed
- Dependencies are missing or misconfigured
- Compilation issues occur during test environment setup
These blocks accumulate in test files and can cause:
- Test Environment Corruption: Preventing proper test regeneration
- Build Failures: Interfering with subsequent test compilation
- Maintenance Issues: Making test files difficult to manage and version control
- CI/CD Pipeline Breaks: Causing automated testing workflows to fail
| Challenge | Impact | Solution with This Tool |
|---|---|---|
| Manual Cleanup | Hours of manual editing | Automated Processing |
| Error-Prone Process | Risk of removing critical code | Precise Pattern Matching |
| Team Productivity | Delayed test cycles | Batch Processing Capability |
| Quality Assurance | Inconsistent test environments | Reliable, Repeatable Cleaning |
- Test Environment Reset: Clean corrupted test files before regeneration
- CI/CD Integration: Automated cleanup in build pipelines
- Migration Projects: Prepare test files when moving between VectorCAST versions
- Maintenance Scripts: Regular cleanup of test repositories
- Development Workflows: Quick cleanup during active test development
- Fast Processing: Optimized regex patterns for quick file processing
- Memory Efficient: Processes files without loading entire content into memory unnecessarily
- Error Recovery: Graceful handling of encoding issues and file permission problems
- Backup Safety: Automatic backup creation prevents data loss
The project includes comprehensive test coverage:
# Run tests
python -m pytest tests/
# Run with coverage
python -m pytest tests/ --cov=content_cleaner --cov-report=htmlvectorcast-content-cleaner/
β
βββ content_cleaner.py # Main application
βββ tests/ # Test suite
β βββ __init__.py
β βββ test_content_cleaner.py
β βββ test_data/ # Test files
βββ .github/
β βββ workflows/
β βββ python-package.yml # CI/CD pipeline
βββ .gitignore # Git ignore rules
βββ LICENSE # CC0 License
βββ README.md # This file
βββ requirements-dev.txt # Development dependencies
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
# Install development dependencies
pip install -r requirements-dev.txt
# Run linting
flake8 content_cleaner.py
# Run tests
pytestThis project follows PEP 8 guidelines and uses flake8 for linting.
This project demonstrates several key technical competencies:
- Python Development: Advanced string processing, regex, and file handling
- Software Testing: Experience with VectorCAST and test automation
- DevOps Integration: CI/CD pipeline setup and automated testing
- Error Handling: Robust error management and logging practices
- Documentation: Professional-grade documentation and code comments
- Automotive: Safety-critical software testing (ISO 26262)
- Aerospace: DO-178B/C compliance testing
- Medical Devices: IEC 62304 software lifecycle processes
- Industrial Control: Functional safety testing and validation
This project is released into the public domain under the CC0 1.0 Universal license. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
If you encounter any issues or have questions:
- Check the Issues section
- Create a new issue with detailed description
- For urgent matters, contact: [[email protected]]
β If this tool helped you, please consider giving it a star!
Built with β€οΈ for the VectorCAST testing community