Skip to content

Commit

Permalink
increase timeout when on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Hweinstock committed Nov 8, 2024
1 parent d3102da commit a7e092a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
5 changes: 0 additions & 5 deletions packages/core/src/shared/sam/cli/samCliLocalInvoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,7 @@ export class SamCliLocalInvokeInvocation {

public async execute(timeout?: Timeout): Promise<ChildProcess> {
await this.validate()
const start = Date.now()
const sam = await this.config.getOrDetectSamCli()
// eslint-disable-next-line aws-toolkits/no-console-log
console.log('getOrDetect took %O seconds', (Date.now() - start) / 1000)
// eslint-disable-next-line aws-toolkits/no-console-log
console.log('autodetect is %O', sam.autoDetected)
if (!sam.path) {
getLogger().warn('SAM CLI not found and not configured')
} else if (sam.autoDetected) {
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/shared/sam/cli/samCliLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export class SamCliLocationProvider {
public async getLocation(forceSearch?: boolean): Promise<{ path: string; version: string } | undefined> {
const perflog = new PerfLog('samCliLocator: getLocation')
const cachedLoc = forceSearch ? undefined : SamCliLocationProvider.cachedSamLocation
// eslint-disable-next-line aws-toolkits/no-console-log
console.log('cachedLoc is: %O', cachedLoc)

// Avoid searching the system for `sam` (especially slow on Windows).
if (cachedLoc && (await SamCliLocationProvider.isValidSamLocation(cachedLoc.path))) {
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/shared/sam/cli/samCliSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ export class SamCliSettings extends fromExtensionManifest('aws.samcli', descript
SamCliSettings.logIfChanged(`SAM CLI location (from settings): ${fromConfig}`)
return { path: fromConfig, autoDetected: false }
}
const start = Date.now()
const fromSearch = await this.locationProvider.getLocation(forceSearch)
// eslint-disable-next-line aws-toolkits/no-console-log
console.log('getOrDetect took %O seconds', (Date.now() - start) / 1000)

SamCliSettings.logIfChanged(`SAM CLI location (version: ${fromSearch?.version}): ${fromSearch?.path}`)
return { path: fromSearch?.path, autoDetected: true }
Expand Down
67 changes: 38 additions & 29 deletions packages/core/src/test/shared/sam/cli/samCliLocalInvoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import {
import { ChildProcess } from '../../../../shared/utilities/processUtils'
import { assertArgIsPresent, assertArgNotPresent, assertArgsContainArgument } from './samCliTestUtils'
import { fs } from '../../../../shared'

describe('SamCliLocalInvokeInvocation', async function () {
import { isWin } from '../../../../shared/vscode/env'
import Sinon from 'sinon'
import { SamCliLocationProvider } from '../../../../shared/sam/cli/samCliLocator'
// eslint-disable-next-line aws-toolkits/no-only-in-tests
describe.only('SamCliLocalInvokeInvocation', async function () {
class TestSamLocalInvokeCommand implements SamLocalInvokeCommand {
public constructor(private readonly onInvoke: ({ ...params }: SamLocalInvokeCommandArgs) => void) {}

Expand All @@ -41,34 +44,40 @@ describe('SamCliLocalInvokeInvocation', async function () {
afterEach(async function () {
await fs.delete(tempFolder, { recursive: true })
})

it('invokes `sam local` with args', async function () {
const taskInvoker: SamLocalInvokeCommand = new TestSamLocalInvokeCommand(
(invokeArgs: SamLocalInvokeCommandArgs) => {
assert.ok(invokeArgs.args.length >= 2, 'Expected args to be present')
assert.strictEqual(invokeArgs.args[0], 'local')
assert.strictEqual(invokeArgs.args[1], 'invoke')
// --debug is present because tests run with "debug" log-level. #1403
assert.strictEqual(invokeArgs.args[2], '--debug')
assert.strictEqual(invokeArgs.args[4], '--template')
assert.strictEqual(invokeArgs.args[6], '--event')
assert.strictEqual(invokeArgs.args[8], '--env-vars')

// `extraArgs` are appended to the end.
assert.strictEqual(invokeArgs.args[10], '--build-dir')
assert.strictEqual(invokeArgs.args[11], 'my/build/dir/')
for (const _ of Array.from({ length: 1000 }, (i) => i)) {
// eslint-disable-next-line aws-toolkits/no-only-in-tests
it.only('invokes `sam local` with args', async function () {
if (isWin()) {
// TODO: insert 'C:\\Program Files\\Amazon\\AWSSAMCLI\\bin\\sam.cmd' into the cache.
this.timeout(45000)
}
)

await new SamCliLocalInvokeInvocation({
templateResourceName: nonRelevantArg,
templatePath: placeholderTemplateFile,
eventPath: placeholderEventFile,
environmentVariablePath: nonRelevantArg,
invoker: taskInvoker,
extraArgs: ['--build-dir', 'my/build/dir/'],
}).execute()
})
const taskInvoker: SamLocalInvokeCommand = new TestSamLocalInvokeCommand(
(invokeArgs: SamLocalInvokeCommandArgs) => {
assert.ok(invokeArgs.args.length >= 2, 'Expected args to be present')
assert.strictEqual(invokeArgs.args[0], 'local')
assert.strictEqual(invokeArgs.args[1], 'invoke')
// --debug is present because tests run with "debug" log-level. #1403
assert.strictEqual(invokeArgs.args[2], '--debug')
assert.strictEqual(invokeArgs.args[4], '--template')
assert.strictEqual(invokeArgs.args[6], '--event')
assert.strictEqual(invokeArgs.args[8], '--env-vars')

// `extraArgs` are appended to the end.
assert.strictEqual(invokeArgs.args[10], '--build-dir')
assert.strictEqual(invokeArgs.args[11], 'my/build/dir/')
}
)

await new SamCliLocalInvokeInvocation({
templateResourceName: nonRelevantArg,
templatePath: placeholderTemplateFile,
eventPath: placeholderEventFile,
environmentVariablePath: nonRelevantArg,
invoker: taskInvoker,
extraArgs: ['--build-dir', 'my/build/dir/'],
}).execute()
})
}

it('Passes template resource name to sam cli', async function () {
const expectedResourceName = 'HelloWorldResource'
Expand Down

0 comments on commit a7e092a

Please sign in to comment.