summaryrefslogtreecommitdiff
path: root/finder/finder_test.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2020-09-18 14:25:31 -0700
committer Colin Cross <ccross@android.com> 2020-10-06 15:12:22 -0700
commit323dc60712491c71ccdc5363c42df61f0a192487 (patch)
tree5ba86007fb0f7d2536671cbc64e91b1eac304270 /finder/finder_test.go
parent56a8321c210bf73c7b9f177849ff4a6b6192d237 (diff)
Make lots of tests run in parallel
Putting t.Parallel() in each test makes them run in parallel. Additional t.Parallel() could be added to each subtest, although that requires making a local copy of the loop variable for table driven tests. Test: m checkbuild Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
Diffstat (limited to 'finder/finder_test.go')
-rw-r--r--finder/finder_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/finder/finder_test.go b/finder/finder_test.go
index 88b0c058b..029c80f13 100644
--- a/finder/finder_test.go
+++ b/finder/finder_test.go
@@ -122,6 +122,7 @@ func testAgainstSeveralThreadcounts(t *testing.T, tester func(t *testing.T, numT
// end of utils, start of individual tests
func TestSingleFile(t *testing.T) {
+ t.Parallel()
runSimpleTest(t,
[]string{"findme.txt"},
[]string{"findme.txt"},
@@ -129,6 +130,7 @@ func TestSingleFile(t *testing.T) {
}
func TestIncludeFiles(t *testing.T) {
+ t.Parallel()
runSimpleTest(t,
[]string{"findme.txt", "skipme.txt"},
[]string{"findme.txt"},
@@ -136,6 +138,7 @@ func TestIncludeFiles(t *testing.T) {
}
func TestNestedDirectories(t *testing.T) {
+ t.Parallel()
runSimpleTest(t,
[]string{"findme.txt", "skipme.txt", "subdir/findme.txt", "subdir/skipme.txt"},
[]string{"findme.txt", "subdir/findme.txt"},
@@ -143,6 +146,7 @@ func TestNestedDirectories(t *testing.T) {
}
func TestEmptyDirectory(t *testing.T) {
+ t.Parallel()
runSimpleTest(t,
[]string{},
[]string{},
@@ -150,6 +154,7 @@ func TestEmptyDirectory(t *testing.T) {
}
func TestEmptyPath(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
root := "/tmp"
fs.Create(t, filepath.Join(root, "findme.txt"), filesystem)
@@ -170,6 +175,7 @@ func TestEmptyPath(t *testing.T) {
}
func TestFilesystemRoot(t *testing.T) {
+ t.Parallel()
testWithNumThreads := func(t *testing.T, numThreads int) {
filesystem := newFs()
@@ -197,6 +203,7 @@ func TestFilesystemRoot(t *testing.T) {
}
func TestNonexistentDir(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -215,6 +222,7 @@ func TestNonexistentDir(t *testing.T) {
}
func TestExcludeDirs(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/exclude/findme.txt", filesystem)
fs.Create(t, "/tmp/exclude/subdir/findme.txt", filesystem)
@@ -243,6 +251,7 @@ func TestExcludeDirs(t *testing.T) {
}
func TestPruneFiles(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/out/findme.txt", filesystem)
fs.Create(t, "/tmp/out/.ignore-out-dir", filesystem)
@@ -275,6 +284,7 @@ func TestPruneFiles(t *testing.T) {
// TestRootDir tests that the value of RootDirs is used
// tests of the filesystem root are in TestFilesystemRoot
func TestRootDir(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/a/findme.txt", filesystem)
fs.Create(t, "/tmp/a/subdir/findme.txt", filesystem)
@@ -299,6 +309,7 @@ func TestRootDir(t *testing.T) {
}
func TestUncachedDir(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/a/findme.txt", filesystem)
fs.Create(t, "/tmp/a/subdir/findme.txt", filesystem)
@@ -326,6 +337,7 @@ func TestUncachedDir(t *testing.T) {
}
func TestSearchingForFilesExcludedFromCache(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -353,6 +365,7 @@ func TestSearchingForFilesExcludedFromCache(t *testing.T) {
}
func TestRelativeFilePaths(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/ignore/hi.txt", filesystem)
@@ -397,6 +410,7 @@ func TestRelativeFilePaths(t *testing.T) {
// have to run this test with the race-detector (`go test -race src/android/soong/finder/*.go`)
// for there to be much chance of the test actually detecting any error that may be present
func TestRootDirsContainedInOtherRootDirs(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/a/b/c/d/e/f/g/h/i/j/findme.txt", filesystem)
@@ -418,6 +432,7 @@ func TestRootDirsContainedInOtherRootDirs(t *testing.T) {
}
func TestFindFirst(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/a/hi.txt", filesystem)
fs.Create(t, "/tmp/b/hi.txt", filesystem)
@@ -442,6 +457,7 @@ func TestFindFirst(t *testing.T) {
}
func TestConcurrentFindSameDirectory(t *testing.T) {
+ t.Parallel()
testWithNumThreads := func(t *testing.T, numThreads int) {
filesystem := newFs()
@@ -493,6 +509,7 @@ func TestConcurrentFindSameDirectory(t *testing.T) {
}
func TestConcurrentFindDifferentDirectories(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
// create a bunch of files and directories
@@ -556,6 +573,7 @@ func TestConcurrentFindDifferentDirectories(t *testing.T) {
}
func TestStrangelyFormattedPaths(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -581,6 +599,7 @@ func TestStrangelyFormattedPaths(t *testing.T) {
}
func TestCorruptedCacheHeader(t *testing.T) {
+ t.Parallel()
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -605,6 +624,7 @@ func TestCorruptedCacheHeader(t *testing.T) {
}
func TestCanUseCache(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -651,6 +671,7 @@ func TestCanUseCache(t *testing.T) {
}
func TestCorruptedCacheBody(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -715,6 +736,7 @@ func TestCorruptedCacheBody(t *testing.T) {
}
func TestStatCalls(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/a/findme.txt", filesystem)
@@ -738,6 +760,7 @@ func TestStatCalls(t *testing.T) {
}
func TestFileAdded(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/ignoreme.txt", filesystem)
@@ -780,6 +803,7 @@ func TestFileAdded(t *testing.T) {
}
func TestDirectoriesAdded(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/ignoreme.txt", filesystem)
@@ -824,6 +848,7 @@ func TestDirectoriesAdded(t *testing.T) {
}
func TestDirectoryAndSubdirectoryBothUpdated(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/hi1.txt", filesystem)
@@ -864,6 +889,7 @@ func TestDirectoryAndSubdirectoryBothUpdated(t *testing.T) {
}
func TestFileDeleted(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/ignoreme.txt", filesystem)
@@ -904,6 +930,7 @@ func TestFileDeleted(t *testing.T) {
}
func TestDirectoriesDeleted(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -959,6 +986,7 @@ func TestDirectoriesDeleted(t *testing.T) {
}
func TestDirectoriesMoved(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -1017,6 +1045,7 @@ func TestDirectoriesMoved(t *testing.T) {
}
func TestDirectoriesSwapped(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -1132,6 +1161,7 @@ func runFsReplacementTest(t *testing.T, fs1 *fs.MockFs, fs2 *fs.MockFs) {
}
func TestChangeOfDevice(t *testing.T) {
+ t.Parallel()
fs1 := newFs()
// not as fine-grained mounting controls as a real filesystem, but should be adequate
fs1.SetDeviceNumber(0)
@@ -1143,6 +1173,7 @@ func TestChangeOfDevice(t *testing.T) {
}
func TestChangeOfUserOrHost(t *testing.T) {
+ t.Parallel()
fs1 := newFs()
fs1.SetViewId("me@here")
@@ -1153,6 +1184,7 @@ func TestChangeOfUserOrHost(t *testing.T) {
}
func TestConsistentCacheOrdering(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
for i := 0; i < 5; i++ {
@@ -1205,6 +1237,7 @@ func TestConsistentCacheOrdering(t *testing.T) {
}
func TestNumSyscallsOfSecondFind(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -1235,6 +1268,7 @@ func TestNumSyscallsOfSecondFind(t *testing.T) {
}
func TestChangingParamsOfSecondFind(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/findme.txt", filesystem)
@@ -1265,6 +1299,7 @@ func TestChangingParamsOfSecondFind(t *testing.T) {
}
func TestSymlinkPointingToFile(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/a/hi.txt", filesystem)
@@ -1301,6 +1336,7 @@ func TestSymlinkPointingToFile(t *testing.T) {
}
func TestSymlinkPointingToDirectory(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/dir/hi.txt", filesystem)
@@ -1335,6 +1371,7 @@ func TestSymlinkPointingToDirectory(t *testing.T) {
// TestAddPruneFile confirms that adding a prune-file (into a directory for which we
// already had a cache) causes the directory to be ignored
func TestAddPruneFile(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/out/hi.txt", filesystem)
@@ -1373,6 +1410,7 @@ func TestAddPruneFile(t *testing.T) {
}
func TestUpdatingDbIffChanged(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/a/hi.txt", filesystem)
@@ -1432,6 +1470,7 @@ func TestUpdatingDbIffChanged(t *testing.T) {
}
func TestDirectoryNotPermitted(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/hi.txt", filesystem)
@@ -1480,6 +1519,7 @@ func TestDirectoryNotPermitted(t *testing.T) {
}
func TestFileNotPermitted(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/hi.txt", filesystem)
@@ -1502,6 +1542,7 @@ func TestFileNotPermitted(t *testing.T) {
}
func TestCacheEntryPathUnexpectedError(t *testing.T) {
+ t.Parallel()
// setup filesystem
filesystem := newFs()
fs.Create(t, "/tmp/a/hi.txt", filesystem)