Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "/test: show descriptive error message"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
import { ChildProcess, spawn } from 'child_process' // eslint-disable-line no-restricted-imports
import { BuildStatus } from '../../amazonqTest/chat/session/session'
import { fs } from '../../shared/fs/fs'
import { TestGenerationJobStatus } from '../models/constants'
import { TestGenFailedError } from '../../amazonqTest/error'
import { Range } from '../client/codewhispereruserclient'

// eslint-disable-next-line unicorn/no-null
Expand Down Expand Up @@ -112,18 +110,13 @@ export async function startTestGenerationProcess(
if (!shouldContinueRunning(tabID)) {
return
}
const jobStatus = await pollTestJobStatus(
await pollTestJobStatus(
testJob.testGenerationJob.testGenerationJobId,
testJob.testGenerationJob.testGenerationJobGroupName,
filePath,
initialExecution
)
// TODO: Send status to test summary
if (jobStatus === TestGenerationJobStatus.FAILED) {
session.numberOfTestsGenerated = 0
logger.verbose(`Test generation failed.`)
throw new TestGenFailedError()
}
throwIfCancelled()
if (!shouldContinueRunning(tabID)) {
return
Expand Down
15 changes: 12 additions & 3 deletions packages/core/src/codewhisperer/service/testGenHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
CreateUploadUrlError,
ExportResultsArchiveError,
InvalidSourceZipError,
TestGenFailedError,
TestGenStoppedError,
TestGenTimedOutError,
} from '../../amazonqTest/error'
Expand Down Expand Up @@ -193,9 +194,17 @@ export async function pollTestJobStatus(
}
}
ChatSessionManager.Instance.getSession().targetFileInfo = targetFileInfo
if (resp.testGenerationJob?.status !== CodeWhispererConstants.TestGenerationJobStatus.IN_PROGRESS) {
// This can be FAILED or COMPLETED
status = resp.testGenerationJob?.status as CodeWhispererConstants.TestGenerationJobStatus
status = resp.testGenerationJob?.status as CodeWhispererConstants.TestGenerationJobStatus
if (status === CodeWhispererConstants.TestGenerationJobStatus.FAILED) {
session.numberOfTestsGenerated = 0
logger.verbose(`Test generation failed.`)
if (resp.testGenerationJob?.jobStatusReason) {
session.stopIteration = true
throw new TestGenFailedError(resp.testGenerationJob?.jobStatusReason)
} else {
throw new TestGenFailedError()
}
} else if (status === CodeWhispererConstants.TestGenerationJobStatus.COMPLETED) {
logger.verbose(`testgen job status: ${status}`)
logger.verbose(`Complete polling test job status.`)
break
Expand Down
Loading