goose icon indicating copy to clipboard operation
goose copied to clipboard

Fix scenario filtering to use exact matching without wildcards

Open jeremyandrews opened this issue 4 months ago • 3 comments

PR Description: Fix scenario filtering substring matching bug

Problem

Issue #612: When filtering scenarios, --scenarios put1024bytes incorrectly matched both put1024bytes and getput1024bytes due to substring matching instead of exact matching.

Root Cause

scenario_is_active() method used scenario_name.contains(&scenario), causing substring matches.

Solution

Replace substring matching with exact matching for non-wildcard patterns:

  • No wildcard: Exact string comparison only
  • With * wildcard: Pattern matching (maintains backward compatibility)

Technical Changes

  • src/lib.rs: Replace contains() with wildcard_match() helper
  • src/config.rs: Allow * characters in scenario validation
  • tests/scenarios.rs: Add comprehensive test coverage (14 new tests)
  • Documentation: Update scenario filtering behavior description

Behavior Change

Before: --scenarios put1024bytes matches put1024bytes, getput1024bytes, preput1024bytes After: --scenarios put1024bytes matches only put1024bytes

Backward Compatibility: --scenarios * continues to match all scenarios

Test Coverage

  • Exact matching without wildcards
  • Wildcard patterns: *suffix, prefix*, prefix*suffix
  • Multiple wildcards: *prefix*middle*suffix*
  • Edge cases and complex patterns

Fixes #612

jeremyandrews avatar Sep 09 '25 10:09 jeremyandrews

Consider Third-Party Crate

The custom wildcard_match implementation works well and is thoroughly tested, but consider using a specialized crate like wildmatch or glob instead. This would:

  • Reduce maintenance overhead
  • Leverage battle-tested implementations
  • Handle edge cases more robustly

(Powered by Claude Code)

LionsAd avatar Sep 10 '25 14:09 LionsAd

Test Suite Optimization

Excellent test coverage! Consider refactoring the test suite to use parameterized tests or helper functions to reduce code duplication:

#[test] 
fn test_wildcard_patterns() {
    let test_cases = vec![
        ("*", vec!["scenarioa1", "scenariob1"]),
        ("*a1", vec!["scenarioa1"]),
        // ... more cases
    ];
    
    for (pattern, expected) in test_cases {
        // test logic
    }
}

(Powered by Claude Code)

LionsAd avatar Sep 10 '25 14:09 LionsAd

Completed wildcard test deduplication and enhanced functionality. Replaced custom wildcard implementation with wildcard crate, added support for ? and [abc] patterns, eliminated 500+ lines of test boilerplate through helper functions, and updated documentation. All 19 tests pass with comprehensive coverage maintained.

jeremyandrews avatar Sep 14 '25 13:09 jeremyandrews