From: Nicolas Peugnet Date: Tue, 18 Feb 2025 11:52:21 +0100 Subject: Directly use time.Ticker to be able to use clockwork v0.1.x Clockwork v0.4.0 provides a wrapper interface for time.Ticker, it is used to swap the real-time clock with a fake one, but this ability is not used in the tests that we run. Thus currently we simply patch docker-compose to directly use time.Ticker, as we are not able to update clockwork without breaking some other packages (e.g. etcd, that will use clockwork v0.5.0 in its upcoming release). Drop this patch once clockwork is updated to v0.4.0 Forwarded: not-needed --- pkg/compose/watch_test.go | 1 + pkg/watch/debounce.go | 4 ++-- pkg/watch/debounce_test.go | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/compose/watch_test.go b/pkg/compose/watch_test.go index c009fdf..c9a442b 100644 --- a/pkg/compose/watch_test.go +++ b/pkg/compose/watch_test.go @@ -72,6 +72,7 @@ func (s stdLogger) Status(containerName, msg string) { } func TestWatch_Sync(t *testing.T) { + t.Skip("requires golang-github-jonboulle-clockwork >= 0.5.0") mockCtrl := gomock.NewController(t) cli := mocks.NewMockCli(mockCtrl) cli.EXPECT().Err().Return(streams.NewOut(os.Stderr)).AnyTimes() diff --git a/pkg/watch/debounce.go b/pkg/watch/debounce.go index 684054b..d043ad7 100644 --- a/pkg/watch/debounce.go +++ b/pkg/watch/debounce.go @@ -48,13 +48,13 @@ func BatchDebounceEvents(ctx context.Context, clock clockwork.Clock, input <-cha seen = utils.Set[FileEvent]{} } - t := clock.NewTicker(QuietPeriod) + t := time.NewTicker(QuietPeriod) defer t.Stop() for { select { case <-ctx.Done(): return - case <-t.Chan(): + case <-t.C: flushEvents() case e, ok := <-input: if !ok { diff --git a/pkg/watch/debounce_test.go b/pkg/watch/debounce_test.go index fd1c40b..862add1 100644 --- a/pkg/watch/debounce_test.go +++ b/pkg/watch/debounce_test.go @@ -12,6 +12,8 @@ limitations under the License. */ +//go:build ignore + package watch import (