Commit ad868c53 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

ctb: Fix concurrent map writes error (#13278)

`ProcessFilesGlob` calls the callback concurrently, so this test needs to lock the `processedFiles` map to prevent panics. See [here](https://app.circleci.com/pipelines/github/ethereum-optimism/optimism/73932/workflows/951eb7de-0611-4bea-b4de-5d3a56c9bf37/jobs/3021176) for an example of this happening.
parent f17da354
...@@ -3,6 +3,7 @@ package common ...@@ -3,6 +3,7 @@ package common
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"sync"
"testing" "testing"
) )
...@@ -79,8 +80,11 @@ func TestProcessFilesGlob(t *testing.T) { ...@@ -79,8 +80,11 @@ func TestProcessFilesGlob(t *testing.T) {
excludes := []string{"skip.txt"} excludes := []string{"skip.txt"}
processedFiles := make(map[string]bool) processedFiles := make(map[string]bool)
var mtx sync.Mutex
err := ProcessFilesGlob(includes, excludes, func(path string) []error { err := ProcessFilesGlob(includes, excludes, func(path string) []error {
mtx.Lock()
processedFiles[filepath.Base(path)] = true processedFiles[filepath.Base(path)] = true
mtx.Unlock()
return nil return nil
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment