1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | var path = require('path');
|
19 |
|
20 | var sprintf = require('sprintf').sprintf;
|
21 |
|
22 | var common = require('./common');
|
23 | var testUtil = require('./util');
|
24 | var coverage = require('./coverage');
|
25 | var constants = require('./constants');
|
26 |
|
27 | var ARGUMENTS = {
|
28 | 'test_path': {
|
29 | 'pos': 2
|
30 | },
|
31 | 'socket_path': {
|
32 | 'pos': 3
|
33 | },
|
34 | 'cwd': {
|
35 | 'pos': 4
|
36 | },
|
37 | 'lib_cov_dir': {
|
38 | 'pos': 5
|
39 | },
|
40 | 'scope_leaks': {
|
41 | 'pos': 6
|
42 | },
|
43 | 'chdir': {
|
44 | 'pos': 7
|
45 | },
|
46 | 'custom_assert_module': {
|
47 | 'pos': 8
|
48 | },
|
49 | 'init_file': {
|
50 | 'pos': 9
|
51 | },
|
52 | 'timeout': {
|
53 | 'pos': 10,
|
54 | 'type': 'number'
|
55 | },
|
56 | 'concurrency': {
|
57 | 'pos': 11,
|
58 | 'type': 'pos'
|
59 | },
|
60 | 'pattern': {
|
61 | 'pos': 12
|
62 | },
|
63 | };
|
64 |
|
65 | if (process.argv.length < 6) {
|
66 | console.log('No enough argumentes provided');
|
67 | process.exit(1);
|
68 | }
|
69 |
|
70 | var args = testUtil.parseArguments(ARGUMENTS, process.argv);
|
71 |
|
72 | var testPath = args['test_path'];
|
73 | var socketPath = args['socket_path'];
|
74 | var cwd = args['cwd'];
|
75 | var libCovDir = args['lib_cov_dir'];
|
76 | var scopeLeaks = args['scope_leaks'];
|
77 | var chdir = args['chdir'];
|
78 | var customAssertModule = args['custom_assert_module'];
|
79 | var testInitFile = args['init_file'];
|
80 | var timeout = args['timeout'];
|
81 | var concurrency = args['concurrency'];
|
82 | var pattern = args['pattern'];
|
83 |
|
84 | if (customAssertModule) {
|
85 | var exportedFunctions = require(customAssertModule.replace(/$\.js/, ''));
|
86 | common.registerCustomAssertionFunctions(exportedFunctions);
|
87 | }
|
88 |
|
89 | if (chdir && path.existsSync(chdir)) {
|
90 | process.chdir(chdir);
|
91 | }
|
92 |
|
93 | var options = { 'cwd': cwd, 'socket_path': socketPath,
|
94 | 'init_file': testInitFile, 'timeout': timeout,
|
95 | 'concurrency': concurrency, 'scope_leaks': scopeLeaks,
|
96 | 'pattern': pattern};
|
97 | var testFile = new common.TestFile(testPath, options);
|
98 | testFile.runTests(function onTestFileEnd() {
|
99 | if (libCovDir && typeof _$jscoverage === 'object') {
|
100 | testFile._reportTestCoverage(_$jscoverage);
|
101 | }
|
102 |
|
103 | testFile._reportTestFileEnd();
|
104 | });
|
105 |
|
106 | process.on('uncaughtException', function(err) {
|
107 | testFile.addUncaughtException(err);
|
108 | });
|