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

fix: wait for prompt on rich param CLI test#15406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
spikecurtis merged 1 commit intomainfromspike/cli-rich-param
Nov 7, 2024

Conversation

spikecurtis
Copy link
Contributor

@spikecurtisspikecurtis commentedNov 6, 2024
edited
Loading

Fixes a race in TestUpdateValidateRichParameters where the parameter is sent prior to the prompt.

Causes errors like:https://github.com/coder/coder/actions/runs/11681622439/job/32527173007

    ptytest.go:132: 2024-11-05 10:02:18.819: cmd: "bool_parameter"    ptytest.go:167: 2024-11-05 10:02:18.819: cmd: matched "bool_parameter" = "bool_parameter"    update_test.go:440: 2024-11-05 10:02:18.819: cmd: stdin: "cat\r\n"    ptytest.go:132: 2024-11-05 10:02:18.819: cmd: "> Enter a value (default: \"\"): can't validate build parameter \"bool_parameter\": boolean value can be either \"true\" or \"false\""    ptytest.go:167: 2024-11-05 10:02:18.819: cmd: matched "boolean value can be either" = "\n> Enter a value (default: \"\"): can't validate build parameter \"bool_parameter\": boolean value can be either"    update_test.go:440: 2024-11-05 10:02:18.819: cmd: stdin: "\r\n"    ptytest.go:167: 2024-11-05 10:02:18.819: cmd: matched "Enter a value" = " \"true\" or \"false\"\n> Enter a value"    update_test.go:440: 2024-11-05 10:02:18.819: cmd: stdin: "false\r\n"    ptytest.go:132: 2024-11-05 10:02:18.821: cmd: "> Enter a value (default: \"\"): can't validate build parameter \"bool_parameter\": boolean value can be either \"true\" or \"false\""

@spikecurtisGraphite App
Copy link
ContributorAuthor

This stack of pull requests is managed by Graphite.Learn more about stacking.

Join@spikecurtis and the rest of your teammates onGraphiteGraphite

@spikecurtisspikecurtis marked this pull request as ready for reviewNovember 6, 2024 13:08
@@ -198,7 +198,7 @@ func (e *outExpecter) expectMatcherFunc(ctx context.Context, str string, fn func
e.fatalf("read error", "%v (wanted %q; got %q)", err, str, buffer.String())
return ""
}
e.logf("matched %q = %q", str,stripansi.Strip(buffer.String()))
e.logf("matched %q = %q", str, buffer.String())
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this can be misleading, since we don't strip the the string of ANSI codes when matching.

mtojek reacted with thumbs up emoji
}
<-doneChan
pty.ExpectMatch(stringParameterName)
pty.ExpectMatch("> Enter a value (default: \"\"): ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I understand the rationale behind proposing this matcher. However, I'm a bit surprised to observe that stdin isn't buffered when input arrives prematurely. Is this the intended behavior, or are you exploring different matcher configurations to address the issue?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It's a good point. I looked into this more and there is a race incliui.Prompt that causes input to be lost in cases where input is being sent too early and we fail validation.

coder/internal#203

I'll separately work on a fix for this ^^

I still think this PR is an improvement: in many cases the explicit matches are fewer lines than the looping construct, and are closer to the timing a human would have.

It also prevents these tests from deadlocking on failure via the bare<-doneChan read.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I agree, mitigating the risk of deadlocks is certainly valuable here.

As for the explicit matchers, I also find them preferable from a readability standpoint; they make the intent clear and reduce ambiguity, allowing developers to quickly grasp the expected input without needing to infer it.

}
<-doneChan
pty.ExpectMatch(stringParameterName)
pty.ExpectMatch("> Enter a value (default: \"\"): ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I agree, mitigating the risk of deadlocks is certainly valuable here.

As for the explicit matchers, I also find them preferable from a readability standpoint; they make the intent clear and reduce ambiguity, allowing developers to quickly grasp the expected input without needing to infer it.

@spikecurtisspikecurtis merged commitcee6b1e intomainNov 7, 2024
27 checks passed
@spikecurtisspikecurtis deleted the spike/cli-rich-param branchNovember 7, 2024 12:47
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mtojekmtojekmtojek approved these changes

Assignees

@spikecurtisspikecurtis

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@spikecurtis@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp