@@ -14,8 +14,11 @@ import {
1414import { ChildProcess } from '../../../../shared/utilities/processUtils'
1515import { assertArgIsPresent , assertArgNotPresent , assertArgsContainArgument } from './samCliTestUtils'
1616import { 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