@@ -11,6 +11,7 @@ import { PmdTool } from 'azure-pipelines-tasks-codeanalysis-common/Common/PmdToo
1111import { CheckstyleTool } from 'azure-pipelines-tasks-codeanalysis-common/Common/CheckstyleTool' ;
1212import { FindbugsTool } from 'azure-pipelines-tasks-codeanalysis-common/Common/FindbugsTool' ;
1313import { AnalysisResult } from 'azure-pipelines-tasks-codeanalysis-common/Common/AnalysisResult' ;
14+ import { extractGradleVersion } from '../Modules/environment' ;
1415
1516let isWindows : RegExpMatchArray = os . type ( ) . match ( / ^ W i n / ) ;
1617let gradleWrapper : string = isWindows ? 'gradlew.bat' : 'gradlew' ;
@@ -767,7 +768,7 @@ describe('Gradle L0 Suite', function () {
767768 tr . run ( ) ;
768769
769770 assert ( tr . succeeded , 'task should have succeeded' ) ;
770- assert ( tr . invokedToolCount === 2 , 'should have only run gradle 2 times' ) ;
771+ assert ( tr . invokedToolCount === 3 , 'should have only run gradle 3 times' ) ;
771772 assert ( tr . stderr . length === 0 , 'should not have written to stderr' ) ;
772773 assert ( tr . ran ( gradleWrapper + ` properties` ) , 'should have run Gradle with properties' ) ;
773774 assert ( tr . ran ( gradleWrapper + ` clean build jacocoTestReport` ) , 'should have run Gradle with code coverage' ) ;
@@ -794,7 +795,7 @@ describe('Gradle L0 Suite', function () {
794795 tr . run ( ) ;
795796
796797 assert ( tr . failed , 'task should have failed' ) ;
797- assert ( tr . invokedToolCount === 2 , 'should have only run gradle 2 times' ) ;
798+ assert ( tr . invokedToolCount === 3 , 'should have only run gradle 3 times' ) ;
798799 assert ( tr . stderr . length === 0 , 'should not have written to stderr' ) ;
799800 assert ( tr . stdout . indexOf ( 'loc_mock_NoCodeCoverage' ) > - 1 , 'should have given an error message' ) ;
800801 assert ( tr . ran ( gradleWrapper + ` properties` ) , 'should have run Gradle with properties' ) ;
@@ -820,7 +821,7 @@ describe('Gradle L0 Suite', function () {
820821 tr . run ( ) ;
821822
822823 assert ( tr . succeeded , 'task should have succeeded' ) ;
823- assert ( tr . invokedToolCount === 2 , 'should have only run gradle 2 times' ) ;
824+ assert ( tr . invokedToolCount === 3 , 'should have only run gradle 3 times' ) ;
824825 assert ( tr . stderr . length === 0 , 'should not have written to stderr' ) ;
825826 assert ( tr . ran ( `${ gradleWrapper } properties` ) , 'should have run Gradle with properties' ) ;
826827 assert ( tr . ran ( `${ gradleWrapper } clean build jacocoTestReport` ) , 'should have run Gradle with code coverage' ) ;
@@ -846,7 +847,7 @@ describe('Gradle L0 Suite', function () {
846847 tr . run ( ) ;
847848
848849 assert ( tr . succeeded , 'task should have succeeded' ) ;
849- assert ( tr . invokedToolCount === 2 , 'should have only run gradle 2 times' ) ;
850+ assert ( tr . invokedToolCount === 3 , 'should have only run gradle 3 times' ) ;
850851 assert ( tr . stderr . length === 0 , 'should not have written to stderr' ) ;
851852 assert ( tr . ran ( `${ gradleWrapper } properties` ) , 'should have run Gradle with properties' ) ;
852853 assert ( tr . ran ( `${ gradleWrapper } clean build jacocoTestReport` ) , 'should have run Gradle with code coverage' ) ;
@@ -924,4 +925,22 @@ describe('Gradle L0 Suite', function () {
924925 } ) ;
925926 // /* END Tools tests */
926927
928+ it ( 'extractGradleVersion returns correct results' , ( done ) => {
929+ const log1 : string = 'Gradle 4.0.1' ;
930+ const log2 : string = 'Gradle 4.0' ;
931+ const log3 : string = 'Gradle 3.5-rc-2' ;
932+ const log4 : string = 'Gradle 8.5-20230916222118+0000' ;
933+ const log5 : string = 'Gradle 8.5-20230916222118-0000' ;
934+ const log6 : string = 'Gradle 8.4-branch-ljacomet_kotlin_kotlin_1_9_10-20230901164331+0000'
935+ const log7 : string = '' ;
936+ assert ( extractGradleVersion ( log1 ) === '4.0.1' , 'extractGradleVersion should return 4.0.1' ) ;
937+ assert ( extractGradleVersion ( log2 ) === '4.0' , 'extractGradleVersion should return 4.0' ) ;
938+ assert ( extractGradleVersion ( log3 ) === '3.5-rc-2' , 'extractGradleVersion should return 3.5-rc-2' ) ;
939+ assert ( extractGradleVersion ( log4 ) === '8.5-20230916222118+0000' , 'extractGradleVersion should return 8.5-20230916222118+0000' ) ;
940+ assert ( extractGradleVersion ( log5 ) === '8.5-20230916222118-0000' , 'extractGradleVersion should return 8.5-20230916222118-0000' ) ;
941+ assert ( extractGradleVersion ( log6 ) === '8.4-branch-ljacomet_kotlin_kotlin_1_9_10-20230901164331+0000' , 'extractGradleVersion should return 8.4-branch-ljacomet_kotlin_kotlin_1_9_10-20230901164331+0000' ) ;
942+ assert ( extractGradleVersion ( log7 ) === 'unknown' , 'extractGradleVersion should return unknown' ) ;
943+
944+ done ( ) ;
945+ } ) ;
927946} ) ;
0 commit comments