Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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"
}
33 changes: 8 additions & 25 deletions packages/core/src/amazonqTest/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,7 @@ export class TestController {
this.messenger.sendUpdatePromptProgress(data.tabID, null)
const session = this.sessionStorage.getSession()
const isCancel = data.error.uiMessage === unitTestGenerationCancelMessage
let telemetryErrorMessage = getTelemetryReasonDesc(data.error)
if (session.stopIteration) {
telemetryErrorMessage = getTelemetryReasonDesc(data.error.uiMessage.replaceAll('```', ''))
}
const telemetryErrorMessage = getTelemetryReasonDesc(data.error.uiMessage.replaceAll('```', ''))
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
session.isSupportedLanguage,
Expand All @@ -309,26 +306,13 @@ export class TestController {
undefined,
isCancel ? 'CANCELLED' : 'FAILED'
)
if (session.stopIteration) {
// Error from Science
this.messenger.sendMessage(
data.error.uiMessage.replaceAll('```', ''),
data.tabID,
'answer',
'testGenErrorMessage',
this.getFeedbackButtons()
)
} else {
isCancel
? this.messenger.sendMessage(
data.error.uiMessage,
data.tabID,
'answer',
'testGenErrorMessage',
this.getFeedbackButtons()
)
: this.sendErrorMessage(data)
}
this.messenger.sendMessage(
data.error.uiMessage.replaceAll('```', ''),
data.tabID,
'answer',
'testGenErrorMessage',
this.getFeedbackButtons()
)
await this.sessionCleanUp()
return
}
Expand Down Expand Up @@ -1398,7 +1382,6 @@ export class TestController {
session.sourceFilePath = ''
session.generatedFilePath = ''
session.projectRootPath = ''
session.stopIteration = false
session.fileLanguage = undefined
ChatSessionManager.Instance.setIsInProgress(false)
session.linesOfCodeGenerated = 0
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/amazonqTest/chat/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class Session {
public generatedFilePath: string = ''
public projectRootPath: string = ''
public fileLanguage: string | undefined = 'plaintext'
public stopIteration: boolean = false
public targetFileInfo: TargetFileInfo | undefined
public jobSummary: string = ''

Expand Down
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
14 changes: 11 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,16 @@ 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) {
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