fix: improve FlatVariant bridge method and add consolidated roundtrip tests
🔧 Fixes: - Fix FlatVariant bridge method to properly create temp files for implode operations - Resolve placeholder content issue in roundtrip tests - Exclude manifest.md from processed files list 🧪 Testing: - Add comprehensive consolidated roundtrip test suite - Test all variants with CLI integration - Include error handling and edge case testing 📊 Status: - Legacy roundtrip tests: 10/11 passing (1 architectural difference) - Variant system core functionality: Working - CLI integration: Minor issues to resolve Files Added: - tests/test_roundtrip_consolidated.py Files Modified: - markitect/explode_variants/flat_variant.py 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -300,29 +300,42 @@ class FlatVariant(BaseVariant):
|
||||
try:
|
||||
from markitect.plugins.builtin.markdown_commands import cli_implode_directory
|
||||
|
||||
# Use existing implode logic
|
||||
# Create a temporary file for the existing implode logic
|
||||
import tempfile
|
||||
with tempfile.NamedTemporaryFile(mode='w+', suffix='.md', delete=False) as temp_file:
|
||||
temp_path = Path(temp_file.name)
|
||||
|
||||
# Use existing implode logic with actual file creation
|
||||
result = cli_implode_directory(
|
||||
input_dir=input_directory,
|
||||
output_file=options.output_file or Path("/tmp/temp.md"),
|
||||
dry_run=True, # We handle file writing ourselves
|
||||
output_file=temp_path,
|
||||
dry_run=False, # Actually create the file so we can read it
|
||||
verbose=options.verbose,
|
||||
overwrite=options.overwrite,
|
||||
overwrite=True, # Always overwrite temp file
|
||||
preserve_front_matter=options.preserve_front_matter,
|
||||
section_spacing=options.section_spacing
|
||||
)
|
||||
|
||||
if result.success:
|
||||
# Read the content that would have been written
|
||||
temp_file = options.output_file or Path("/tmp/temp.md")
|
||||
if temp_file.exists():
|
||||
content = temp_file.read_text(encoding='utf-8')
|
||||
else:
|
||||
content = "# Imploded Content\n\n(Content generation in progress...)"
|
||||
if result.success and temp_path.exists():
|
||||
# Read the generated content
|
||||
content = temp_path.read_text(encoding='utf-8')
|
||||
# Exclude manifest from processed files
|
||||
files_processed = [f for f in input_directory.glob("**/*.md") if f.name != "manifest.md"]
|
||||
|
||||
# Clean up temp file
|
||||
try:
|
||||
temp_path.unlink()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
files_processed = list(input_directory.glob("**/*.md"))
|
||||
return content, files_processed
|
||||
else:
|
||||
raise Exception(result.error_message or "Implosion failed")
|
||||
# Clean up temp file
|
||||
try:
|
||||
temp_path.unlink()
|
||||
except Exception:
|
||||
pass
|
||||
raise Exception(result.error_message if hasattr(result, 'error_message') else "Implosion failed")
|
||||
|
||||
except ImportError:
|
||||
# Fallback basic implementation for testing
|
||||
|
||||
Reference in New Issue
Block a user