Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb9895ac

Browse files
committed
another attempt to fix window stest
1 parent2cbb597 commitb9895ac

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

‎agent/agent_test.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,12 @@ func TestAgent_Session_EnvironmentVariables(t *testing.T) {
324324
err=session.Start(command)
325325
require.NoError(t,err)
326326

327+
// Context is fine here since we're not doing a parallel subtest.
327328
ctx:=testutil.Context(t,testutil.WaitLong)
329+
gofunc() {
330+
<-ctx.Done()
331+
_=session.Close()
332+
}()
328333

329334
s:=bufio.NewScanner(stdout)
330335
out:=make(chanstring)
@@ -338,8 +343,6 @@ func TestAgent_Session_EnvironmentVariables(t *testing.T) {
338343
}
339344
})
340345

341-
// Until we have gotten the first result, the shell may spit out some data.
342-
first:=true
343346
//nolint:paralleltest // These tests need to run sequentially.
344347
fork,partialV:=rangemap[string]string{
345348
"CODER":"true",// From the agent.
@@ -350,21 +353,15 @@ func TestAgent_Session_EnvironmentVariables(t *testing.T) {
350353
} {
351354
t.Run(k,func(t*testing.T) {
352355
echoEnv(t,stdin,k)
353-
iffirst {
354-
for {
355-
s:=testutil.RequireRecvCtx(ctx,t,out)
356-
t.Logf("%s=%s",k,s)
357-
s=strings.TrimSpace(s)
358-
ifstrings.Contains(s,partialV) {
359-
first=false
360-
return
361-
}
356+
// Windows is unreliable, so keep scanning until we find a match.
357+
fors.Scan() {
358+
got:=strings.TrimSpace(s.Text())
359+
t.Logf("%s=%s",k,got)
360+
ifstrings.Contains(got,partialV) {
361+
break
362362
}
363363
}
364-
s:=testutil.RequireRecvCtx(ctx,t,out)
365-
t.Logf("%s=%s",k,s)
366-
s=strings.TrimSpace(s)
367-
require.Contains(t,s,partialV)
364+
require.NoError(t,s.Err())
368365
})
369366
}
370367
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp