diff options
| author | apocelipes <seve3r@outlook.com> | 2024-07-24 10:47:14 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-07-25 00:23:06 +0000 |
| commit | 05861ff90cfc855620d0dcbd1d6cc488ebf04880 (patch) | |
| tree | 72b56bbb48da1f66041fd9df85423740bb3f5120 /src/testing | |
| parent | 0b0dfcd5404ce86d6c818d78bdb6348ded459e96 (diff) | |
| download | go-05861ff90cfc855620d0dcbd1d6cc488ebf04880.tar.xz | |
os,path/filepath,testing: use slices to clean up tests
Replace reflect.DeepEqual with slices.Equal which is much faster.
Change-Id: I299db6f998738174983731f08c1021346b87dfaa
GitHub-Last-Rev: 44ca9015d6af4e0fbe8d23c93b3f2da08a2d7728
GitHub-Pull-Request: golang/go#67613
Reviewed-on: https://go-review.googlesource.com/c/go/+/587938
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/fstest/testfs.go | 3 | ||||
| -rw-r--r-- | src/testing/sub_test.go | 4 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/testing/fstest/testfs.go b/src/testing/fstest/testfs.go index 080bcdd65f..76a2cff62d 100644 --- a/src/testing/fstest/testfs.go +++ b/src/testing/fstest/testfs.go @@ -11,7 +11,6 @@ import ( "io" "io/fs" "path" - "reflect" "slices" "strings" "testing/iotest" @@ -358,7 +357,7 @@ func (t *fsTester) checkGlob(dir string, list []fs.DirEntry) { t.errorf("%s: Glob(%#q): %w", dir, glob, err) return } - if reflect.DeepEqual(want, names) { + if slices.Equal(want, names) { return } diff --git a/src/testing/sub_test.go b/src/testing/sub_test.go index 1c23d054a0..90c2afe605 100644 --- a/src/testing/sub_test.go +++ b/src/testing/sub_test.go @@ -7,9 +7,9 @@ package testing import ( "bytes" "fmt" - "reflect" "regexp" "runtime" + "slices" "strings" "sync" "sync/atomic" @@ -886,7 +886,7 @@ func TestCleanup(t *T) { t.Cleanup(func() { cleanups = append(cleanups, 1) }) t.Cleanup(func() { cleanups = append(cleanups, 2) }) }) - if got, want := cleanups, []int{2, 1}; !reflect.DeepEqual(got, want) { + if got, want := cleanups, []int{2, 1}; !slices.Equal(got, want) { t.Errorf("unexpected cleanup record; got %v want %v", got, want) } } |
