@@ -51,13 +51,12 @@ export class CppUTestRunnable extends AbstractRunnable {
5151
5252 const reloadResult = new RunnableReloadResult ( ) ;
5353
54- for ( let i = 0 ; i < xml . testsuites . testsuite . length ; ++ i ) {
55- const suiteName = xml . testsuites . testsuite [ i ] . $ . name ;
54+ const processTestcases = async ( testsuite : any , reloadResult : RunnableReloadResult ) => {
55+ const suiteName = testsuite . $ . name ;
56+ for ( let i = 0 ; i < testsuite . testcase . length ; i ++ ) {
57+ if ( cancellationFlag . isCancellationRequested ) return ;
5658
57- for ( let j = 0 ; j < xml . testsuites . testsuite [ i ] . testcase . length ; j ++ ) {
58- if ( cancellationFlag . isCancellationRequested ) return reloadResult ;
59-
60- const testCase = xml . testsuites . testsuite [ i ] . testcase [ j ] ;
59+ const testCase = testsuite . testcase [ i ] ;
6160 const testName = testCase . $ . name . startsWith ( 'DISABLED_' ) ? testCase . $ . name . substr ( 9 ) : testCase . $ . name ;
6261 const testNameAsId = suiteName + '.' + testCase . $ . name ;
6362
@@ -76,6 +75,15 @@ export class CppUTestRunnable extends AbstractRunnable {
7675 ) ) ,
7776 ) ;
7877 }
78+ } ;
79+
80+ if ( xml . testsuites !== undefined ) {
81+ for ( let i = 0 ; i < xml . testsuites . testsuite . length ; ++ i ) {
82+ await processTestcases ( xml . testsuites . testsuite [ i ] , reloadResult )
83+ . catch ( ( err ) => this . _shared . log . info ( 'Error' , err ) ) ;
84+ }
85+ } else {
86+ await processTestcases ( xml . testsuite , reloadResult ) ;
7987 }
8088
8189 return reloadResult ;
@@ -160,15 +168,20 @@ export class CppUTestRunnable extends AbstractRunnable {
160168 . catch ( err => this . _shared . log . error ( 'error creating xmls folder: ' , junitXmlsFolderPath , err ) ) ;
161169 //Generate xml files
162170 const args = this . properties . prependTestListingArgs . concat ( [ '-ojunit' ] ) ;
163- const options = this . properties . options ;
164- options . cwd = junitXmlsFolderPath ;
171+ const options = { cwd : junitXmlsFolderPath } ;
165172 await this . properties . spawner
166173 . spawnAsync ( this . properties . path , args , options , 30000 )
167174 . then ( ( ) => this . _shared . log . info ( 'create cpputest xmls' , this . properties . path , args , options . cwd ) ) ;
168175 //Merge xmls into single xml
169- await mergeFiles ( cacheFile , [ junitXmlsFolderPath + '/*.xml' ] )
170- . then ( ( ) => this . _shared . log . info ( 'cache xml written' , cacheFile ) )
171- . catch ( err => this . _shared . log . warn ( 'combine xml cache file could not create: ' , cacheFile , err ) ) ;
176+ fs . readdir ( junitXmlsFolderPath , ( err , files ) => {
177+ if ( files . length > 1 ) {
178+ mergeFiles ( cacheFile , [ junitXmlsFolderPath + '/*.xml' ] )
179+ . then ( ( ) => this . _shared . log . info ( 'cache xml written' , cacheFile ) )
180+ . catch ( err => this . _shared . log . warn ( 'combine xml cache file could not create: ' , cacheFile , err ) ) ;
181+ } else {
182+ fs . copyFile ( junitXmlsFolderPath + '/' + files [ 0 ] , cacheFile ) ;
183+ }
184+ } ) ;
172185 //Delete xmls folder
173186 fs . remove ( junitXmlsFolderPath )
174187 . then ( ( ) => this . _shared . log . info ( 'junit-xmls folder deleted' , junitXmlsFolderPath ) )
0 commit comments