Skip to content

Commit

Permalink
Fix test file scanning for Windows (closes DevExpress#3918) (DevExpre…
Browse files Browse the repository at this point in the history
…ss#3927)

* Fix test file scanning for Windows

* Refactor after review

* Fix
  • Loading branch information
AndreyBelym authored and kirovboris committed Dec 18, 2019
1 parent 97d0152 commit 9a9bedc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"emittery": "^0.4.1",
"endpoint-utils": "^1.0.2",
"error-stack-parser": "^1.3.6",
"globby": "^3.0.1",
"globby": "^9.2.0",
"graceful-fs": "^4.1.11",
"graphlib": "^2.1.5",
"import-lazy": "^3.1.0",
Expand Down
28 changes: 23 additions & 5 deletions src/utils/parse-file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import globby from 'globby';
import isGlob from 'is-glob';
import Compiler from '../compiler';
import OS from 'os-family';
import { isEmpty } from 'lodash';
import { isEmpty, flatten } from 'lodash';
import { stat } from '../utils/promisified-functions';

const DEFAULT_TEST_LOOKUP_DIRS = ['test/', 'tests/'];
Expand All @@ -24,9 +24,12 @@ function modifyFileRoot (baseDir, file) {

async function getDefaultDirs (baseDir) {
return await globby(DEFAULT_TEST_LOOKUP_DIRS, {
cwd: baseDir,
nocase: true,
silent: true
cwd: baseDir,
absolute: true,
caseSensitiveMatch: false,
expandDirectories: false,
onlyDirectories: true,
suppressErrors: true
});
}

Expand Down Expand Up @@ -56,12 +59,27 @@ async function convertDirsToGlobs (fileList, baseDir) {
return fileList.filter(file => !!file);
}

async function getFiles (globTask) {
const files = await globby(globTask.pattern, globTask.options);

return files.sort((fileA, fileB) => fileA.localeCompare(fileB));
}

async function execFileGlobs (globs, baseDir) {
// NOTE: We have to create glob tasks, execute them and sort their results separately to preserve the same item order
// as in the older globby versions (<7.1.1)
const tasks = globby.generateGlobTasks(globs, { cwd: baseDir, expandDirectories: false, onlyFiles: true });
const files = await Promise.all(tasks.map(getFiles));

return flatten(files);
}

export default async function parseFileList (fileList, baseDir) {
if (isEmpty(fileList))
fileList = await getDefaultDirs(baseDir);

fileList = await convertDirsToGlobs(fileList, baseDir);
fileList = await globby(fileList, { cwd: baseDir });
fileList = await execFileGlobs(fileList, baseDir);

return fileList.map(file => path.resolve(baseDir, file));
}

0 comments on commit 9a9bedc

Please sign in to comment.