Skip to content

Commit a06a225

Browse files
committed
tests: don't call testing.Testing() in mocks
With commit 6864912 ("Isolate the testing import in test code"), the testing hooks were only ever called in binaries compiled in test mode, meaning that checking if we are in a test doesn't really make sense. This is also necessary to remove because testing.Testing() was added in Go 1.21, which is too new for some of our users. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
1 parent 07ceaf0 commit a06a225

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

testing_mocks_linux_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package securejoin
88

99
import (
1010
"os"
11-
"testing"
1211
)
1312

1413
type forceGetProcRootLevel int
@@ -33,17 +32,17 @@ func testingCheckClose(check bool, f *os.File) bool {
3332
}
3433

3534
func testingForcePrivateProcRootOpenTree(f *os.File) bool {
36-
return testing.Testing() && testingForceGetProcRoot != nil &&
35+
return testingForceGetProcRoot != nil &&
3736
testingCheckClose(*testingForceGetProcRoot >= forceGetProcRootOpenTree, f)
3837
}
3938

4039
func testingForcePrivateProcRootOpenTreeAtRecursive(f *os.File) bool {
41-
return testing.Testing() && testingForceGetProcRoot != nil &&
40+
return testingForceGetProcRoot != nil &&
4241
testingCheckClose(*testingForceGetProcRoot >= forceGetProcRootOpenTreeAtRecursive, f)
4342
}
4443

4544
func testingForceGetProcRootUnsafe() bool {
46-
return testing.Testing() && testingForceGetProcRoot != nil &&
45+
return testingForceGetProcRoot != nil &&
4746
*testingForceGetProcRoot >= forceGetProcRootUnsafe
4847
}
4948

@@ -58,12 +57,12 @@ const (
5857
var testingForceProcThreadSelf *forceProcThreadSelfLevel
5958

6059
func testingForceProcSelfTask() bool {
61-
return testing.Testing() && testingForceProcThreadSelf != nil &&
60+
return testingForceProcThreadSelf != nil &&
6261
*testingForceProcThreadSelf >= forceProcSelfTask
6362
}
6463

6564
func testingForceProcSelf() bool {
66-
return testing.Testing() && testingForceProcThreadSelf != nil &&
65+
return testingForceProcThreadSelf != nil &&
6766
*testingForceProcThreadSelf >= forceProcSelf
6867
}
6968

0 commit comments

Comments
 (0)