@@ -331,7 +331,7 @@ target.test = function() {
331
331
matchCopy ( path . join ( '**' , '@(*.ps1|*.psm1)' ) , path . join ( __dirname , 'Tests' , 'lib' ) , path . join ( buildTestsPath , 'lib' ) ) ;
332
332
333
333
var suiteType = options . suite || 'L0' ;
334
- function runTaskTests ( taskName ) {
334
+ function runTaskTests ( taskName , failWithNoTests ) {
335
335
banner ( 'Testing: ' + taskName ) ;
336
336
// find the tests
337
337
var nodeVersion = options . node || getTaskNodeVersion ( buildPath , taskName ) + "" ;
@@ -347,25 +347,28 @@ target.test = function() {
347
347
testsSpec . push ( pattern2 ) ;
348
348
}
349
349
350
- if ( testsSpec . length == 0 ) {
351
- console . warn ( `Unable to find tests using the following patterns: ${ JSON . stringify ( [ pattern1 , pattern2 ] ) } ` ) ;
350
+ if ( ! testsSpec . length && ! process . env . TF_BUILD ) {
351
+ if ( failWithNoTests ) {
352
+ fail ( `Unable to find tests using the following patterns: ${ JSON . stringify ( [ pattern1 , pattern2 ] ) } ` ) ;
353
+ } else {
354
+ console . warn ( `Unable to find tests using the following patterns: ${ JSON . stringify ( [ pattern1 , pattern2 ] ) } ` ) ;
355
+ }
352
356
return ;
353
357
}
354
-
355
358
// setup the version of node to run the tests
356
359
util . installNode ( nodeVersion ) ;
357
360
358
361
run ( 'mocha ' + testsSpec . join ( ' ' ) /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/ , /*inheritStreams:*/ true ) ;
359
362
}
360
363
361
364
if ( options . task ) {
362
- runTaskTests ( options . task ) ;
365
+ runTaskTests ( options . task , true ) ;
363
366
} else {
364
367
// Run tests for each task that exists
365
368
taskList . forEach ( function ( taskName ) {
366
369
var taskPath = path . join ( buildPath , taskName ) ;
367
370
if ( fs . existsSync ( taskPath ) ) {
368
- runTaskTests ( taskName ) ;
371
+ runTaskTests ( taskName , false ) ;
369
372
}
370
373
} ) ;
371
374
@@ -375,7 +378,7 @@ target.test = function() {
375
378
if ( matchFind ( commonLibPattern , buildPath ) . length > 0 ) {
376
379
specs . push ( commonLibPattern ) ;
377
380
}
378
- if ( specs . length > 0 ) {
381
+ if ( specs . length ) {
379
382
// setup the version of node to run the tests
380
383
util . installNode ( options . node ) ;
381
384
run ( 'mocha ' + specs . join ( ' ' ) /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/ , /*inheritStreams:*/ true ) ;
@@ -388,7 +391,7 @@ target.test = function() {
388
391
banner ( 'Running common tests' ) ;
389
392
var commonPattern = path . join ( buildTestsPath , suiteType + '.js' ) ;
390
393
var specs = matchFind ( commonPattern , buildTestsPath , { noRecurse : true } ) ;
391
- if ( specs . length > 0 ) {
394
+ if ( specs . length ) {
392
395
// setup the version of node to run the tests
393
396
util . installNode ( options . node ) ;
394
397
run ( 'mocha ' + specs . join ( ' ' ) /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/ , /*inheritStreams:*/ true ) ;
0 commit comments