1 |
|
2 | "use strict";
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | var path = require("path");
|
10 | var logger = require("testarmada-logger");
|
11 |
|
12 | module.exports = function (tests, partialFilename) {
|
13 | logger.prefix = "Mocha Plugin";
|
14 |
|
15 | if (!partialFilename) {
|
16 | logger.log("No partial filename supplied to group filter, using all tests");
|
17 | return tests;
|
18 | }
|
19 |
|
20 | if (typeof partialFilename === "string") {
|
21 | partialFilename = [partialFilename];
|
22 | }
|
23 |
|
24 | logger.log("Using group filter: ", partialFilename);
|
25 | return tests.filter(function (t) {
|
26 | return path.extname(t.filename) === ".js";
|
27 | }).filter(function (t) {
|
28 | return partialFilename.some(function (pfn) {
|
29 | return t.filename.indexOf(pfn) !== -1;
|
30 | });
|
31 | });
|
32 | };
|