mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
This commit was originally automatically generated using `tools/lint --only=eslint --fix`. It was then modified by tabbott to contain only changes to a set of files that are unlikely to result in significant merge conflicts with any open pull request, excluding about 20 files. His plan is to merge the remaining changes with more precise care, potentially involving merging parts of conflicting pull requests before running the `eslint --fix` operation. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
const _ = require('underscore/underscore.js');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
exports.find_files_to_run = function () {
|
|
let oneFileFilter = [];
|
|
let testsDifference = [];
|
|
if (process.argv[2]) {
|
|
oneFileFilter = process.argv
|
|
.slice(2)
|
|
.filter(function (filename) {return (/[.]js$/).test(filename);})
|
|
.map(function (filename) {return filename.replace(/\.js$/i, '');});
|
|
}
|
|
|
|
// tests_dir is where we find our specific unit tests (as opposed
|
|
// to framework code)
|
|
const tests_dir = __dirname.replace(/zjsunit/, 'node_tests');
|
|
|
|
let tests = fs.readdirSync(tests_dir)
|
|
.filter(function (filename) {return !(/^\./i).test(filename);})
|
|
.filter(function (filename) {return (/\.js$/i).test(filename);})
|
|
.map(function (filename) {return filename.replace(/\.js$/i, '');});
|
|
|
|
if (oneFileFilter.length > 0) {
|
|
tests = tests.filter(function (filename) {
|
|
return oneFileFilter.indexOf(filename) !== -1;
|
|
});
|
|
testsDifference = _.difference(oneFileFilter, tests);
|
|
}
|
|
|
|
testsDifference.forEach(function (filename) {
|
|
throw filename + ".js does not exist";
|
|
});
|
|
|
|
tests.sort();
|
|
|
|
const files = tests.map(function (fn) {
|
|
const obj = {};
|
|
obj.name = fn;
|
|
obj.full_name = path.join(tests_dir, fn);
|
|
return obj;
|
|
});
|
|
|
|
return files;
|
|
};
|