Skip to content

Commit 07eaa3c

Browse files
authored
Ignore empty fixture directories and fix fixtures in the parser (#9113)
* 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
1 parent 3530d11 commit 07eaa3c

File tree

366 files changed

+14984
-754
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

366 files changed

+14984
-754
lines changed

packages/babel-helper-fixtures/src/index.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function findFile(filepath: string, allowJSON: boolean) {
7070
throw new Error(`Found conflicting file matches: ${matches.join(", ")}`);
7171
}
7272

73-
return matches[0] || filepath + ".js";
73+
return matches[0];
7474
}
7575

7676
export default function get(entryLoc): Array<Suite> {
@@ -101,18 +101,34 @@ export default function get(entryLoc): Array<Suite> {
101101
}
102102

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

108+
// If neither input nor exec is present it is not a real testcase
109+
if (taskDirStats.isDirectory() && !actualLoc && !execLoc) {
110+
if (fs.readdirSync(taskDir).length > 0) {
111+
console.warn(`Skipped test folder with invalid layout: ${taskDir}`);
112+
}
113+
return;
114+
} else if (!actualLoc) {
115+
actualLoc = taskDir + "/input.js";
116+
} else if (!execLoc) {
117+
execLoc = taskDir + "/exec.js";
118+
}
119+
120+
const expectLoc =
121+
findFile(taskDir + "/output", true /* allowJSON */) ||
122+
taskDir + "/output.js";
123+
108124
const actualLocAlias =
109125
suiteName + "/" + taskName + "/" + path.basename(actualLoc);
110126
const expectLocAlias =
111127
suiteName + "/" + taskName + "/" + path.basename(actualLoc);
112128
let execLocAlias =
113129
suiteName + "/" + taskName + "/" + path.basename(actualLoc);
114130

115-
if (fs.statSync(taskDir).isFile()) {
131+
if (taskDirStats.isFile()) {
116132
const ext = path.extname(taskDir);
117133
if (EXTENSIONS.indexOf(ext) === -1) return;
118134

0 commit comments

Comments
 (0)