Skip to content

Commit b9d66a4

Browse files
Merge master into feature/amazonqLSP
2 parents b06bc7b + 86f87a5 commit b9d66a4

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "/test: show descriptive error message"
4+
}

packages/core/src/codewhisperer/commands/startTestGeneration.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
2020
import { ChildProcess, spawn } from 'child_process' // eslint-disable-line no-restricted-imports
2121
import { BuildStatus } from '../../amazonqTest/chat/session/session'
2222
import { fs } from '../../shared/fs/fs'
23-
import { TestGenerationJobStatus } from '../models/constants'
24-
import { TestGenFailedError } from '../../amazonqTest/error'
2523
import { Range } from '../client/codewhispereruserclient'
2624

2725
// eslint-disable-next-line unicorn/no-null
@@ -112,18 +110,13 @@ export async function startTestGenerationProcess(
112110
if (!shouldContinueRunning(tabID)) {
113111
return
114112
}
115-
const jobStatus = await pollTestJobStatus(
113+
await pollTestJobStatus(
116114
testJob.testGenerationJob.testGenerationJobId,
117115
testJob.testGenerationJob.testGenerationJobGroupName,
118116
filePath,
119117
initialExecution
120118
)
121119
// TODO: Send status to test summary
122-
if (jobStatus === TestGenerationJobStatus.FAILED) {
123-
session.numberOfTestsGenerated = 0
124-
logger.verbose(`Test generation failed.`)
125-
throw new TestGenFailedError()
126-
}
127120
throwIfCancelled()
128121
if (!shouldContinueRunning(tabID)) {
129122
return

packages/core/src/codewhisperer/service/testGenHandler.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
CreateUploadUrlError,
1919
ExportResultsArchiveError,
2020
InvalidSourceZipError,
21+
TestGenFailedError,
2122
TestGenStoppedError,
2223
TestGenTimedOutError,
2324
} from '../../amazonqTest/error'
@@ -193,9 +194,17 @@ export async function pollTestJobStatus(
193194
}
194195
}
195196
ChatSessionManager.Instance.getSession().targetFileInfo = targetFileInfo
196-
if (resp.testGenerationJob?.status !== CodeWhispererConstants.TestGenerationJobStatus.IN_PROGRESS) {
197-
// This can be FAILED or COMPLETED
198-
status = resp.testGenerationJob?.status as CodeWhispererConstants.TestGenerationJobStatus
197+
status = resp.testGenerationJob?.status as CodeWhispererConstants.TestGenerationJobStatus
198+
if (status === CodeWhispererConstants.TestGenerationJobStatus.FAILED) {
199+
session.numberOfTestsGenerated = 0
200+
logger.verbose(`Test generation failed.`)
201+
if (resp.testGenerationJob?.jobStatusReason) {
202+
session.stopIteration = true
203+
throw new TestGenFailedError(resp.testGenerationJob?.jobStatusReason)
204+
} else {
205+
throw new TestGenFailedError()
206+
}
207+
} else if (status === CodeWhispererConstants.TestGenerationJobStatus.COMPLETED) {
199208
logger.verbose(`testgen job status: ${status}`)
200209
logger.verbose(`Complete polling test job status.`)
201210
break

0 commit comments

Comments
 (0)