File tree Expand file tree Collapse file tree 3 files changed +17
-11
lines changed
amazonq/.changes/next-release Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "type" : " Bug Fix" ,
3+ "description" : " /test: show descriptive error message"
4+ }
Original file line number Diff line number Diff line change @@ -20,8 +20,6 @@ import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
2020import { ChildProcess , spawn } from 'child_process' // eslint-disable-line no-restricted-imports
2121import { BuildStatus } from '../../amazonqTest/chat/session/session'
2222import { fs } from '../../shared/fs/fs'
23- import { TestGenerationJobStatus } from '../models/constants'
24- import { TestGenFailedError } from '../../amazonqTest/error'
2523import { 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments