Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: fix agent tests on Windows 11 #17631

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spikecurtis
Copy link
Contributor

@spikecurtis spikecurtis commented May 1, 2025

Fixes a couple agent tests so that they work correctly on Windows.

HOME is not a standard Windows environment variable, and we don't have any specific Code in Coder to set it on SSH, so I've removed the test case. Amazingly/bizarrely the Windows test runners set this variable, but this is not standard Windows behavior so we shouldn't be including it in our tests.

Also the command true is not valid on a default Windows install.

true: The term 'true' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I'm not really sure how the CI runners are allowing this test to pass, but again, it's not standard so we shouldn't be doing it.

Copy link
Contributor Author

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

@spikecurtis spikecurtis force-pushed the spike/windows-agent-test-fixes branch from 33090d2 to 825b326 Compare May 1, 2025 10:16
@spikecurtis spikecurtis requested a review from mafredri May 1, 2025 10:20
@spikecurtis spikecurtis marked this pull request as ready for review May 1, 2025 10:20
{
key: "HOME",
want: u.HomeDir,
},
Copy link
Member

Choose a reason for hiding this comment

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

Could we set HOME here instead?

cmd.Env = append(cmd.Env, fmt.Sprintf("LOGNAME=%s", username))

This is what OpenSSH does as well: https://github.com/openssh/openssh-portable/blob/7cc8e150d51a4545b86d996692b541419b35d1a3/session.c#L991

Almost added it last time I was excavating here but I opted on the side of caution. 😅

@@ -1502,7 +1498,7 @@ func TestAgent_Lifecycle(t *testing.T) {

_, client, _, _, _ := setupAgent(t, agentsdk.Manifest{
Scripts: []codersdk.WorkspaceAgentScript{{
Script: "true",
Script: "echo foo",
Copy link
Member

Choose a reason for hiding this comment

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

👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants