Skip to content

Commit

Permalink
Check that an extensions directory has a test directory underneath it.
Browse files Browse the repository at this point in the history
  • Loading branch information
powdercloud committed Apr 5, 2016
1 parent c192abb commit 8943c6e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions validator/validator_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ function readdir(dir) {
return files;
}

/**
* @param {string} dir
* @return {boolean}
*/
function isdir(dir) {
try {
return fs.lstatSync(dir).isDirectory();
} catch (e) {
return false; // If there's neither a file nor a directory.
}
}

/**
* Returns all html files underneath the testdata roots. This looks
* both for feature_tests/*.html and for tests in extension directories.
Expand All @@ -57,8 +69,10 @@ function findHtmlFilesRelativeToTestdata() {
for (const root of process.env['TESTDATA_ROOTS'].split(':')) {
if (path.basename(root) === 'extensions') {
for (const extension of readdir(root)) {
testSubdirs.push(
{root: root, subdir: path.join(extension, '0.1', 'test')});
const testPath = path.join(extension, '0.1', 'test');
if (isdir(path.join(root, testPath))) {
testSubdirs.push({root: root, subdir: testPath});
}
}
} else {
for (const subdir of readdir(root)) {
Expand Down

0 comments on commit 8943c6e

Please sign in to comment.