Skip to content

Commit 4b61798

Browse files
committed
Revert "Fix test running in CI (#13628)"
This reverts commit 414c031.
1 parent 2967398 commit 4b61798

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

make.js

+11-8
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) {
334+
function runTaskTests(taskName, failWithNoTests) {
335335
banner('Testing: ' + taskName);
336336
// find the tests
337337
var nodeVersion = options.node || getTaskNodeVersion(buildPath, taskName) + "";
@@ -347,25 +347,28 @@ target.test = function() {
347347
testsSpec.push(pattern2);
348348
}
349349

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+
}
352356
return;
353357
}
354-
355358
// setup the version of node to run the tests
356359
util.installNode(nodeVersion);
357360

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

361364
if (options.task) {
362-
runTaskTests(options.task);
365+
runTaskTests(options.task, true);
363366
} else {
364367
// Run tests for each task that exists
365368
taskList.forEach(function(taskName) {
366369
var taskPath = path.join(buildPath, taskName);
367370
if (fs.existsSync(taskPath)) {
368-
runTaskTests(taskName);
371+
runTaskTests(taskName, false);
369372
}
370373
});
371374

@@ -375,7 +378,7 @@ target.test = function() {
375378
if (matchFind(commonLibPattern, buildPath).length > 0) {
376379
specs.push(commonLibPattern);
377380
}
378-
if (specs.length > 0) {
381+
if (specs.length) {
379382
// setup the version of node to run the tests
380383
util.installNode(options.node);
381384
run('mocha ' + specs.join(' ') /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/, /*inheritStreams:*/true);
@@ -388,7 +391,7 @@ target.test = function() {
388391
banner('Running common tests');
389392
var commonPattern = path.join(buildTestsPath, suiteType + '.js');
390393
var specs = matchFind(commonPattern, buildTestsPath, { noRecurse: true });
391-
if (specs.length > 0) {
394+
if (specs.length) {
392395
// setup the version of node to run the tests
393396
util.installNode(options.node);
394397
run('mocha ' + specs.join(' ') /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/, /*inheritStreams:*/true);

0 commit comments

Comments
 (0)