UNPKG

2.29 kBJavaScriptView Raw
1//
2// Copyright (c) Microsoft and contributors. All rights reserved.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16var fs = require('fs');
17var args = (process.ARGV || process.argv);
18
19var reporter = '../../../test/framework/xcli-test-reporter';
20var xunitOption = Array.prototype.indexOf.call(args, '-xunit');
21if (xunitOption !== -1) {
22 reporter = 'xunit';
23 args.splice(xunitOption, 1);
24}
25
26var testList = args.pop();
27
28if (!fs.existsSync) {
29 fs.existsSync = require('path').existsSync;
30}
31
32var root = fs.existsSync('./package.json');
33
34function 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
49var allFiles = [];
50buildFileList(allFiles, testList, root);
51
52args.push('-u');
53args.push('tdd');
54
55// TODO: remove this timeout once tests are faster
56args.push('-t');
57args.push('500000');
58
59allFiles.forEach(function (file) {
60 if (file.length > 0 && file.trim()[0] !== '#') {
61 // trim trailing \r if it exists
62 file = file.replace('\r', '');
63 var temp = root ? 'test/' + file : file;
64 args.push(temp);
65 }
66});
67
68args.push('-R');
69args.push(reporter);
70
71console.log('Start (' + testList + '):' + new Date().toLocaleTimeString());
72
73//console.log(JSON.stringify(args, null, 2));
74
75process.on('exit', function (err) {
76 console.log('End:' + new Date().toLocaleTimeString());
77})
78
79require('../node_modules/mocha/bin/mocha');