@@ -39,13 +39,11 @@ func TestWindowsBufferSize(t *testing.T) {
39
39
40
40
func TestNoEvents (t * testing.T ) {
41
41
f := newNotifyFixture (t )
42
- defer f .tearDown ()
43
42
f .assertEvents ()
44
43
}
45
44
46
45
func TestNoWatches (t * testing.T ) {
47
46
f := newNotifyFixture (t )
48
- defer f .tearDown ()
49
47
f .paths = nil
50
48
f .rebuildWatcher ()
51
49
f .assertEvents ()
@@ -58,7 +56,6 @@ func TestEventOrdering(t *testing.T) {
58
56
return
59
57
}
60
58
f := newNotifyFixture (t )
61
- defer f .tearDown ()
62
59
63
60
count := 8
64
61
dirs := make ([]string , count )
@@ -90,7 +87,6 @@ func TestEventOrdering(t *testing.T) {
90
87
// them all quickly. Make sure there are no errors.
91
88
func TestGitBranchSwitch (t * testing.T ) {
92
89
f := newNotifyFixture (t )
93
- defer f .tearDown ()
94
90
95
91
count := 10
96
92
dirs := make ([]string , count )
@@ -144,7 +140,6 @@ func TestGitBranchSwitch(t *testing.T) {
144
140
145
141
func TestWatchesAreRecursive (t * testing.T ) {
146
142
f := newNotifyFixture (t )
147
- defer f .tearDown ()
148
143
149
144
root := f .TempDir ("root" )
150
145
@@ -166,7 +161,6 @@ func TestWatchesAreRecursive(t *testing.T) {
166
161
167
162
func TestNewDirectoriesAreRecursivelyWatched (t * testing.T ) {
168
163
f := newNotifyFixture (t )
169
- defer f .tearDown ()
170
164
171
165
root := f .TempDir ("root" )
172
166
@@ -191,7 +185,6 @@ func TestNewDirectoriesAreRecursivelyWatched(t *testing.T) {
191
185
192
186
func TestWatchNonExistentPath (t * testing.T ) {
193
187
f := newNotifyFixture (t )
194
- defer f .tearDown ()
195
188
196
189
root := f .TempDir ("root" )
197
190
path := filepath .Join (root , "change" )
@@ -206,7 +199,6 @@ func TestWatchNonExistentPath(t *testing.T) {
206
199
207
200
func TestWatchNonExistentPathDoesNotFireSiblingEvent (t * testing.T ) {
208
201
f := newNotifyFixture (t )
209
- defer f .tearDown ()
210
202
211
203
root := f .TempDir ("root" )
212
204
watchedFile := filepath .Join (root , "a.txt" )
@@ -222,7 +214,6 @@ func TestWatchNonExistentPathDoesNotFireSiblingEvent(t *testing.T) {
222
214
223
215
func TestRemove (t * testing.T ) {
224
216
f := newNotifyFixture (t )
225
- defer f .tearDown ()
226
217
227
218
root := f .TempDir ("root" )
228
219
path := filepath .Join (root , "change" )
@@ -242,7 +233,6 @@ func TestRemove(t *testing.T) {
242
233
243
234
func TestRemoveAndAddBack (t * testing.T ) {
244
235
f := newNotifyFixture (t )
245
- defer f .tearDown ()
246
236
247
237
path := filepath .Join (f .paths [0 ], "change" )
248
238
@@ -272,7 +262,6 @@ func TestRemoveAndAddBack(t *testing.T) {
272
262
273
263
func TestSingleFile (t * testing.T ) {
274
264
f := newNotifyFixture (t )
275
- defer f .tearDown ()
276
265
277
266
root := f .TempDir ("root" )
278
267
path := filepath .Join (root , "change" )
@@ -296,7 +285,6 @@ func TestWriteBrokenLink(t *testing.T) {
296
285
t .Skip ("no user-space symlinks on windows" )
297
286
}
298
287
f := newNotifyFixture (t )
299
- defer f .tearDown ()
300
288
301
289
link := filepath .Join (f .paths [0 ], "brokenLink" )
302
290
missingFile := filepath .Join (f .paths [0 ], "missingFile" )
@@ -313,7 +301,6 @@ func TestWriteGoodLink(t *testing.T) {
313
301
t .Skip ("no user-space symlinks on windows" )
314
302
}
315
303
f := newNotifyFixture (t )
316
- defer f .tearDown ()
317
304
318
305
goodFile := filepath .Join (f .paths [0 ], "goodFile" )
319
306
err := ioutil .WriteFile (goodFile , []byte ("hello" ), 0644 )
@@ -335,7 +322,6 @@ func TestWatchBrokenLink(t *testing.T) {
335
322
t .Skip ("no user-space symlinks on windows" )
336
323
}
337
324
f := newNotifyFixture (t )
338
- defer f .tearDown ()
339
325
340
326
newRoot , err := NewDir (t .Name ())
341
327
if err != nil {
@@ -363,7 +349,6 @@ func TestWatchBrokenLink(t *testing.T) {
363
349
364
350
func TestMoveAndReplace (t * testing.T ) {
365
351
f := newNotifyFixture (t )
366
- defer f .tearDown ()
367
352
368
353
root := f .TempDir ("root" )
369
354
file := filepath .Join (root , "myfile" )
@@ -383,7 +368,6 @@ func TestMoveAndReplace(t *testing.T) {
383
368
384
369
func TestWatchBothDirAndFile (t * testing.T ) {
385
370
f := newNotifyFixture (t )
386
- defer f .tearDown ()
387
371
388
372
dir := f .JoinPath ("foo" )
389
373
fileA := f .JoinPath ("foo" , "a" )
@@ -402,7 +386,6 @@ func TestWatchBothDirAndFile(t *testing.T) {
402
386
403
387
func TestWatchNonexistentFileInNonexistentDirectoryCreatedSimultaneously (t * testing.T ) {
404
388
f := newNotifyFixture (t )
405
- defer f .tearDown ()
406
389
407
390
root := f .JoinPath ("root" )
408
391
err := os .Mkdir (root , 0777 )
@@ -420,7 +403,6 @@ func TestWatchNonexistentFileInNonexistentDirectoryCreatedSimultaneously(t *test
420
403
421
404
func TestWatchNonexistentDirectory (t * testing.T ) {
422
405
f := newNotifyFixture (t )
423
- defer f .tearDown ()
424
406
425
407
root := f .JoinPath ("root" )
426
408
err := os .Mkdir (root , 0777 )
@@ -450,7 +432,6 @@ func TestWatchNonexistentDirectory(t *testing.T) {
450
432
451
433
func TestWatchNonexistentFileInNonexistentDirectory (t * testing.T ) {
452
434
f := newNotifyFixture (t )
453
- defer f .tearDown ()
454
435
455
436
root := f .JoinPath ("root" )
456
437
err := os .Mkdir (root , 0777 )
@@ -475,7 +456,6 @@ func TestWatchNonexistentFileInNonexistentDirectory(t *testing.T) {
475
456
476
457
func TestWatchCountInnerFile (t * testing.T ) {
477
458
f := newNotifyFixture (t )
478
- defer f .tearDown ()
479
459
480
460
root := f .paths [0 ]
481
461
a := f .JoinPath (root , "a" )
@@ -493,7 +473,6 @@ func TestWatchCountInnerFile(t *testing.T) {
493
473
494
474
func TestWatchCountInnerFileWithIgnore (t * testing.T ) {
495
475
f := newNotifyFixture (t )
496
- defer f .tearDown ()
497
476
498
477
root := f .paths [0 ]
499
478
ignore , _ := dockerignore .NewDockerPatternMatcher (root , []string {
@@ -517,7 +496,6 @@ func TestWatchCountInnerFileWithIgnore(t *testing.T) {
517
496
518
497
func TestIgnoreCreatedDir (t * testing.T ) {
519
498
f := newNotifyFixture (t )
520
- defer f .tearDown ()
521
499
522
500
root := f .paths [0 ]
523
501
ignore , _ := dockerignore .NewDockerPatternMatcher (root , []string {"a/b" })
@@ -538,7 +516,6 @@ func TestIgnoreCreatedDir(t *testing.T) {
538
516
539
517
func TestIgnoreCreatedDirWithExclusions (t * testing.T ) {
540
518
f := newNotifyFixture (t )
541
- defer f .tearDown ()
542
519
543
520
root := f .paths [0 ]
544
521
ignore , _ := dockerignore .NewDockerPatternMatcher (root ,
@@ -564,7 +541,6 @@ func TestIgnoreCreatedDirWithExclusions(t *testing.T) {
564
541
565
542
func TestIgnoreInitialDir (t * testing.T ) {
566
543
f := newNotifyFixture (t )
567
- defer f .tearDown ()
568
544
569
545
root := f .TempDir ("root" )
570
546
ignore , _ := dockerignore .NewDockerPatternMatcher (root , []string {"a/b" })
@@ -612,6 +588,7 @@ func newNotifyFixture(t *testing.T) *notifyFixture {
612
588
out : out ,
613
589
}
614
590
nf .watch (nf .TempDir ("watched" ))
591
+ t .Cleanup (nf .tearDown )
615
592
return nf
616
593
}
617
594
@@ -759,6 +736,5 @@ func (f *notifyFixture) closeWatcher() {
759
736
func (f * notifyFixture ) tearDown () {
760
737
f .cancel ()
761
738
f .closeWatcher ()
762
- f .TempDirFixture .TearDown ()
763
739
numberOfWatches .Set (0 )
764
740
}
0 commit comments