UNPKG

6.81 kBJavaScriptView Raw
1/*
2 * Licensed to Cloudkick, Inc ('Cloudkick') under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * Cloudkick licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18var sprintf = require('sprintf').sprintf;
19
20/*
21 * How long to wait for a test file to complete.
22 */
23var DEFAULT_TEST_TIMEOUT = 15 * 1000;
24
25var DEFAULT_CONCURRENCY = 1;
26
27/**
28 * Default reporters.
29 */
30var DEFAULT_TEST_REPORTER = 'cli';
31var DEFAULT_COVERAGE_REPORTER = 'cli';
32var DEFAULT_SCOPE_LEAKS_REPORTER = 'cli';
33
34/**
35 * Program version.
36 */
37var VERSION = '0.7.1';
38
39/**
40 * Path where the instrumented files are saved.
41 */
42var COVERAGE_PATH = 'lib-cov';
43
44/**
45 * Default test verbosity (1 = quiet, 2 = verbose, 3 = very verbose)
46 */
47var DEFAULT_VERBOSITY = 2;
48
49var INIT_FUNCTION_NAME = 'init';
50
51var GLOBAL_TEARDOWN_FUNCTION_NAME = 'globalTearDown';
52var TEARDOWN_FUNCTION_NAME = 'tearDown';
53var GLOBAL_SETUP_FUNCTION_NAME = 'globalSetUp';
54var SETUP_FUNCTION_NAME = 'setUp';
55
56var DEFAULT_SOCKET_PATH = '/tmp/whiskey-parent.sock';
57
58/**
59 * Different markers.
60 */
61var TEST_START_MARKER = '@-start-test-@';
62var DELIMITER = '@-delimiter-@';
63var TEST_END_MARKER = '@-end-test-@';
64var TEST_FILE_END_MARKER = '@-end-test-file-@';
65var COVERAGE_END_MARKER = '@-end-coverage-@';
66
67/**
68 * Default switches for the option parser.
69 */
70var DEFAULT_OPTIONS = [
71 ['-h', '--help', 'Print this help'],
72 ['-V', '--version', 'Print the version']
73];
74
75/**
76 * Other options for the Whiskey option parser.
77 */
78var WHISKEY_OPTIONS = [
79 ['-t', '--tests STRING', 'Whitespace separated list of test suites to run sequentially.'],
80 ['-T', '--independent-tests STRING', 'Whitespace separated list of test suites capable of running independently and concurrently.'],
81 ['-m', '--max-suites NUMBER', 'The number of concurrently executing test suites (defaults to 5)'],
82 ['-ti', '--test-init-file STRING', 'An initialization file which is run before each test file'],
83 ['-c', '--chdir STRING', 'Directory to which each test process chdirs before running the tests'],
84 ['-v', '--verbosity [NUMBER]', 'Test runner verbosity'],
85 ['-g', '--global-setup-teardown STRING', 'Specifies the file containing the globalSetUp and globalTearDown procedures.'],
86 ['', '--failfast', 'Stop running the tests on the first failure'],
87 ['', '--timeout [NUMBER]', 'How long to wait (ms) for a test file to complete before timing out'],
88 ['', '--socket-path STRING', sprintf('A path to the unix socket used for communication. ' +
89 'Defaults to %s', DEFAULT_SOCKET_PATH)],
90
91 ['', '--concurrency [NUMBER]', sprintf('Maximum number of tests in a file which will run in ' +
92 'parallel. Defaults to %s', DEFAULT_CONCURRENCY)],
93 ['', '--sequential', 'Run test in a file in sequential mode. This is the same as using --concurrency 1'],
94
95 ['', '--custom-assert-module STRING', 'Absolute path to a module with custom assert methods'],
96
97 ['', '--no-styles', 'Don\'t use colors and styles'],
98
99 ['', '--quiet', 'Don\'t print stdout and stderr'],
100 ['', '--real-time', 'Print data which is sent to stdout / stderr as soon ' +
101 'as it comes in'],
102
103 ['', '--test-reporter STRING', 'Rest reporter type (cli or tap)'],
104
105 ['', '--coverage', 'Enable test coverage'],
106 ['', '--coverage-file STRING', 'A file where the coverage result is stored. Only has an effect if json coverage reporter is used'],
107 ['', '--coverage-files STRING', 'A comma-separated list of files containing coverage data'],
108 ['', '--coverage-reporter STRING', 'Coverage reporter type (cli, html)'],
109 ['', '--coverage-dir STRING', 'Directory where the HTML coverage report is saved'],
110 ['', '--coverage-encoding STRING', 'Encoding which jscoverage will use when parsing files which are instrumented'],
111 ['', '--coverage-exclude STRING', 'Paths which won\'t be instrumented'],
112 ['', '--coverage-no-instrument STRING', 'Copy but don\'t instrument the path'],
113 ['', '--coverage-no-regen', 'Don\'t generate coverage file if lib-cov directory already exists'],
114
115 ['', '--scope-leaks', 'Records which variables were leaked into the global ' +
116 'scope.'],
117 ['', '--scope-leaks-reporter STRING', 'Scope leaks reporter type (cli)'],
118 ['-d', '--debug', 'Attach a debugger to a test process'],
119 ['', '--gen-makefile', 'Genarate a Makefile'],
120 ['', '--makefile-path STRING', 'Path where a generated Makefile is saved'],
121 ['', '--report-timing', 'Report test timing'],
122 ['', '--dependencies STRING', 'Path to the test dependencies configuration file'],
123 ['', '--only-essential-dependencies', 'Only start dependencies required by the tests files which are ran']
124];
125
126/**
127 * Other options for the Process runner option parser.
128 */
129var PROCESS_RUNNER_OPTIONS = [
130 ['-c', '--config STRING', 'Path to the dependencies.json file'],
131 ['-v', '--verify', 'Verify the config'],
132 ['-r', '--run', 'Run the processes'],
133 ['-n', '--names STRING', 'Comma-delimited string of the processes to run. Only applicable' +
134 ' if --run is used']
135];
136
137exports.DEFAULT_TEST_TIMEOUT = DEFAULT_TEST_TIMEOUT;
138exports.DEFAULT_CONCURRENCY = DEFAULT_CONCURRENCY;
139exports.DEFAULT_TEST_REPORTER = DEFAULT_TEST_REPORTER;
140exports.DEFAULT_COVERAGE_REPORTER = DEFAULT_COVERAGE_REPORTER;
141exports.DEFAULT_SCOPE_LEAKS_REPORTER = DEFAULT_SCOPE_LEAKS_REPORTER;
142
143exports.VERSION = VERSION;
144exports.COVERAGE_PATH = COVERAGE_PATH;
145exports.DEFAULT_VERBOSITY = DEFAULT_VERBOSITY;
146exports.INIT_FUNCTION_NAME = INIT_FUNCTION_NAME;
147exports.SETUP_FUNCTION_NAME = SETUP_FUNCTION_NAME;
148exports.TEARDOWN_FUNCTION_NAME = TEARDOWN_FUNCTION_NAME;
149exports.GLOBAL_SETUP_FUNCTION_NAME = GLOBAL_SETUP_FUNCTION_NAME;
150exports.GLOBAL_TEARDOWN_FUNCTION_NAME = GLOBAL_TEARDOWN_FUNCTION_NAME;
151exports.DEFAULT_SOCKET_PATH = DEFAULT_SOCKET_PATH;
152exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
153exports.WHISKEY_OPTIONS = WHISKEY_OPTIONS;
154exports.PROCESS_RUNNER_OPTIONS = PROCESS_RUNNER_OPTIONS;
155
156exports.TEST_START_MARKER = TEST_START_MARKER;
157exports.DELIMITER = DELIMITER;
158exports.TEST_END_MARKER = TEST_END_MARKER;
159exports.TEST_FILE_END_MARKER = TEST_FILE_END_MARKER;
160exports.COVERAGE_END_MARKER = COVERAGE_END_MARKER;