fix: Add GDScript regex patterns for test example extraction
PROBLEM:
- Test files discovered but extraction failed
- WARNING: Language GDScript not supported for regex extraction
- PATTERNS dictionary missing GDScript entry
SOLUTION:
Added GDScript patterns to PATTERNS dictionary:
1. test_function pattern:
- Matches GUT: func test_something()
- Matches gdUnit4: @test\nfunc test_something()
- Pattern: r"(?:@test\s+)?func\s+(test_\w+)\s*\("
2. instantiation pattern:
- var obj = Class.new()
- var obj = preload("res://path").new()
- var obj = load("res://path").new()
- Pattern: r"(?:var|const)\s+(\w+)\s*=\s*(?:(\w+)\.new\(|(?:preload|load)\([\"']([^\"']+)[\"']\)\.new\()"
3. assertion pattern:
- GUT assertions: assert_eq, assert_true, assert_false, etc.
- gdUnit4 assertions: assert_that, assert_str, etc.
- Pattern: r"assert_(?:eq|ne|true|false|null|not_null|gt|lt|between|has|contains|typeof)\(([^)]+)\)"
4. signal pattern (bonus):
- Signal connections: signal_name.connect()
- Signal emissions: emit_signal("signal_name")
- Pattern: r"(?:(\w+)\.connect\(|emit_signal\([\"'](\w+)[\"'])"
IMPACT:
- ✅ GDScript test files now extract examples
- ✅ Supports GUT, gdUnit4, and WAT test frameworks
- ✅ Extracts instantiation, assertion, and signal patterns
FILE: test_example_extractor.py line 680-690
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,9 +9,9 @@ Analyzes test files to extract meaningful code examples showing:
|
|||||||
- Setup patterns from fixtures/setUp()
|
- Setup patterns from fixtures/setUp()
|
||||||
- Multi-step workflows from integration tests
|
- Multi-step workflows from integration tests
|
||||||
|
|
||||||
Supports 9 languages:
|
Supports 10 languages:
|
||||||
- Python (AST-based, deep analysis)
|
- Python (AST-based, deep analysis)
|
||||||
- JavaScript, TypeScript, Go, Rust, Java, C#, PHP, Ruby (regex-based)
|
- JavaScript, TypeScript, Go, Rust, Java, C#, PHP, Ruby, GDScript (regex-based)
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
# Extract from directory
|
# Extract from directory
|
||||||
@@ -676,6 +676,16 @@ class GenericTestAnalyzer:
|
|||||||
"assertion": r"expect\(([^)]+)\)\.to\s+(?:eq|be|match)\(([^)]+)\)",
|
"assertion": r"expect\(([^)]+)\)\.to\s+(?:eq|be|match)\(([^)]+)\)",
|
||||||
"test_function": r'(?:test|it)\s+["\']([^"\']+)["\']',
|
"test_function": r'(?:test|it)\s+["\']([^"\']+)["\']',
|
||||||
},
|
},
|
||||||
|
"gdscript": {
|
||||||
|
# GDScript object instantiation (var x = Class.new(), preload, load)
|
||||||
|
"instantiation": r"(?:var|const)\s+(\w+)\s*=\s*(?:(\w+)\.new\(|(?:preload|load)\([\"']([^\"']+)[\"']\)\.new\()",
|
||||||
|
# GUT/gdUnit4 assertions
|
||||||
|
"assertion": r"assert_(?:eq|ne|true|false|null|not_null|gt|lt|between|has|contains|typeof)\(([^)]+)\)",
|
||||||
|
# Test functions: GUT (func test_*), gdUnit4 (@test), WAT (extends WAT.Test)
|
||||||
|
"test_function": r"(?:@test\s+)?func\s+(test_\w+)\s*\(",
|
||||||
|
# Signal connections and emissions
|
||||||
|
"signal": r"(?:(\w+)\.connect\(|emit_signal\([\"'](\w+)[\"'])",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Language name normalization mapping
|
# Language name normalization mapping
|
||||||
|
|||||||
Reference in New Issue
Block a user