Skip to content

Commit dfdc7a8

Browse files
committed
Clean up pre-synctest portions of watch tests
Especially the old forceRuntimeProgress. I copy-pasted that all over the place in the days before synctest.
1 parent ace7482 commit dfdc7a8

File tree

3 files changed

+0
-124
lines changed

3 files changed

+0
-124
lines changed

internal/watch/watch_synctest1_test.go

Lines changed: 0 additions & 89 deletions
This file was deleted.

internal/watch/watch_synctest2_test.go

Lines changed: 0 additions & 3 deletions
This file was deleted.

internal/watch/watch_test.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -376,38 +376,6 @@ func assertWatchTerminates(t *testing.T, w Watch) {
376376
}
377377
}
378378

379-
// assertBlockedAfter fails a test if it receives a value from ch after calling
380-
// settle().
381-
//
382-
// The settle function should ensure that any goroutines that might incorrectly
383-
// send into ch have progressed far enough to do so, ideally to the point that
384-
// they have exited or are durably blocked on another condition.
385-
// [forceRuntimeProgress] makes a best-effort attempt to ensure this in stable
386-
// versions of Go as of writing. Future versions of Go may provide a mechanism
387-
// to robustly guarantee this, like the experimental "testing/synctest" package.
388-
func assertBlockedAfter[T any](settle func(), t *testing.T, ch <-chan T) {
389-
t.Helper()
390-
391-
settle()
392-
select {
393-
case <-ch:
394-
t.Fatal("channel was not blocked")
395-
default:
396-
}
397-
}
398-
399-
// forceRuntimeProgress makes a best-effort attempt to force the Go runtime to
400-
// make progress on all other goroutines in the system, ideally to the point at
401-
// which they will next block if not preempted. It works best if no other
402-
// goroutines are CPU-intensive or change GOMAXPROCS.
403-
func forceRuntimeProgress() {
404-
gomaxprocs := runtime.GOMAXPROCS(1)
405-
defer runtime.GOMAXPROCS(gomaxprocs)
406-
for range runtime.NumGoroutine() {
407-
runtime.Gosched()
408-
}
409-
}
410-
411379
func BenchmarkSet1Watcher(b *testing.B) {
412380
benchmarkSetWithWatchers(b, 1)
413381
}

0 commit comments

Comments
 (0)