(t *testing.T, condition func() (bool, error))
| 2010 | } |
| 2011 | |
| 2012 | func waitWhileTrue(t *testing.T, condition func() (bool, error)) { |
| 2013 | var ( |
| 2014 | wait bool |
| 2015 | err error |
| 2016 | ) |
| 2017 | timer := time.NewTimer(time.Second * 5) |
| 2018 | for { |
| 2019 | wait, err = condition() |
| 2020 | if wait { |
| 2021 | select { |
| 2022 | case <-timer.C: |
| 2023 | t.Fatal(err) |
| 2024 | default: |
| 2025 | time.Sleep(50 * time.Millisecond) |
| 2026 | continue |
| 2027 | } |
| 2028 | } |
| 2029 | if !timer.Stop() { |
| 2030 | <-timer.C |
| 2031 | } |
| 2032 | break |
| 2033 | } |
| 2034 | } |
| 2035 | |
| 2036 | // If any error occurs on a call to Stream.Read, future calls |
| 2037 | // should continue to return that same error. |
no test coverage detected