@@ -2178,19 +2178,21 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
2178
2178
o .ExperimentalDevcontainersEnabled = true
2179
2179
})
2180
2180
2181
+ ctx := testutil .Context (t ,testutil .WaitLong )
2182
+
2181
2183
// We enabled autostart for the devcontainer, so ready is a good
2182
2184
// indication that the devcontainer is up and running. Importantly,
2183
2185
// this also means that the devcontainer startup is no longer
2184
2186
// producing logs that may interfere with the recreate logs.
2185
- require .Eventually (t ,func ()bool {
2187
+ testutil .Eventually (ctx , t ,func (context. Context )bool {
2186
2188
states := client .GetLifecycleStates ()
2187
2189
return slices .Contains (states ,codersdk .WorkspaceAgentLifecycleReady )
2188
- },testutil .WaitLong , testutil . IntervalMedium ,"devcontainer not ready" )
2190
+ },testutil .IntervalMedium ,"devcontainer not ready" )
2189
2191
2190
2192
t .Logf ("Looking for container with label: devcontainer.local_folder=%s" ,workspaceFolder )
2191
2193
2192
2194
var container docker.APIContainers
2193
- require .Eventually (t ,func ()bool {
2195
+ testutil .Eventually (ctx , t ,func (context. Context )bool {
2194
2196
containers ,err := pool .Client .ListContainers (docker.ListContainersOptions {All :true })
2195
2197
if err != nil {
2196
2198
t .Logf ("Error listing containers: %v" ,err )
@@ -2205,7 +2207,7 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
2205
2207
}
2206
2208
}
2207
2209
return false
2208
- },testutil .WaitLong , testutil . IntervalMedium ,"no container with workspace folder label found" )
2210
+ },testutil .IntervalMedium ,"no container with workspace folder label found" )
2209
2211
defer func (container docker.APIContainers ) {
2210
2212
// We can't rely on pool here because the container is not
2211
2213
// managed by it (it is managed by @devcontainer/cli).
@@ -2217,7 +2219,7 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
2217
2219
assert .Error (t ,err ,"container should be removed by recreate" )
2218
2220
}(container )
2219
2221
2220
- ctx : =testutil .Context (t ,testutil .WaitLong )
2222
+ ctx = testutil .Context (t ,testutil .WaitLong )// Reset context.
2221
2223
2222
2224
// Capture logs via ScriptLogger.
2223
2225
logsCh := make (chan * proto.BatchCreateLogsRequest ,1 )
@@ -2253,7 +2255,7 @@ waitForOutcomeLoop:
2253
2255
t .Logf ("Checking there's a new container with label: devcontainer.local_folder=%s" ,workspaceFolder )
2254
2256
2255
2257
// Make sure the container exists and isn't the same as the old one.
2256
- require .Eventually (t ,func ()bool {
2258
+ testutil .Eventually (ctx , t ,func (context. Context )bool {
2257
2259
containers ,err := pool .Client .ListContainers (docker.ListContainersOptions {All :true })
2258
2260
if err != nil {
2259
2261
t .Logf ("Error listing containers: %v" ,err )
@@ -2272,7 +2274,7 @@ waitForOutcomeLoop:
2272
2274
}
2273
2275
}
2274
2276
return false
2275
- },testutil .WaitLong , testutil . IntervalMedium ,"new devcontainer not found" )
2277
+ },testutil .IntervalMedium ,"new devcontainer not found" )
2276
2278
defer func (container docker.APIContainers ) {
2277
2279
// We can't rely on pool here because the container is not
2278
2280
// managed by it (it is managed by @devcontainer/cli).