Skip to content

test(ec2): unreliable test "SSH Agent can start the agent on windows" #6929

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

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/shared/utilities/processUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export class ChildProcess {
if (typeof rejectOnErrorCode === 'function') {
reject(rejectOnErrorCode(code))
} else {
reject(new Error(`Command exited with non-zero code: ${code}`))
reject(new Error(`Command exited with non-zero code (${code}): ${this.toString()}`))
}
}
if (options.waitForStreams === false) {
Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/test/shared/extensions/ssh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ import { isWin } from '../../../shared/vscode/env'

describe('SSH Agent', function () {
it('can start the agent on windows', async function () {
this.retries(2)

// TODO: we should also skip this test if not running in CI
// Local machines probably won't have admin permissions in the spawned processes
if (process.platform !== 'win32') {
this.skip()
}

const runCommand = (command: string) => {
const args = ['-Command', command]
return new ChildProcess('powershell.exe', args).run({ rejectOnErrorCode: true })
async function runCommand(command: string) {
const args = ['-NoLogo', '-NonInteractive', '-ExecutionPolicy', 'RemoteSigned', '-Command', command]
return await new ChildProcess('pwsh.exe', args).run({ rejectOnErrorCode: true })
}

const getStatus = () => {
return runCommand('echo (Get-Service ssh-agent).Status').then((o) => o.stdout)
async function getStatus() {
const c = await runCommand('echo (Get-Service ssh-agent).Status')
return c.stdout
}

await runCommand('Stop-Service ssh-agent')
Expand Down
Loading