@@ -1292,7 +1292,7 @@ def rerunFailedTests(stageName, llmSrc, testCmdLine) {
12921292
12931293 // If there are some failed tests that cannot be rerun (e.g. test duration > 10 min and no known failure signatures),
12941294 // fail the stage immediately without attempting any reruns
1295- rerunTestList = " ${ WORKSPACE} /${ stageName} /rerun_0.txt"
1295+ def rerunTestList = " ${ WORKSPACE} /${ stageName} /rerun_0.txt"
12961296 if (fileExists(rerunTestList)) {
12971297 sh " cat ${ rerunTestList} "
12981298 error " There are some failed tests that cannot be rerun, skip the rerun step."
@@ -1301,10 +1301,10 @@ def rerunFailedTests(stageName, llmSrc, testCmdLine) {
13011301 // If the stage has more than 5 failed tests, skip the rerun step
13021302 def validLineCount = 0
13031303 for (times in [1 , 2 ]) {
1304- rerunTestList = " ${ WORKSPACE} /${ stageName} /rerun_${ times} .txt"
1305- if (fileExists(rerunTestList )) {
1304+ def currentRerunTestList = " ${ WORKSPACE} /${ stageName} /rerun_${ times} .txt"
1305+ if (fileExists(currentRerunTestList )) {
13061306 count = sh(
1307- script : " grep -v '^[[:space:]]*\$ ' ${ rerunTestList } | wc -l" ,
1307+ script : " grep -v '^[[:space:]]*\$ ' ${ currentRerunTestList } | wc -l" ,
13081308 returnStdout : true
13091309 ). trim(). toInteger()
13101310 echo " Found ${ count} tests to rerun ${ times} time(s)"
@@ -1318,31 +1318,31 @@ def rerunFailedTests(stageName, llmSrc, testCmdLine) {
13181318 }
13191319
13201320 // Rerun tests
1321- isRerunFailed = false
1321+ def isRerunFailed = false
13221322 for (times in [1 , 2 ]) {
1323- rerunTestList = " ${ WORKSPACE} /${ stageName} /rerun_${ times} .txt"
1324- if (! fileExists(rerunTestList )) {
1323+ def currentRerunTestList = " ${ WORKSPACE} /${ stageName} /rerun_${ times} .txt"
1324+ if (! fileExists(currentRerunTestList )) {
13251325 echo " No failed tests need to be rerun ${ times} time(s)"
13261326 continue
13271327 }
1328- sh " cat ${ rerunTestList } "
1329- xmlFile = " ${ WORKSPACE} /${ stageName} /rerun_results_${ times} .xml"
1328+ sh " cat ${ currentRerunTestList } "
1329+ def xmlFile = " ${ WORKSPACE} /${ stageName} /rerun_results_${ times} .xml"
13301330 // change the testCmdLine for rerun
1331- noNeedLine = [" --splitting-algorithm" , " --splits" , " --group" , " --waives-file" , " --cov" ]
1332- needToChangeLine = [" --test-list" , " --csv" , " --junit-xml" ]
1333- testCmdLine = testCmdLine. findAll { cmd ->
1331+ def noNeedLine = [" --splitting-algorithm" , " --splits" , " --group" , " --waives-file" , " --cov" ]
1332+ def needToChangeLine = [" --test-list" , " --csv" , " --junit-xml" ]
1333+ def newTestCmdLine = testCmdLine. findAll { cmd ->
13341334 ! noNeedLine. any { line -> cmd. contains(line) } && ! needToChangeLine. any { line -> cmd. contains(line) }
13351335 }
1336- testCmdLine + = [
1337- " --test-list=${ rerunTestList } " ,
1336+ newTestCmdLine + = [
1337+ " --test-list=${ currentRerunTestList } " ,
13381338 " --csv=${ WORKSPACE} /${ stageName} /rerun_report_${ times} .csv" ,
13391339 " --junit-xml ${ xmlFile} " ,
13401340 " --reruns ${ times - 1} "
13411341 ]
13421342 try {
13431343 sh """
13441344 cd ${ llmSrc} /tests/integration/defs && \
1345- ${ testCmdLine .join(" ")}
1345+ ${ newTestCmdLine .join(" ")}
13461346 """
13471347 } catch (InterruptedException e) {
13481348 throw e
@@ -1360,9 +1360,9 @@ def rerunFailedTests(stageName, llmSrc, testCmdLine) {
13601360 sh " cd ${ WORKSPACE} /${ stageName} && sed -i 's/testsuite name=\" pytest\" /testsuite name=\" ${ stageName} \" /g' *.xml || true"
13611361
13621362 // Generate rerun report
1363- inputFiles = [" ${ WORKSPACE} /${ stageName} /results.xml" ,
1364- " ${ WORKSPACE} /${ stageName} /rerun_results_1.xml" ,
1365- " ${ WORKSPACE} /${ stageName} /rerun_results_2.xml" ]
1363+ def inputFiles = [" ${ WORKSPACE} /${ stageName} /results.xml" ,
1364+ " ${ WORKSPACE} /${ stageName} /rerun_results_1.xml" ,
1365+ " ${ WORKSPACE} /${ stageName} /rerun_results_2.xml" ]
13661366 sh """
13671367 python3 ${ llmSrc} /jenkins/scripts/test_rerun.py \
13681368 generate_rerun_report \
@@ -1643,7 +1643,7 @@ def runLLMTestlistOnPlatformImpl(pipeline, platform, testList, config=VANILLA_CO
16431643 } catch (InterruptedException e) {
16441644 throw e
16451645 } catch (Exception e) {
1646- isRerunFailed = rerunFailedTests(stageName, llmSrc, testCmdLine)
1646+ def isRerunFailed = rerunFailedTests(stageName, llmSrc, testCmdLine)
16471647 if (isRerunFailed) {
16481648 error " The tests still failed after rerun attempt."
16491649 }
0 commit comments