1
1
//golangcitest:args -Ettempdir
2
- //golangcitest:config_path testdata/ttempdir_all.yml
3
2
package testdata
4
3
5
4
import (
5
+ "fmt"
6
6
"os"
7
7
"testing"
8
8
)
@@ -12,12 +12,12 @@ var (
12
12
)
13
13
14
14
func testsetup () {
15
- os .MkdirTemp ("a" , "b" ) // if -all = true, want "os\\.MkdirTemp\\(\\) should be replaced by `testing\\.TempDir\\(\\)` in testsetup"
16
- _ , err := os .MkdirTemp ("a" , "b" ) // if -all = true, want "os\\.MkdirTemp\\(\\) should be replaced by `testing\\.TempDir\\(\\)` in testsetup"
15
+ os .MkdirTemp ("a" , "b" ) // never seen
16
+ _ , err := os .MkdirTemp ("a" , "b" ) // never seen
17
17
if err != nil {
18
18
_ = err
19
19
}
20
- os .MkdirTemp ("a" , "b" ) // if -all = true, "func setup is not using testing.TempDir"
20
+ os .MkdirTemp ("a" , "b" ) // never seen
21
21
}
22
22
23
23
func TestF (t * testing.T ) {
@@ -77,3 +77,31 @@ func TestEmpty(t *testing.T) {
77
77
func TestEmptyTB (t * testing.T ) {
78
78
func (testing.TB ) {}(t )
79
79
}
80
+
81
+ func TestTDD (t * testing.T ) {
82
+ for _ , tt := range []struct {
83
+ name string
84
+ }{
85
+ {"test" },
86
+ } {
87
+ t .Run (tt .name , func (t * testing.T ) {
88
+ os .MkdirTemp ("a" , "b" ) // want "os\\.MkdirTemp\\(\\) should be replaced by `t\\.TempDir\\(\\)` in anonymous function"
89
+ _ , err := os .MkdirTemp ("a" , "b" ) // want "os\\.MkdirTemp\\(\\) should be replaced by `t\\.TempDir\\(\\)` in anonymous function"
90
+ _ = err
91
+ if _ , err := os .MkdirTemp ("a" , "b" ); err != nil { // want "os\\.MkdirTemp\\(\\) should be replaced by `t\\.TempDir\\(\\)` in anonymous function"
92
+ _ = err
93
+ }
94
+ })
95
+ }
96
+ }
97
+
98
+ func TestLoop (t * testing.T ) {
99
+ for i := 0 ; i < 3 ; i ++ {
100
+ os .MkdirTemp (fmt .Sprintf ("a%d" , i ), "b" ) // want "os\\.MkdirTemp\\(\\) should be replaced by `t\\.TempDir\\(\\)` in TestLoop"
101
+ _ , err := os .MkdirTemp (fmt .Sprintf ("a%d" , i ), "b" ) // want "os\\.MkdirTemp\\(\\) should be replaced by `t\\.TempDir\\(\\)` in TestLoop"
102
+ _ = err
103
+ if _ , err := os .MkdirTemp (fmt .Sprintf ("a%d" , i ), "b" ); err != nil { // want "os\\.MkdirTemp\\(\\) should be replaced by `t\\.TempDir\\(\\)` in TestLoop"
104
+ _ = err
105
+ }
106
+ }
107
+ }
0 commit comments