]> Cypherpunks repositories - gostls13.git/commitdiff
testing: give short package variable a longer name
authorBrad Fitzpatrick <bradfitz@golang.org>
Sat, 25 Apr 2020 14:01:45 +0000 (07:01 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 25 Apr 2020 18:40:45 +0000 (18:40 +0000)
(Update to CL 229837)

Change-Id: Ieab46bd384f76f678ef0d6a38dc043bc4b0c458a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230157
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/testing/testing.go

index 8dfb61bcc3a1f32327f298942de4e4dfe0746042..ed88ba51fb4e71c8c038b824a6ae548b71db527b 100644 (file)
@@ -797,10 +797,10 @@ func (c *common) Cleanup(f func()) {
        }
 }
 
-var (
-       rOnce sync.Once
-       r     *strings.Replacer
-)
+var tempDirReplacer struct {
+       sync.Once
+       r *strings.Replacer
+}
 
 // TempDir returns a temporary directory for the test to use.
 // It is lazily created on first access, and calls t.Fatal if the directory
@@ -814,10 +814,10 @@ func (c *common) TempDir() string {
 
                // ioutil.TempDir doesn't like path separators in its pattern,
                // so mangle the name to accommodate subtests.
-               rOnce.Do(func() {
-                       r = strings.NewReplacer("/", "_", "\\", "_", ":", "_")
+               tempDirReplacer.Do(func() {
+                       tempDirReplacer.r = strings.NewReplacer("/", "_", "\\", "_", ":", "_")
                })
-               pattern := r.Replace(c.Name())
+               pattern := tempDirReplacer.r.Replace(c.Name())
 
                c.tempDir, c.tempDirErr = ioutil.TempDir("", pattern)
                if c.tempDirErr == nil {