Skip to content

Commit a7e092a

Browse files
committed
increase timeout when on windows
1 parent d3102da commit a7e092a

File tree

4 files changed

+38
-39
lines changed

4 files changed

+38
-39
lines changed

packages/core/src/shared/sam/cli/samCliLocalInvoke.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,7 @@ export class SamCliLocalInvokeInvocation {
232232

233233
public async execute(timeout?: Timeout): Promise<ChildProcess> {
234234
await this.validate()
235-
const start = Date.now()
236235
const sam = await this.config.getOrDetectSamCli()
237-
// eslint-disable-next-line aws-toolkits/no-console-log
238-
console.log('getOrDetect took %O seconds', (Date.now() - start) / 1000)
239-
// eslint-disable-next-line aws-toolkits/no-console-log
240-
console.log('autodetect is %O', sam.autoDetected)
241236
if (!sam.path) {
242237
getLogger().warn('SAM CLI not found and not configured')
243238
} else if (sam.autoDetected) {

packages/core/src/shared/sam/cli/samCliLocator.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ export class SamCliLocationProvider {
2929
public async getLocation(forceSearch?: boolean): Promise<{ path: string; version: string } | undefined> {
3030
const perflog = new PerfLog('samCliLocator: getLocation')
3131
const cachedLoc = forceSearch ? undefined : SamCliLocationProvider.cachedSamLocation
32-
// eslint-disable-next-line aws-toolkits/no-console-log
33-
console.log('cachedLoc is: %O', cachedLoc)
3432

3533
// Avoid searching the system for `sam` (especially slow on Windows).
3634
if (cachedLoc && (await SamCliLocationProvider.isValidSamLocation(cachedLoc.path))) {

packages/core/src/shared/sam/cli/samCliSettings.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ export class SamCliSettings extends fromExtensionManifest('aws.samcli', descript
8383
SamCliSettings.logIfChanged(`SAM CLI location (from settings): ${fromConfig}`)
8484
return { path: fromConfig, autoDetected: false }
8585
}
86-
const start = Date.now()
8786
const fromSearch = await this.locationProvider.getLocation(forceSearch)
88-
// eslint-disable-next-line aws-toolkits/no-console-log
89-
console.log('getOrDetect took %O seconds', (Date.now() - start) / 1000)
9087

9188
SamCliSettings.logIfChanged(`SAM CLI location (version: ${fromSearch?.version}): ${fromSearch?.path}`)
9289
return { path: fromSearch?.path, autoDetected: true }

packages/core/src/test/shared/sam/cli/samCliLocalInvoke.test.ts

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ import {
1414
import { ChildProcess } from '../../../../shared/utilities/processUtils'
1515
import { assertArgIsPresent, assertArgNotPresent, assertArgsContainArgument } from './samCliTestUtils'
1616
import { fs } from '../../../../shared'
17-
18-
describe('SamCliLocalInvokeInvocation', async function () {
17+
import { isWin } from '../../../../shared/vscode/env'
18+
import Sinon from 'sinon'
19+
import { SamCliLocationProvider } from '../../../../shared/sam/cli/samCliLocator'
20+
// eslint-disable-next-line aws-toolkits/no-only-in-tests
21+
describe.only('SamCliLocalInvokeInvocation', async function () {
1922
class TestSamLocalInvokeCommand implements SamLocalInvokeCommand {
2023
public constructor(private readonly onInvoke: ({ ...params }: SamLocalInvokeCommandArgs) => void) {}
2124

@@ -41,34 +44,40 @@ describe('SamCliLocalInvokeInvocation', async function () {
4144
afterEach(async function () {
4245
await fs.delete(tempFolder, { recursive: true })
4346
})
44-
45-
it('invokes `sam local` with args', async function () {
46-
const taskInvoker: SamLocalInvokeCommand = new TestSamLocalInvokeCommand(
47-
(invokeArgs: SamLocalInvokeCommandArgs) => {
48-
assert.ok(invokeArgs.args.length >= 2, 'Expected args to be present')
49-
assert.strictEqual(invokeArgs.args[0], 'local')
50-
assert.strictEqual(invokeArgs.args[1], 'invoke')
51-
// --debug is present because tests run with "debug" log-level. #1403
52-
assert.strictEqual(invokeArgs.args[2], '--debug')
53-
assert.strictEqual(invokeArgs.args[4], '--template')
54-
assert.strictEqual(invokeArgs.args[6], '--event')
55-
assert.strictEqual(invokeArgs.args[8], '--env-vars')
56-
57-
// `extraArgs` are appended to the end.
58-
assert.strictEqual(invokeArgs.args[10], '--build-dir')
59-
assert.strictEqual(invokeArgs.args[11], 'my/build/dir/')
47+
for (const _ of Array.from({ length: 1000 }, (i) => i)) {
48+
// eslint-disable-next-line aws-toolkits/no-only-in-tests
49+
it.only('invokes `sam local` with args', async function () {
50+
if (isWin()) {
51+
// TODO: insert 'C:\\Program Files\\Amazon\\AWSSAMCLI\\bin\\sam.cmd' into the cache.
52+
this.timeout(45000)
6053
}
61-
)
62-
63-
await new SamCliLocalInvokeInvocation({
64-
templateResourceName: nonRelevantArg,
65-
templatePath: placeholderTemplateFile,
66-
eventPath: placeholderEventFile,
67-
environmentVariablePath: nonRelevantArg,
68-
invoker: taskInvoker,
69-
extraArgs: ['--build-dir', 'my/build/dir/'],
70-
}).execute()
71-
})
54+
const taskInvoker: SamLocalInvokeCommand = new TestSamLocalInvokeCommand(
55+
(invokeArgs: SamLocalInvokeCommandArgs) => {
56+
assert.ok(invokeArgs.args.length >= 2, 'Expected args to be present')
57+
assert.strictEqual(invokeArgs.args[0], 'local')
58+
assert.strictEqual(invokeArgs.args[1], 'invoke')
59+
// --debug is present because tests run with "debug" log-level. #1403
60+
assert.strictEqual(invokeArgs.args[2], '--debug')
61+
assert.strictEqual(invokeArgs.args[4], '--template')
62+
assert.strictEqual(invokeArgs.args[6], '--event')
63+
assert.strictEqual(invokeArgs.args[8], '--env-vars')
64+
65+
// `extraArgs` are appended to the end.
66+
assert.strictEqual(invokeArgs.args[10], '--build-dir')
67+
assert.strictEqual(invokeArgs.args[11], 'my/build/dir/')
68+
}
69+
)
70+
71+
await new SamCliLocalInvokeInvocation({
72+
templateResourceName: nonRelevantArg,
73+
templatePath: placeholderTemplateFile,
74+
eventPath: placeholderEventFile,
75+
environmentVariablePath: nonRelevantArg,
76+
invoker: taskInvoker,
77+
extraArgs: ['--build-dir', 'my/build/dir/'],
78+
}).execute()
79+
})
80+
}
7281

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

0 commit comments

Comments
 (0)