blob: 4b910da84407f1d5d4b0581ebd4ab8e11fabf5eb [file] [log] [blame]
// Copyright 2019 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package testingutil
import (
"context"
"time"
"go.chromium.org/tast/core/errors"
)
// Sleep implements testing.Sleep.
func Sleep(ctx context.Context, d time.Duration) error {
tm := time.NewTimer(d)
defer tm.Stop()
select {
case <-tm.C:
return nil
case <-ctx.Done():
return errors.Wrap(ctx.Err(), "sleep interrupted")
}
}