Skip to content

Commit

Permalink
Ignore empty fixture directories and fix fixtures in the parser (#9113)
Browse files Browse the repository at this point in the history
* Ignore fixture directories that do not contain input or exec

* Fix parser test fixtures structures for some imported esprima tests.

* Warn on test folders that are not empty and do not contain testfiles
  • Loading branch information
danez committed Dec 3, 2018
1 parent 3530d11 commit 07eaa3c
Show file tree
Hide file tree
Showing 366 changed files with 14,984 additions and 754 deletions.
24 changes: 20 additions & 4 deletions packages/babel-helper-fixtures/src/index.js
Expand Up @@ -70,7 +70,7 @@ function findFile(filepath: string, allowJSON: boolean) {
throw new Error(`Found conflicting file matches: ${matches.join(", ")}`);
}

return matches[0] || filepath + ".js";
return matches[0];
}

export default function get(entryLoc): Array<Suite> {
Expand Down Expand Up @@ -101,18 +101,34 @@ export default function get(entryLoc): Array<Suite> {
}

function push(taskName, taskDir) {
const actualLoc = findFile(taskDir + "/input");
const expectLoc = findFile(taskDir + "/output", true /* allowJSON */);
const taskDirStats = fs.statSync(taskDir);
let actualLoc = findFile(taskDir + "/input");
let execLoc = findFile(taskDir + "/exec");

// If neither input nor exec is present it is not a real testcase
if (taskDirStats.isDirectory() && !actualLoc && !execLoc) {
if (fs.readdirSync(taskDir).length > 0) {
console.warn(`Skipped test folder with invalid layout: ${taskDir}`);
}
return;
} else if (!actualLoc) {
actualLoc = taskDir + "/input.js";
} else if (!execLoc) {
execLoc = taskDir + "/exec.js";
}

const expectLoc =
findFile(taskDir + "/output", true /* allowJSON */) ||
taskDir + "/output.js";

const actualLocAlias =
suiteName + "/" + taskName + "/" + path.basename(actualLoc);
const expectLocAlias =
suiteName + "/" + taskName + "/" + path.basename(actualLoc);
let execLocAlias =
suiteName + "/" + taskName + "/" + path.basename(actualLoc);

if (fs.statSync(taskDir).isFile()) {
if (taskDirStats.isFile()) {
const ext = path.extname(taskDir);
if (EXTENSIONS.indexOf(ext) === -1) return;

Expand Down

0 comments on commit 07eaa3c

Please sign in to comment.