UNPKG

6.45 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.6.9';
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 TEARDOWN_FUNCTION_NAME = 'tearDown';
52
53var SETUP_FUNCTION_NAME = 'setUp';
54
55var DEFAULT_SOCKET_PATH = '/tmp/whiskey-parent.sock';
56
57/**
58 * Different markers.
59 */
60var TEST_START_MARKER = '@-start-test-@';
61var DELIMITER = '@-delimiter-@';
62var TEST_END_MARKER = '@-end-test-@';
63var TEST_FILE_END_MARKER = '@-end-test-file-@';
64var COVERAGE_END_MARKER = '@-end-coverage-@';
65
66/**
67 * Default switches for the option parser.
68 */
69var DEFAULT_OPTIONS = [
70 ['-h', '--help', 'Print this help'],
71 ['-V', '--version', 'Print the version']
72];
73
74/**
75 * Other options for the Whiskey option parser.
76 */
77var WHISKEY_OPTIONS = [
78 ['-t', '--tests STRING', 'Whitespace separated list of test suites to run sequentially.'],
79 ['-T', '--independent-tests STRING', 'Whitespace separated list of test suites capable of running independently and concurrently.'],
80 ['-m', '--max-suites NUMBER', 'The number of concurrently executing test suites (defaults to 5)'],
81 ['-ti', '--test-init-file STRING', 'An initialization file which is run before each test file'],
82 ['-c', '--chdir STRING', 'Directory to which each test process chdirs before running the tests'],
83 ['-v', '--verbosity [NUMBER]', 'Test runner verbosity'],
84 ['', '--failfast', 'Stop running the tests on the first failure'],
85 ['', '--timeout [NUMBER]', 'How long to wait (ms) for a test file to complete before timing out'],
86 ['', '--socket-path STRING', sprintf('A path to the unix socket used for communication. ' +
87 'Defaults to %s', DEFAULT_SOCKET_PATH)],
88
89 ['', '--concurrency [NUMBER]', sprintf('Maximum number of tests in a file which will run in ' +
90 'parallel. Defaults to %s', DEFAULT_CONCURRENCY)],
91 ['', '--sequential', 'Run test in a file in sequential mode. This is the same as using --concurrency 1'],
92
93 ['', '--custom-assert-module STRING', 'Absolute path to a module with custom assert methods'],
94
95 ['', '--no-styles', 'Don\'t use colors and styles'],
96
97 ['', '--quiet', 'Don\'t print stdout and stderr'],
98 ['', '--real-time', 'Print data which is sent to stdout / stderr as soon ' +
99 'as it comes in'],
100
101 ['', '--test-reporter STRING', 'Rest reporter type (cli or tap)'],
102
103 ['', '--coverage', 'Enable test coverage'],
104 ['', '--coverage-file STRING', 'A file where the coverage result is stored. Only has an effect if json coverage reporter is used'],
105 ['', '--coverage-files STRING', 'A comma-separated list of files containing coverage data'],
106 ['', '--coverage-reporter STRING', 'Coverage reporter type (cli, html)'],
107 ['', '--coverage-dir STRING', 'Directory where the HTML coverage report is saved'],
108 ['', '--coverage-encoding STRING', 'Encoding which jscoverage will use when parsing files which are instrumented'],
109 ['', '--coverage-exclude STRING', 'Paths which won\'t be instrumented'],
110 ['', '--coverage-no-instrument STRING', 'Copy but don\'t instrument the path'],
111 ['', '--coverage-no-regen', 'Don\'t generate coverage file if lib-cov directory already exists'],
112
113 ['', '--scope-leaks', 'Records which variables were leaked into the global ' +
114 'scope.'],
115 ['', '--scope-leaks-reporter STRING', 'Scope leaks reporter type (cli)'],
116 ['-d', '--debug', 'Attach a debugger to a test process'],
117 ['', '--gen-makefile', 'Genarate a Makefile'],
118 ['', '--makefile-path STRING', 'Path where a generated Makefile is saved'],
119 ['', '--report-timing', 'Report test timing'],
120 ['', '--dependencies STRING', 'Path to the test dependencies configuration file'],
121 ['', '--only-essential-dependencies', 'Only start dependencies required by the tests files which are ran']
122];
123
124/**
125 * Other options for the Process runner option parser.
126 */
127var PROCESS_RUNNER_OPTIONS = [
128 ['-c', '--config STRING', 'Path to the dependencies.json file'],
129 ['-v', '--verify', 'Verify the config'],
130 ['-r', '--run', 'Run the processes'],
131 ['-n', '--names STRING', 'Comma-delimited string of the processes to run. Only applicable' +
132 ' if --run is used']
133];
134
135exports.DEFAULT_TEST_TIMEOUT = DEFAULT_TEST_TIMEOUT;
136exports.DEFAULT_CONCURRENCY = DEFAULT_CONCURRENCY;
137exports.DEFAULT_TEST_REPORTER = DEFAULT_TEST_REPORTER;
138exports.DEFAULT_COVERAGE_REPORTER = DEFAULT_COVERAGE_REPORTER;
139exports.DEFAULT_SCOPE_LEAKS_REPORTER = DEFAULT_SCOPE_LEAKS_REPORTER;
140
141exports.VERSION = VERSION;
142exports.COVERAGE_PATH = COVERAGE_PATH;
143exports.DEFAULT_VERBOSITY = DEFAULT_VERBOSITY;
144exports.INIT_FUNCTION_NAME = INIT_FUNCTION_NAME;
145exports.SETUP_FUNCTION_NAME = SETUP_FUNCTION_NAME;
146exports.TEARDOWN_FUNCTION_NAME = TEARDOWN_FUNCTION_NAME;
147exports.DEFAULT_SOCKET_PATH = DEFAULT_SOCKET_PATH;
148exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
149exports.WHISKEY_OPTIONS = WHISKEY_OPTIONS;
150exports.PROCESS_RUNNER_OPTIONS = PROCESS_RUNNER_OPTIONS;
151
152exports.TEST_START_MARKER = TEST_START_MARKER;
153exports.DELIMITER = DELIMITER;
154exports.TEST_END_MARKER = TEST_END_MARKER;
155exports.TEST_FILE_END_MARKER = TEST_FILE_END_MARKER;
156exports.COVERAGE_END_MARKER = COVERAGE_END_MARKER;