Housekeeping
This commit is contained in:
43
main.go
43
main.go
@@ -53,6 +53,48 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, " You can use any valid Lua code, including if statements, loops, etc.\n")
|
||||
fmt.Fprintf(os.Stderr, " Glob patterns are supported for file selection (*.xml, data/**.xml, etc.)\n")
|
||||
}
|
||||
// TODO: Implement -f flag for filtering recipes by name
|
||||
// TODO: Fix bed shitting when doing *.yml in barotrauma directory
|
||||
// TODO: Fix disaster:
|
||||
// fatal error: concurrent map writes
|
||||
//
|
||||
// goroutine 243 [running]:
|
||||
// internal/runtime/maps.fatal({0x8b9c77?, 0xc003399ce8?})
|
||||
// C:/Users/Administrator/scoop/apps/go/current/src/runtime/panic.go:1058 +0x18
|
||||
// main.main.func2({0x0?, 0x0?, 0x0?})
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/main.go:137 +0x31d
|
||||
// modify/logger.SafeGoWithArgs.func1()
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/logger/panic_handler.go:31 +0x43
|
||||
// created by modify/logger.SafeGoWithArgs in goroutine 1
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/logger/panic_handler.go:29 +0x86
|
||||
//
|
||||
// goroutine 1 [chan send]:
|
||||
// main.main()
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/main.go:107 +0x5aa
|
||||
//
|
||||
// goroutine 547 [sync.Mutex.Lock]:
|
||||
// internal/sync.runtime_SemacquireMutex(0x0?, 0x5b?, 0x0?)
|
||||
// C:/Users/Administrator/scoop/apps/go/current/src/runtime/sema.go:95 +0x25
|
||||
// internal/sync.(*Mutex).lockSlow(0xc0000a2240)
|
||||
// C:/Users/Administrator/scoop/apps/go/current/src/internal/sync/mutex.go:149 +0x15d
|
||||
// internal/sync.(*Mutex).Lock(...)
|
||||
// C:/Users/Administrator/scoop/apps/go/current/src/internal/sync/mutex.go:70
|
||||
// sync.(*Mutex).Lock(...)
|
||||
// C:/Users/Administrator/scoop/apps/go/current/src/sync/mutex.go:46
|
||||
// modify/logger.(*Logger).log(0xc0000a2240, 0x1, {0x8bf8ab, 0x1e}, {0xc007049d08, 0x1, 0x1})
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/logger/logger.go:321 +0x9d
|
||||
// modify/logger.(*Logger).Warning(...)
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/logger/logger.go:335
|
||||
// modify/logger.Warning({0x8bf8ab?, 0x5c?}, {0xc004d87d08?, 0xc006b85ae0?, 0x53f3b9?})
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/logger/logger.go:373 +0x87
|
||||
// modify/processor.ProcessRegex({0xc004025000, 0x1f0}, {{0xc00026c450, 0xa}, {0xc000015bd0, 0x4b}, {0xc000261c00, 0xf4}, {0xc000282110, 0x1, ...}, ...})
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/processor/regex.go:64 +0x5c5
|
||||
// main.main.func2({0x0?, 0x0?, 0x0?})
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/main.go:128 +0x471
|
||||
// modify/logger.SafeGoWithArgs.func1()
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/logger/panic_handler.go:31 +0x43
|
||||
// created by modify/logger.SafeGoWithArgs in goroutine 1
|
||||
// C:/Users/Administrator/Seafile/Projects-Go/GoProjects/modifier/logger/panic_handler.go:29 +0x86
|
||||
flag.Parse()
|
||||
args := flag.Args()
|
||||
|
||||
@@ -92,7 +134,6 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Utilize parallel workers for this
|
||||
// Then for each file run all commands associated with the file
|
||||
workers := make(chan struct{}, *utils.ParallelFiles)
|
||||
wg := sync.WaitGroup{}
|
||||
|
@@ -250,7 +250,7 @@ func deduplicateGroups(captureGroups []*CaptureGroup) []*CaptureGroup {
|
||||
}
|
||||
if overlaps {
|
||||
// We CAN just continue despite this fuckup
|
||||
logger.Error("Overlapping capture group: %s", group.Name)
|
||||
logger.Warning("Overlapping capture group: %s", group.Name)
|
||||
continue
|
||||
}
|
||||
logger.Debug("No overlap detected for capture group: %s. Adding to deduplicated groups.", group.Name)
|
||||
@@ -268,8 +268,6 @@ func resolveRegexPlaceholders(pattern string) string {
|
||||
// Handle special pattern modifications
|
||||
if !strings.HasPrefix(pattern, "(?s)") {
|
||||
pattern = "(?s)" + pattern
|
||||
// Use fmt.Printf for test compatibility
|
||||
fmt.Printf("Pattern modified to include (?s): %s\n", pattern)
|
||||
}
|
||||
|
||||
namedGroupNum := regexp.MustCompile(`(?:(\?<[^>]+>)(!num))`)
|
||||
|
@@ -979,29 +979,12 @@ func TestPatternWithoutPrefixGetsModified(t *testing.T) {
|
||||
// Setup
|
||||
pattern := "some.*pattern"
|
||||
|
||||
// Redirect stdout to capture fmt.Printf output
|
||||
oldStdout := os.Stdout
|
||||
r, w, _ := os.Pipe()
|
||||
os.Stdout = w
|
||||
|
||||
// Execute function
|
||||
result := resolveRegexPlaceholders(pattern)
|
||||
|
||||
// Restore stdout
|
||||
w.Close()
|
||||
os.Stdout = oldStdout
|
||||
|
||||
// Read captured output
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, r)
|
||||
output := buf.String()
|
||||
|
||||
// Verify results
|
||||
expectedPattern := "(?s)some.*pattern"
|
||||
assert.Equal(t, expectedPattern, result, "Expected pattern to be %q, got %q", expectedPattern, result)
|
||||
|
||||
expectedOutput := fmt.Sprintf("Pattern modified to include (?s): %s\n", expectedPattern)
|
||||
assert.Equal(t, expectedOutput, output, "Expected output message %q, got %q", expectedOutput, output)
|
||||
}
|
||||
|
||||
// Empty string input returns "(?s)"
|
||||
@@ -1009,29 +992,12 @@ func TestEmptyStringReturnsWithPrefix(t *testing.T) {
|
||||
// Setup
|
||||
pattern := ""
|
||||
|
||||
// Redirect stdout to capture fmt.Printf output
|
||||
oldStdout := os.Stdout
|
||||
r, w, _ := os.Pipe()
|
||||
os.Stdout = w
|
||||
|
||||
// Execute function
|
||||
result := resolveRegexPlaceholders(pattern)
|
||||
|
||||
// Restore stdout
|
||||
w.Close()
|
||||
os.Stdout = oldStdout
|
||||
|
||||
// Read captured output
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, r)
|
||||
output := buf.String()
|
||||
|
||||
// Verify results
|
||||
expectedPattern := "(?s)"
|
||||
assert.Equal(t, expectedPattern, result, "Expected pattern to be %q, got %q", expectedPattern, result)
|
||||
|
||||
expectedOutput := fmt.Sprintf("Pattern modified to include (?s): %s\n", expectedPattern)
|
||||
assert.Equal(t, expectedOutput, output, "Expected output message %q, got %q", expectedOutput, output)
|
||||
}
|
||||
|
||||
// Named group with "!num" pattern gets replaced with proper regex for numbers
|
||||
|
Reference in New Issue
Block a user