1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | var fs = require('fs');
|
17 | var args = (process.ARGV || process.argv);
|
18 |
|
19 | var reporter = '../../../test/framework/xcli-test-reporter';
|
20 | var xunitOption = Array.prototype.indexOf.call(args, '-xunit');
|
21 | if (xunitOption !== -1) {
|
22 | reporter = 'xunit';
|
23 | args.splice(xunitOption, 1);
|
24 | }
|
25 |
|
26 | var testList = args.pop();
|
27 |
|
28 | if (!fs.existsSync) {
|
29 | fs.existsSync = require('path').existsSync;
|
30 | }
|
31 |
|
32 | var root = fs.existsSync('./package.json');
|
33 |
|
34 | function buildFileList(testFiles, testList, root) {
|
35 | var file = root ? './test/' + testList : testList;
|
36 | var fileContent = fs.readFileSync(file).toString();
|
37 | var files = fileContent.split('\n');
|
38 | var includeMark = 'include:';
|
39 | for (var i = 0; i < files.length ; i++) {
|
40 | if (files[i].indexOf(includeMark) === 0) {
|
41 | var fileToInclude = files[i].substring(includeMark.length).replace('\r', '');
|
42 | buildFileList(testFiles, fileToInclude, root);
|
43 | } else {
|
44 | testFiles.push(files[i]);
|
45 | }
|
46 | }
|
47 | }
|
48 |
|
49 | var allFiles = [];
|
50 | buildFileList(allFiles, testList, root);
|
51 |
|
52 | args.push('-u');
|
53 | args.push('tdd');
|
54 |
|
55 |
|
56 | args.push('-t');
|
57 | args.push('500000');
|
58 |
|
59 | allFiles.forEach(function (file) {
|
60 | if (file.length > 0 && file.trim()[0] !== '#') {
|
61 |
|
62 | file = file.replace('\r', '');
|
63 | var temp = root ? 'test/' + file : file;
|
64 | args.push(temp);
|
65 | }
|
66 | });
|
67 |
|
68 | args.push('-R');
|
69 | args.push(reporter);
|
70 |
|
71 | console.log('Start (' + testList + '):' + new Date().toLocaleTimeString());
|
72 |
|
73 |
|
74 |
|
75 | process.on('exit', function (err) {
|
76 | console.log('End:' + new Date().toLocaleTimeString());
|
77 | })
|
78 |
|
79 | require('../node_modules/mocha/bin/mocha');
|