41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/test_bench/cli/parse_arguments.rb', line 41
def option_parser
@option_parser ||= OptionParser.new do |parser|
parser.banner = "Usage: #{self.class.program_name} [options] [paths]"
parser.separator('')
parser.separator("Informational Options")
parser.on('-h', '--help', "Print this help message and exit successfully") do
output_device.puts(parser.help)
raise SystemExit.new(0)
end
parser.on('-V', '--version', "Print version and exit successfully") do
output_device.puts <<TEXT
test-bench (#{self.class.program_name}) version #{self.class.version}
TEXT
raise SystemExit.new(0)
end
parser.separator('')
parser.separator("Configuration Options")
parser.on('-a', '--[no-]abort-on-error', %{Exit immediately after any test failure or error (Default: #{TestBench::Defaults.abort_on_error ? 'on' : 'off'})}) do |abort_on_error|
env['TEST_BENCH_ABORT_ON_ERROR'] = abort_on_error ? 'on' : 'off'
end
parser.on('-d', '--[no-]detail [DETAIL]', %{Always show (or hide) details (Default: #{Output::Raw::Defaults.detail})}) do |detail|
if detail.nil?
detail = 'on'
elsif detail == true
detail = 'on'
elsif detail == false
detail = 'off'
end
env['TEST_BENCH_DETAIL'] = detail
end
parser.on('-x', '--[no-]exclude PATTERN', %{Do not execute test files matching PATTERN (Default: #{Run::Defaults.exclude_pattern.inspect})}) do |pattern_text|
if pattern_text == false
pattern_text = self.none_pattern
end
assure_pattern(pattern_text)
env['TEST_BENCH_EXCLUDE_FILE_PATTERN'] = pattern_text
end
parser.on('-l', '--log-level LEVEL', %{Set the internal logging level to LEVEL (Default: #{Output::Log::Defaults.level})}) do |level_text|
level = level_text.to_sym
Fixture::Output::Log.assure_level(level)
env['TEST_BENCH_LOG_LEVEL'] = level_text
end
parser.on('-o', '--[no-]omit-backtrace PATTERN', %{Omit backtrace frames matching PATTERN (Default: #{Output::PrintError::Defaults.omit_backtrace_pattern.inspect})}) do |pattern_text|
if pattern_text == false
pattern_text = self.none_pattern
end
assure_pattern(pattern_text)
env['TEST_BENCH_OMIT_BACKTRACE_PATTERN'] = pattern_text
end
parser.on('-s', '--output-styling [on|off|detect]', %{Render output coloring and font styling escape codes (Default: #{Output::Writer::Defaults.styling})}) do |styling_text|
styling_text ||= 'on'
styling = styling_text.to_sym
Output::Writer.assure_styling_setting(styling)
env['TEST_BENCH_OUTPUT_STYLING'] = styling_text
end
parser.on('-p', '--[no-]permit-deactivated-tests', %{Do not fail the test run if there are deactivated tests or contexts, e.g. _test or _context (Default: #{!TestBench::Defaults.fail_deactivated_tests ? 'on' : 'off'})}) do |permit_deactivated_tests|
env['TEST_BENCH_FAIL_DEACTIVATED_TESTS'] = !permit_deactivated_tests ? 'on' : 'off'
end
parser.on('-r', '--[no-]reverse-backtraces', %{Reverse order of backtraces when printing errors (Default: #{Output::PrintError::Defaults.reverse_backtraces ? 'on' : 'off'})}) do |reverse_backtraces|
env['TEST_BENCH_REVERSE_BACKTRACES'] = reverse_backtraces ? 'on' : 'off'
end
parser.on('-v', '--[no-]verbose', %{Increase output verbosity (Default: #{Output::Raw::Defaults.verbose ? 'on' : 'off'})}) do |verbose|
env['TEST_BENCH_VERBOSE'] = verbose ? 'on' : 'off'
end
parser.separator(<<TEXT)
Paths to test files (and directories containing test files) can be given after any command line arguments or via STDIN (or both).
If no paths are given, a default path (#{Defaults.tests_directory}) is scanned for test files.
The following environment variables can also control execution:
#{parser.summary_indent}TEST_BENCH_ABORT_ON_ERROR Same as -a or --abort-on-error
#{parser.summary_indent}TEST_BENCH_DETAIL Same as -d or --detail
#{parser.summary_indent}TEST_BENCH_EXCLUDE_FILE_PATTERN Same as -x or --exclude-file-pattern
#{parser.summary_indent}TEST_BENCH_LOG_LEVEL Same as -l or --log-level
#{parser.summary_indent}TEST_BENCH_OMIT_BACKTRACE_PATTERN Same as -o or --omit-backtrace-pattern
#{parser.summary_indent}TEST_BENCH_OUTPUT_STYLING Same as -s or --output-styling
#{parser.summary_indent}TEST_BENCH_FAIL_DEACTIVATED_TESTS Opposite of -p or --permit-deactivated-tests
#{parser.summary_indent}TEST_BENCH_REVERSE_BACKTRACES Same as -r or --reverse-backtraces
#{parser.summary_indent}TEST_BENCH_VERBOSE Same as -v or --reverse-backtraces
TEXT
end
end
|