Skip to content

Commit 3bdf145

Browse files
committed
finish generalization
1 parent a9a1a16 commit 3bdf145

File tree

1 file changed

+54
-155
lines changed

1 file changed

+54
-155
lines changed

packages/core/src/testInteg/sam.test.ts

Lines changed: 54 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,19 @@ const noDebugSessionInterval: number = 100
4646
/** Go can't handle API tests yet */
4747
const skipLanguagesOnApi = ['go']
4848

49-
interface TestScenario {
50-
displayName: string
51-
runtime: Runtime
52-
baseImage?: string
49+
interface TestScenarioDefaults {
5350
path: string
5451
debugSessionType: string
5552
language: Language
5653
dependencyManager: DependencyManager
5754
/** Minimum vscode version required by the relevant third-party extension. */
5855
vscodeMinimum: string
5956
}
57+
type TestScenario = {
58+
displayName: string
59+
runtime: Runtime
60+
baseImage?: string
61+
} & TestScenarioDefaults
6062

6163
const nodeDefaults = {
6264
path: 'hello-world/app.mjs',
@@ -90,163 +92,60 @@ const dotnetDefaults = {
9092
vscodeMinimum: '1.80.0',
9193
}
9294

95+
const defaults: Record<Runtime, TestScenarioDefaults> = {
96+
nodejs: nodeDefaults,
97+
java: javaDefaults,
98+
python: pythonDefaults,
99+
dotnet: dotnetDefaults,
100+
}
101+
102+
function generateScenario(
103+
runtime: Runtime,
104+
version: string,
105+
options: Partial<TestScenario & { sourceTag: string }> = {},
106+
fromImage: boolean = false
107+
): TestScenario {
108+
if (fromImage && !options.baseImage) {
109+
throw new Error('baseImage property must be specified when testing from image')
110+
}
111+
const { sourceTag, ...defaultOverride } = options
112+
const source = `(${options.sourceTag ? `${options.sourceTag} ` : ''}${fromImage ? 'Image' : 'ZIP'})`
113+
const fullName = `${runtime}${version}`
114+
return {
115+
runtime: fullName,
116+
displayName: `${fullName} ${source}`,
117+
...defaults[runtime],
118+
...defaultOverride,
119+
}
120+
}
93121
// When testing additional runtimes, consider pulling the docker container in buildspec\linuxIntegrationTests.yml
94122
// to reduce the chance of automated tests timing out.
95123

96124
const scenarios: TestScenario[] = [
97125
// zips
98-
{
99-
runtime: 'nodejs18.x',
100-
displayName: 'nodejs18.x (ZIP)',
101-
...nodeDefaults,
102-
},
103-
{
104-
runtime: 'nodejs20.x',
105-
displayName: 'nodejs20.x (ZIP)',
106-
...nodeDefaults,
107-
},
108-
{
109-
runtime: 'nodejs22.x',
110-
displayName: 'nodejs22.x (ZIP)',
111-
...nodeDefaults,
112-
vscodeMinimum: '1.78.0',
113-
},
114-
{
115-
runtime: 'python3.10',
116-
displayName: 'python 3.10 (ZIP)',
117-
...pythonDefaults,
118-
},
119-
{
120-
runtime: 'python3.11',
121-
displayName: 'python 3.11 (ZIP)',
122-
...pythonDefaults,
123-
vscodeMinimum: '1.78.0',
124-
},
125-
{
126-
runtime: 'python3.12',
127-
displayName: 'python 3.12 (ZIP)',
128-
...pythonDefaults,
129-
vscodeMinimum: '1.78.0',
130-
},
131-
{
132-
runtime: 'python3.13',
133-
displayName: 'python 3.13 (ZIP)',
134-
...pythonDefaults,
135-
vscodeMinimum: '1.78.0',
136-
},
137-
{
138-
runtime: 'dotnet6',
139-
displayName: 'dotnet6 (ZIP)',
140-
...dotnetDefaults,
141-
},
142-
{
143-
runtime: 'java8.al2',
144-
displayName: 'java8.al2 (Maven ZIP)',
145-
...javaDefaults,
146-
},
147-
{
148-
runtime: 'java11',
149-
displayName: 'java11 (Gradle ZIP)',
150-
...javaDefaults,
151-
},
152-
{
153-
runtime: 'java17',
154-
displayName: 'java17 (Gradle ZIP)',
155-
...javaDefaults,
156-
},
157-
// {
158-
// runtime: 'go1.x',
159-
// displayName: 'go1.x (ZIP)',
160-
// path: 'hello-world/main.go',
161-
// debugSessionType: 'delve',
162-
// language: 'go',
163-
// dependencyManager: 'mod',
164-
// // https://github.com/golang/vscode-go/blob/master/package.json
165-
// vscodeMinimum: '1.67.0',
166-
// },
167-
126+
generateScenario('nodejs', '18.x'),
127+
generateScenario('nodejs', '20.x'),
128+
generateScenario('nodejs', '22.x', { vscodeMinimum: '1.78.0' }),
129+
generateScenario('python', '3.10'),
130+
generateScenario('python', '3.11', { vscodeMinimum: '1.78.0' }),
131+
generateScenario('python', '3.12', { vscodeMinimum: '1.78.0' }),
132+
generateScenario('python', '3.13', { vscodeMinimum: '1.78.0' }),
133+
generateScenario('dotnet', '6'),
134+
generateScenario('java', '8.al2', { sourceTag: 'Maven' }),
135+
generateScenario('java', '11', { sourceTag: 'Gradle' }),
136+
generateScenario('java', '17', { sourceTag: 'Gradle' }),
168137
// images
169-
{
170-
runtime: 'nodejs18.x',
171-
displayName: 'nodejs18.x (Image)',
172-
baseImage: 'amazon/nodejs18.x-base',
173-
...nodeDefaults,
174-
},
175-
{
176-
runtime: 'nodejs20.x',
177-
displayName: 'nodejs20.x (Image)',
178-
baseImage: 'amazon/nodejs20.x-base',
179-
...nodeDefaults,
180-
},
181-
{
182-
runtime: 'nodejs22.x',
183-
displayName: 'nodejs22.x (Image)',
184-
baseImage: 'amazon/nodejs22.x-base',
185-
...nodeDefaults,
186-
vscodeMinimum: '1.78.0',
187-
},
188-
{
189-
runtime: 'python3.10',
190-
displayName: 'python 3.10 (ZIP)',
191-
baseImage: 'amazon/python3.10-base',
192-
...pythonDefaults,
193-
},
194-
{
195-
runtime: 'python3.11',
196-
displayName: 'python 3.11 (ZIP)',
197-
baseImage: 'amazon/python3.11-base',
198-
...pythonDefaults,
199-
vscodeMinimum: '1.78.0',
200-
},
201-
{
202-
runtime: 'python3.12',
203-
displayName: 'python 3.12 (ZIP)',
204-
baseImage: 'amazon/python3.12-base',
205-
...pythonDefaults,
206-
vscodeMinimum: '1.78.0',
207-
},
208-
{
209-
runtime: 'python3.13',
210-
displayName: 'python 3.13 (ZIP)',
211-
baseImage: 'amazon/python3.13-base',
212-
...pythonDefaults,
213-
vscodeMinimum: '1.78.0',
214-
},
215-
// {
216-
// runtime: 'go1.x',
217-
// displayName: 'go1.x (Image)',
218-
// baseImage: 'amazon/go1.x-base',
219-
// path: 'hello-world/main.go',
220-
// debugSessionType: 'delve',
221-
// language: 'go',
222-
// dependencyManager: 'mod',
223-
// // https://github.com/golang/vscode-go/blob/master/package.json
224-
// vscodeMinimum: '1.67.0',
225-
// },
226-
{
227-
runtime: 'java8.al2',
228-
displayName: 'java8.al2 (Gradle Image)',
229-
baseImage: 'amazon/java8.al2-base',
230-
...javaDefaults,
231-
},
232-
{
233-
runtime: 'java11',
234-
displayName: 'java11 (Maven Image)',
235-
baseImage: 'amazon/java11-base',
236-
...javaDefaults,
237-
},
238-
{
239-
runtime: 'java17',
240-
displayName: 'java17 (Maven Image)',
241-
baseImage: 'amazon/java17-base',
242-
...javaDefaults,
243-
},
244-
{
245-
runtime: 'dotnet6',
246-
displayName: 'dotnet6 (Image)',
247-
baseImage: 'amazon/dotnet6-base',
248-
...dotnetDefaults,
249-
},
138+
generateScenario('nodejs', '18.x', { baseImage: 'amazon/nodejs18.x-base' }, true),
139+
generateScenario('nodejs', '20.x', { baseImage: 'amazon/nodejs20.x-base' }, true),
140+
generateScenario('nodejs', '22.x', { baseImage: 'amazon/nodejs18.x-base', vscodeMinimum: '1.78.0' }, true),
141+
generateScenario('python', '3.10', { baseImage: 'amazon/python3.10.x-base' }, true),
142+
generateScenario('python', '3.11', { baseImage: 'amazon/python3.11.x-base', vscodeMinimum: '1.78.0' }, true),
143+
generateScenario('python', '3.12', { baseImage: 'amazon/python3.12.x-base', vscodeMinimum: '1.78.0' }, true),
144+
generateScenario('python', '3.13', { baseImage: 'amazon/python3.13.x-base', vscodeMinimum: '1.78.0' }, true),
145+
generateScenario('dotnet', '6', { baseImage: 'amazon/dotnet6-base' }, true),
146+
generateScenario('java', '.al2', { baseImage: 'amazon/java8.al2-base', sourceTag: 'Maven' }, true),
147+
generateScenario('java', '11', { baseImage: 'amazon/java11-base', sourceTag: 'Gradle' }, true),
148+
generateScenario('java', '17', { baseImage: 'amazon/java17-base', sourceTag: 'Gradle' }, true),
250149
]
251150

252151
async function openSamAppFile(applicationPath: string): Promise<vscode.Uri> {

0 commit comments

Comments
 (0)