Skip to content

Commit

Permalink
Merge branch 'development' into arksap2002/bugs/clean-coverage-after-…
Browse files Browse the repository at this point in the history
…tests-applying
  • Loading branch information
arksap2002 authored Oct 10, 2024
2 parents bd69de0 + 4d61f12 commit de8c2f2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ publishing {
create<MavenPublication>("maven") {
groupId = group as String
artifactId = "testspark-core"
version = "5.0.0"
version = "5.0.1"
from(components["java"])

artifact(tasks["sourcesJar"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ class LLMWithFeedbackCycle(
errorMonitor,
)

// Process stopped checking
if (indicator.isCanceled()) {
executionResult = FeedbackCycleExecutionResult.CANCELED
break
}

when (response.errorCode) {
ResponseErrorCode.OK -> {
log.info { "Test suite generated successfully: ${response.testSuite!!}" }
Expand Down Expand Up @@ -264,6 +270,12 @@ class LLMWithFeedbackCycle(
// saving the compilable test cases
compilableTestCases.addAll(testCasesCompilationResult.compilableTestCases)

// Process stopped checking
if (indicator.isCanceled()) {
executionResult = FeedbackCycleExecutionResult.CANCELED
break
}

if (!testCasesCompilationResult.allTestCasesCompilable && !isLastIteration(requestsCount)) {
log.info { "Non-compilable test suite: \n${testsPresenter.representTestSuite(generatedTestSuite!!)}" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ object ToolUtils {
* @return true if the process has been stopped, false otherwise
*/
fun isProcessStopped(errorMonitor: ErrorMonitor, indicator: CustomProgressIndicator): Boolean {
return errorMonitor.hasErrorOccurred() || isProcessCanceled(indicator)
return errorMonitor.hasErrorOccurred() || isProcessCanceled(errorMonitor, indicator)
}

fun isProcessCanceled(indicator: CustomProgressIndicator): Boolean {
fun isProcessCanceled(errorMonitor: ErrorMonitor, indicator: CustomProgressIndicator): Boolean {
if (indicator.isCanceled()) {
// TODO: we must not stop this indicator! cancellation MAY imply stoppage
errorMonitor.notifyErrorOccurrence()
// TODO: we must not stop this indicator! cancellation MAY already imply stoppage
// See: https://github.com/JetBrains-Research/TestSpark/issues/375
indicator.stop()
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class OpenAIRequestManager(project: Project) : IJRequestManager(project) {
// check response
when (val responseCode = connection.responseCode) {
HttpURLConnection.HTTP_OK -> {
assembleLlmResponse(request, testsAssembler, indicator)
assembleLlmResponse(request, testsAssembler, indicator, errorMonitor)
}

HttpURLConnection.HTTP_INTERNAL_ERROR -> {
Expand Down Expand Up @@ -115,9 +115,10 @@ class OpenAIRequestManager(project: Project) : IJRequestManager(project) {
httpRequest: HttpRequests.Request,
testsAssembler: TestsAssembler,
indicator: CustomProgressIndicator,
errorMonitor: ErrorMonitor,
) {
while (true) {
if (ToolUtils.isProcessCanceled(indicator)) return
if (ToolUtils.isProcessCanceled(errorMonitor, indicator)) return

var text = httpRequest.reader.readLine()

Expand Down

0 comments on commit de8c2f2

Please sign in to comment.