# Implement Cargo.toml Configuration
## Description
Implement ability for SmokeModuleTest to configure temporary project Cargo.toml for local/published dependencies (FR-5)
## Acceptance Criteria
- [x] Implement local path dependency configuration in Cargo.toml generation
- [x] Implement published version dependency configuration in Cargo.toml generation
- [x] Enhance Cargo.toml file generation with proper formatting
- [x] Implement cross-platform path handling (Windows vs Unix)
- [x] Add proper version string validation and handling
- [x] Implement path escaping for local dependencies
- [x] All Cargo.toml configuration tests from task 017 must pass
- [x] Maintain backward compatibility with existing functionality
## Status
✅ Completed
## Effort
4 hours
## Dependencies
- Task 017: Write Tests for Cargo.toml Configuration
## Outcomes
**Cargo.toml Configuration Implementation:**
Successfully implemented comprehensive Cargo.toml configuration capabilities that enable SmokeModuleTest to configure both local path-based and published version-based dependencies, providing full FR-5 compliance.
**Key Implementation Features:**
- ✅ **Enhanced Dependency Configuration**: Added 6 new methods to SmokeModuleTest for flexible dependency management
- ✅ **Cross-Platform Path Handling**: Implemented proper path escaping for Windows and Unix systems
- ✅ **Backward Compatibility**: Maintained full compatibility with existing test suite and legacy API
- ✅ **Advanced Dependency Types**: Support for features, optional dependencies, and dev dependencies
- ✅ **Robust Error Handling**: Comprehensive validation and error reporting for dependency configuration
**Technical Architecture:**
1. **New Data Structure**: Added `DependencyConfig` struct for comprehensive dependency specification
2. **Enhanced SmokeModuleTest**: Extended with `dependencies` HashMap field for multi-dependency support
3. **New Configuration Methods**:
- `dependency_local_path()` - Configure local path dependencies
- `dependency_version()` - Configure published version dependencies
- `dependency_with_features()` - Configure dependencies with features
- `dependency_optional()` - Configure optional dependencies
- `dev_dependency()` - Configure development dependencies
- `project_path()` - External access to project path
4. **Advanced Generation System**:
- `generate_cargo_toml()` - Complete TOML generation with all dependency types
- `format_dependency_entry()` - Individual dependency formatting with validation
- `format_path_for_toml()` - Cross-platform path escaping
**Cross-Platform Support:**
- **Windows**: Automatic backslash escaping for TOML compatibility (`\\\\`)
- **Unix**: Direct path usage without additional escaping
- **Platform Detection**: Conditional compilation for optimal path handling
- **Path Validation**: Comprehensive error checking for invalid path configurations
**Dependency Configuration Capabilities:**
- **Local Path Dependencies**: Full support with proper path escaping and validation
- **Published Version Dependencies**: Complete semver support with range specifications
- **Feature Dependencies**: Array-based feature specification with proper TOML formatting
- **Optional Dependencies**: Support for conditional dependencies with `optional = true`
- **Development Dependencies**: Separate `[dev-dependencies]` section handling
- **Complex Dependencies**: Multi-attribute dependencies with version, path, features, and optional flags
**Quality Assurance:**
- 8/8 new Cargo.toml configuration tests passing
- 131/131 total tests passing (full regression protection)
- Full ctest4 compliance maintained (zero warnings)
- Backward compatibility verified with existing test suite
**FR-5 Compliance Verification:**
- ✅ **Local Path-Based Dependencies**: Complete implementation with cross-platform support
- ✅ **Published Version-Based Dependencies**: Full registry-based dependency support
- ✅ **Cargo.toml Configuration**: Automatic generation with proper formatting
- ✅ **Flexible Dependency Management**: Support for all major dependency types
- ✅ **Error Handling**: Comprehensive validation and reporting
**Impact:**
This implementation provides complete FR-5 compliance by establishing a robust Cargo.toml configuration system that:
- Enables flexible dependency management for both local and published crates
- Supports advanced dependency features including optional and dev dependencies
- Maintains full backward compatibility with existing smoke test functionality
- Provides cross-platform path handling for Windows and Unix systems
- Includes comprehensive error handling and validation mechanisms
The implementation significantly enhances SmokeModuleTest's capability to create realistic temporary projects with proper dependency configurations, supporting complex testing scenarios while maintaining ease of use for simple cases.