Skip to content

Commit

Permalink
Fix test running in CI (#13628)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-peck authored Sep 29, 2020
1 parent 36a6995 commit 414c031
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ target.test = function() {
matchCopy(path.join('**', '@(*.ps1|*.psm1)'), path.join(__dirname, 'Tests', 'lib'), path.join(buildTestsPath, 'lib'));

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

if (!testsSpec.length && !process.env.TF_BUILD) {
if (failWithNoTests) {
fail(`Unable to find tests using the following patterns: ${JSON.stringify([pattern1, pattern2])}`);
} else {
console.warn(`Unable to find tests using the following patterns: ${JSON.stringify([pattern1, pattern2])}`);
}
if (testsSpec.length == 0) {
console.warn(`Unable to find tests using the following patterns: ${JSON.stringify([pattern1, pattern2])}`);
return;
}

// setup the version of node to run the tests
util.installNode(nodeVersion);

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

if (options.task) {
runTaskTests(options.task, true);
runTaskTests(options.task);
} else {
// Run tests for each task that exists
taskList.forEach(function(taskName) {
var taskPath = path.join(buildPath, taskName);
if (fs.existsSync(taskPath)) {
runTaskTests(taskName, false);
runTaskTests(taskName);
}
});

Expand All @@ -378,7 +375,7 @@ target.test = function() {
if (matchFind(commonLibPattern, buildPath).length > 0) {
specs.push(commonLibPattern);
}
if (specs.length) {
if (specs.length > 0) {
// setup the version of node to run the tests
util.installNode(options.node);
run('mocha ' + specs.join(' ') /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/, /*inheritStreams:*/true);
Expand All @@ -391,7 +388,7 @@ target.test = function() {
banner('Running common tests');
var commonPattern = path.join(buildTestsPath, suiteType + '.js');
var specs = matchFind(commonPattern, buildTestsPath, { noRecurse: true });
if (specs.length) {
if (specs.length > 0) {
// setup the version of node to run the tests
util.installNode(options.node);
run('mocha ' + specs.join(' ') /*+ ' --reporter mocha-junit-reporter --reporter-options mochaFile=../testresults/test-results.xml'*/, /*inheritStreams:*/true);
Expand Down

0 comments on commit 414c031

Please sign in to comment.