sync-test-binary
Update test binaries (test_stream_generator.rs) to match the latest architecture from main.rs, ensuring they use the same caching, rendering, and pagination patterns. Use when test binaries need to be synchronized with production code.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Sync Test Binary Architecture
Synchronize test binaries with the latest architecture patterns from main.rs.
Step 1: Extract Architecture Patterns from main.rs
Read src/main.rs and identify current patterns:
- Cache creation - Look for DataCache::new() before page loop
-
Cache conditions - Check
page_values.len() > 1logic - PlotRenderer creation - Look for new_with_cache() usage
- Cache cleanup - Find cache.clear() after page loop
Step 2: Identify Test Binary
Find test binary at src/bin/test_stream_generator.rs
Step 3: Compare and Find Gaps
Compare test binary with main.rs patterns:
- Missing DataCache creation?
- Still using PlotRenderer::new() instead of new_with_cache()?
- Missing cache cleanup?
Step 4: Apply Cache Creation Pattern
Location: Before the page loop (after page_values extraction)
Add this code:
// Create shared disk cache for all pages (only if multiple pages)
use ggrs_core::stream::DataCache;
let cache = if page_values.len() > 1 {
let cache = DataCache::new(&workflow_id, &step_id)?;
println!(" Created disk cache at /tmp/ggrs_cache_{}_{}/", workflow_id, step_id);
Some(cache)
} else {
println!(" Single page - cache disabled");
None
};
Step 5: Update PlotRenderer Creation
Location: Where PlotRenderer::new() is called
Replace:
let renderer = PlotRenderer::new(&plot_gen, plot_width as u32, plot_height as u32);
With:
// Create PlotRenderer with cache (if enabled)
let renderer = if let Some(ref cache_ref) = cache {
PlotRenderer::new_with_cache(&plot_gen, plot_width as u32, plot_height as u32, cache_ref.clone())
} else {
PlotRenderer::new(&plot_gen, plot_width as u32, plot_height as u32)
};
Step 6: Add Cache Cleanup
Location: After the page loop ends
Add this code:
// Clean up cache directory after all pages are rendered
if let Some(ref cache_ref) = cache {
println!(" Cleaning up disk cache...");
cache_ref.clear()?;
}
Step 7: Verify Compilation
Build the test binary:
cargo build --bin test_stream_generator
If errors occur, fix:
- Missing imports (add
use ggrs_core::stream::DataCache;) - Variable naming mismatches
- Scope issues with cache variable
Step 8: Report Changes
Provide summary:
- File modified
- Line numbers where patterns were added
- Compilation status
- What to test next
Edge Cases
- If test binary has no pagination, skip cache entirely
- If workflow_id/step_id missing, they're already extracted from environment in test binary
- If cache logic already exists, verify it exactly matches main.rs
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!