Skip to content

Commit 414c031

Browse files
authored
Fix test running in CI (#13628)
1 parent 36a6995 commit 414c031

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

make.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ target.test = function() {
331331
matchCopy(path.join('**', '@(*.ps1|*.psm1)'), path.join(__dirname, 'Tests', 'lib'), path.join(buildTestsPath, 'lib'));
332332

333333
var suiteType = options.suite || 'L0';
334-
function runTaskTests(taskName, failWithNoTests) {
334+
function runTaskTests(taskName) {
335335
banner('Testing: ' + taskName);
336336
// find the tests
337337
var nodeVersion = options.node || getTaskNodeVersion(buildPath, taskName) + "";
@@ -347,28 +347,25 @@ target.test = function() {
347347
testsSpec.push(pattern2);
348348
}
349349

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-
}
350+
if (testsSpec.length == 0) {
351+
console.warn(`Unable to find tests using the following patterns: ${JSON.stringify([pattern1, pattern2])}`);
356352
return;
357353
}
354+
358355
// setup the version of node to run the tests
359356
util.installNode(nodeVersion);
360357

361358
run('mocha ' + testsSpec.join(' ') /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/, /*inheritStreams:*/true);
362359
}
363360

364361
if (options.task) {
365-
runTaskTests(options.task, true);
362+
runTaskTests(options.task);
366363
} else {
367364
// Run tests for each task that exists
368365
taskList.forEach(function(taskName) {
369366
var taskPath = path.join(buildPath, taskName);
370367
if (fs.existsSync(taskPath)) {
371-
runTaskTests(taskName, false);
368+
runTaskTests(taskName);
372369
}
373370
});
374371

@@ -378,7 +375,7 @@ target.test = function() {
378375
if (matchFind(commonLibPattern, buildPath).length > 0) {
379376
specs.push(commonLibPattern);
380377
}
381-
if (specs.length) {
378+
if (specs.length > 0) {
382379
// setup the version of node to run the tests
383380
util.installNode(options.node);
384381
run('mocha ' + specs.join(' ') /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/, /*inheritStreams:*/true);
@@ -391,7 +388,7 @@ target.test = function() {
391388
banner('Running common tests');
392389
var commonPattern = path.join(buildTestsPath, suiteType + '.js');
393390
var specs = matchFind(commonPattern, buildTestsPath, { noRecurse: true });
394-
if (specs.length) {
391+
if (specs.length > 0) {
395392
// setup the version of node to run the tests
396393
util.installNode(options.node);
397394
run('mocha ' + specs.join(' ') /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/, /*inheritStreams:*/true);

0 commit comments

Comments
 (0)