aruba 1.0.0.pre.alpha.2 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/PULL_REQUEST_TEMPLATE.md +2 -1
- data/.rspec +0 -1
- data/.rubocop.yml +46 -182
- data/.rubocop_todo.yml +216 -0
- data/.simplecov +7 -5
- data/.travis.yml +56 -40
- data/.yardopts +3 -0
- data/CHANGELOG.md +1312 -0
- data/CONTRIBUTING.md +175 -83
- data/Gemfile +5 -69
- data/LICENSE +1 -1
- data/README.md +58 -21
- data/Rakefile +27 -54
- data/appveyor.yml +7 -10
- data/aruba.gemspec +38 -19
- data/bin/console +3 -12
- data/cucumber.yml +4 -22
- data/exe/aruba +1 -1
- data/fixtures/cli-app/README.md +1 -1
- data/fixtures/cli-app/Rakefile +1 -1
- data/fixtures/cli-app/bin/aruba-test-cli +1 -1
- data/fixtures/cli-app/cli-app.gemspec +4 -4
- data/fixtures/cli-app/lib/cli/app.rb +1 -1
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
- data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
- data/fixtures/cli-app/spec/spec_helper.rb +3 -2
- data/fixtures/empty-app/Rakefile +1 -1
- data/fixtures/empty-app/cli-app.gemspec +4 -4
- data/fixtures/empty-app/lib/cli/app.rb +0 -2
- data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
- data/fixtures/getting-started-app/Gemfile +1 -1
- data/lib/aruba/api.rb +8 -15
- data/lib/aruba/api/bundler.rb +16 -0
- data/lib/aruba/api/commands.rb +272 -0
- data/lib/aruba/api/core.rb +82 -43
- data/lib/aruba/api/environment.rb +24 -7
- data/lib/aruba/api/filesystem.rb +66 -64
- data/lib/aruba/api/text.rb +17 -11
- data/lib/aruba/aruba_path.rb +25 -111
- data/lib/aruba/basic_configuration.rb +8 -25
- data/lib/aruba/basic_configuration/option.rb +2 -2
- data/lib/aruba/cli.rb +4 -1
- data/lib/aruba/colorizer.rb +10 -99
- data/lib/aruba/command.rb +4 -0
- data/lib/aruba/config/jruby.rb +15 -5
- data/lib/aruba/config_wrapper.rb +17 -2
- data/lib/aruba/configuration.rb +107 -0
- data/lib/aruba/console.rb +5 -7
- data/lib/aruba/console/help.rb +5 -2
- data/lib/aruba/contracts/absolute_path.rb +3 -3
- data/lib/aruba/contracts/is_power_of_two.rb +2 -2
- data/lib/aruba/contracts/relative_path.rb +3 -3
- data/lib/aruba/cucumber.rb +0 -3
- data/lib/aruba/cucumber/command.rb +227 -190
- data/lib/aruba/cucumber/environment.rb +1 -1
- data/lib/aruba/cucumber/file.rb +56 -50
- data/lib/aruba/cucumber/hooks.rb +10 -63
- data/lib/aruba/cucumber/testing_frameworks.rb +76 -50
- data/lib/aruba/event_bus.rb +4 -2
- data/lib/aruba/event_bus/name_resolver.rb +10 -10
- data/lib/aruba/events.rb +2 -1
- data/lib/aruba/hooks.rb +3 -5
- data/lib/aruba/in_config_wrapper.rb +10 -3
- data/lib/aruba/initializer.rb +40 -34
- data/lib/aruba/matchers/base/base_matcher.rb +2 -11
- data/lib/aruba/matchers/base/message_indenter.rb +19 -0
- data/lib/aruba/matchers/base/object_formatter.rb +2 -7
- data/lib/aruba/matchers/collection/include_an_object.rb +11 -13
- data/lib/aruba/matchers/command/be_successfully_executed.rb +8 -4
- data/lib/aruba/matchers/command/have_exit_status.rb +16 -4
- data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
- data/lib/aruba/matchers/command/have_output.rb +12 -5
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +4 -2
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +4 -2
- data/lib/aruba/matchers/command/have_output_size.rb +2 -2
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
- data/lib/aruba/matchers/directory/have_sub_directory.rb +10 -7
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
- data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
- data/lib/aruba/matchers/file/have_file_content.rb +4 -4
- data/lib/aruba/matchers/file/have_file_size.rb +8 -8
- data/lib/aruba/matchers/file/have_same_file_content.rb +9 -12
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
- data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
- data/lib/aruba/matchers/path/have_permissions.rb +8 -8
- data/lib/aruba/matchers/string/include_output_string.rb +8 -10
- data/lib/aruba/matchers/string/match_output_string.rb +9 -11
- data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
- data/lib/aruba/platform.rb +0 -8
- data/lib/aruba/platforms/announcer.rb +60 -85
- data/lib/aruba/platforms/aruba_file_creator.rb +4 -2
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +8 -3
- data/lib/aruba/platforms/aruba_logger.rb +22 -2
- data/lib/aruba/platforms/command_monitor.rb +15 -102
- data/lib/aruba/platforms/determine_disk_usage.rb +56 -19
- data/lib/aruba/platforms/filesystem_status.rb +9 -9
- data/lib/aruba/platforms/local_environment.rb +2 -2
- data/lib/aruba/platforms/simple_table.rb +3 -11
- data/lib/aruba/platforms/unix_command_string.rb +7 -4
- data/lib/aruba/platforms/unix_environment_variables.rb +19 -26
- data/lib/aruba/platforms/unix_platform.rb +18 -39
- data/lib/aruba/platforms/unix_which.rb +3 -2
- data/lib/aruba/platforms/windows_command_string.rb +20 -7
- data/lib/aruba/platforms/windows_environment_variables.rb +42 -30
- data/lib/aruba/platforms/windows_platform.rb +4 -0
- data/lib/aruba/platforms/windows_which.rb +9 -4
- data/lib/aruba/processes/basic_process.rb +21 -27
- data/lib/aruba/processes/debug_process.rb +16 -5
- data/lib/aruba/processes/in_process.rb +20 -9
- data/lib/aruba/processes/spawn_process.rb +64 -36
- data/lib/aruba/rspec.rb +28 -31
- data/lib/aruba/runtime.rb +16 -7
- data/lib/aruba/setup.rb +32 -17
- data/lib/aruba/tasks/docker_helpers.rb +4 -2
- data/lib/aruba/version.rb +1 -1
- metadata +194 -64
- data/History.md +0 -612
- data/bin/bootstrap +0 -34
- data/bin/build +0 -3
- data/bin/release +0 -3
- data/fixtures/spawn_process/stderr.sh +0 -3
- data/lib/aruba/api/command.rb +0 -309
- data/lib/aruba/api/deprecated.rb +0 -895
- data/lib/aruba/api/rvm.rb +0 -44
- data/lib/aruba/config.rb +0 -101
- data/lib/aruba/cucumber/rvm.rb +0 -3
- data/lib/aruba/in_process.rb +0 -14
- data/lib/aruba/jruby.rb +0 -4
- data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
- data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
- data/lib/aruba/spawn_process.rb +0 -11
data/lib/aruba/console/help.rb
CHANGED
@@ -10,7 +10,8 @@ module Aruba
|
|
10
10
|
def aruba_help
|
11
11
|
puts 'Aruba Version: ' + Aruba::VERSION
|
12
12
|
puts 'Issue Tracker: ' + 'https://github.com/cucumber/aruba/issues'
|
13
|
-
puts
|
13
|
+
puts 'Documentation:'
|
14
|
+
puts '* http://www.rubydoc.info/gems/aruba'
|
14
15
|
puts
|
15
16
|
|
16
17
|
nil
|
@@ -18,7 +19,9 @@ module Aruba
|
|
18
19
|
|
19
20
|
# List available methods in aruba
|
20
21
|
def aruba_methods
|
21
|
-
ms = (Aruba::Api.instance_methods - Module.instance_methods)
|
22
|
+
ms = (Aruba::Api.instance_methods - Module.instance_methods)
|
23
|
+
.each_with_object([]) { |e, a| a << format('* %s', e) }
|
24
|
+
.sort
|
22
25
|
|
23
26
|
puts "Available Methods:\n" + ms.join("\n")
|
24
27
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'aruba/
|
1
|
+
require 'aruba/platform'
|
2
2
|
|
3
3
|
# Aruba
|
4
4
|
module Aruba
|
@@ -11,8 +11,8 @@ module Aruba
|
|
11
11
|
# @param [Object] value
|
12
12
|
# The value to be checked
|
13
13
|
def self.valid?(value)
|
14
|
-
|
15
|
-
rescue
|
14
|
+
Aruba.platform.absolute_path? value
|
15
|
+
rescue StandardError
|
16
16
|
false
|
17
17
|
end
|
18
18
|
end
|
@@ -13,8 +13,8 @@ module Aruba
|
|
13
13
|
def self.valid?(value)
|
14
14
|
# explanation for algorithm can be found here:
|
15
15
|
# http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/
|
16
|
-
value
|
17
|
-
rescue
|
16
|
+
value.positive? && (value & (value - 1)).zero?
|
17
|
+
rescue StandardError
|
18
18
|
false
|
19
19
|
end
|
20
20
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'aruba/
|
1
|
+
require 'aruba/platform'
|
2
2
|
|
3
3
|
# Aruba
|
4
4
|
module Aruba
|
@@ -11,8 +11,8 @@ module Aruba
|
|
11
11
|
# @param [String] value
|
12
12
|
# The path to be checked
|
13
13
|
def self.valid?(value)
|
14
|
-
|
15
|
-
rescue
|
14
|
+
Aruba.platform.relative_path? value
|
15
|
+
rescue StandardError
|
16
16
|
false
|
17
17
|
end
|
18
18
|
end
|
data/lib/aruba/cucumber.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
require 'aruba/version'
|
2
2
|
|
3
3
|
require 'aruba/api'
|
4
|
-
World(Aruba::Api)
|
5
|
-
|
6
4
|
require 'aruba/cucumber/hooks'
|
7
5
|
require 'aruba/cucumber/command'
|
8
6
|
require 'aruba/cucumber/environment'
|
9
7
|
require 'aruba/cucumber/file'
|
10
8
|
require 'aruba/cucumber/testing_frameworks'
|
11
|
-
require 'aruba/cucumber/rvm'
|
@@ -1,55 +1,34 @@
|
|
1
1
|
require 'aruba/generators/script_file'
|
2
2
|
|
3
|
-
When(/^I run
|
4
|
-
warn(%{\e[35m The /^I run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
|
5
|
-
|
3
|
+
When(/^I run `([^`]*)`$/) do |cmd|
|
6
4
|
cmd = sanitize_text(cmd)
|
7
|
-
run_command_and_stop(cmd, false)
|
8
|
-
end
|
9
|
-
|
10
|
-
When(/^I run `([^`]*)`$/)do |cmd|
|
11
|
-
cmd = sanitize_text(cmd)
|
12
|
-
run_command_and_stop(cmd, :fail_on_error => false)
|
13
|
-
end
|
14
|
-
|
15
|
-
When(/^I successfully run "(.*)"$/)do |cmd|
|
16
|
-
warn(%{\e[35m The /^I successfully run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
|
17
|
-
|
18
|
-
cmd = sanitize_text(cmd)
|
19
|
-
run_command_and_stop(cmd)
|
5
|
+
run_command_and_stop(cmd, fail_on_error: false)
|
20
6
|
end
|
21
7
|
|
22
8
|
## I successfully run `echo -n "Hello"`
|
23
9
|
## I successfully run `sleep 29` for up to 30 seconds
|
24
|
-
When(/^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/)do |cmd, secs|
|
10
|
+
When(/^I successfully run `(.*?)`(?: for up to ([\d.]+) seconds)?$/) do |cmd, secs|
|
25
11
|
cmd = sanitize_text(cmd)
|
26
|
-
run_command_and_stop(cmd, :
|
12
|
+
run_command_and_stop(cmd, fail_on_error: true, exit_timeout: secs && secs.to_f)
|
27
13
|
end
|
28
14
|
|
29
|
-
When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/)
|
30
|
-
|
15
|
+
When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) \
|
16
|
+
do |shell, commands|
|
17
|
+
full_path = expand_path('bin/myscript')
|
31
18
|
|
32
19
|
Aruba.platform.mkdir(expand_path('bin'))
|
33
20
|
shell ||= Aruba.platform.default_shell
|
34
21
|
|
35
|
-
Aruba::ScriptFile.new(:
|
36
|
-
|
37
|
-
step 'I run `myscript`'
|
38
|
-
end
|
39
|
-
|
40
|
-
When(/^I run "([^"]*)" interactively$/) do |cmd|
|
41
|
-
Aruba.platform.deprecated(%{\e[35m The /^I run "([^"]*)" interactively$/ step definition is deprecated. Please use the `backticks` version\e[0m})
|
42
|
-
|
43
|
-
step %(I run `#{cmd}` interactively)
|
22
|
+
Aruba::ScriptFile.new(interpreter: shell, content: commands, path: full_path).call
|
23
|
+
run_command_and_stop(Shellwords.escape(full_path), fail_on_error: false)
|
44
24
|
end
|
45
25
|
|
46
|
-
When(/^I run `([^`]*)` interactively$/)do |cmd|
|
47
|
-
|
48
|
-
@interactive = run_command(cmd)
|
26
|
+
When(/^I run `([^`]*)` interactively$/) do |cmd|
|
27
|
+
run_command(sanitize_text(cmd))
|
49
28
|
end
|
50
29
|
|
51
30
|
# Merge interactive and background after refactoring with event queue
|
52
|
-
When(/^I run `([^`]*)` in background$/)do |cmd|
|
31
|
+
When(/^I run `([^`]*)` in background$/) do |cmd|
|
53
32
|
run_command(sanitize_text(cmd))
|
54
33
|
end
|
55
34
|
|
@@ -68,35 +47,27 @@ When(/^I pipe in (?:a|the) file(?: named)? "([^"]*)"$/) do |file|
|
|
68
47
|
end
|
69
48
|
|
70
49
|
When(/^I (terminate|stop) the command (?:"([^"]*)"|(?:started last))$/) do |signal, command|
|
71
|
-
|
72
|
-
cmd = all_commands.find { |c| c.commandline == command }
|
73
|
-
fail ArgumentError, %(No command "#{command}" found) if cmd.nil?
|
50
|
+
monitor = aruba.command_monitor
|
74
51
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
52
|
+
cmd = if command
|
53
|
+
monitor.find(command)
|
54
|
+
else
|
55
|
+
last_command_started
|
56
|
+
end
|
57
|
+
|
58
|
+
if signal == 'terminate'
|
59
|
+
cmd.terminate
|
82
60
|
else
|
83
|
-
|
84
|
-
# last_command_started.terminate
|
85
|
-
process_monitor.terminate_process!(last_command_started)
|
86
|
-
else
|
87
|
-
# last_command_started.stop
|
88
|
-
process_monitor.stop_process(last_command_started)
|
89
|
-
end
|
61
|
+
cmd.stop
|
90
62
|
end
|
91
63
|
end
|
92
64
|
|
93
|
-
When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/)
|
94
|
-
|
95
|
-
|
65
|
+
When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/) \
|
66
|
+
do |channel, expected|
|
96
67
|
begin
|
97
68
|
Timeout.timeout(aruba.config.exit_timeout) do
|
98
69
|
loop do
|
99
|
-
output = last_command_started.public_send channel.to_sym, :
|
70
|
+
output = last_command_started.public_send channel.to_sym, wait_for_io: 0
|
100
71
|
|
101
72
|
output = sanitize_text(output)
|
102
73
|
expected = sanitize_text(expected)
|
@@ -110,7 +81,7 @@ When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$
|
|
110
81
|
sleep 0.1
|
111
82
|
end
|
112
83
|
end
|
113
|
-
rescue ChildProcess::TimeoutError,
|
84
|
+
rescue ChildProcess::TimeoutError, Timeout::Error
|
114
85
|
last_command_started.terminate
|
115
86
|
end
|
116
87
|
end
|
@@ -146,24 +117,13 @@ When(/^I wait for (?:output|stdout) to contain "([^"]*)"$/) do |expected|
|
|
146
117
|
end
|
147
118
|
|
148
119
|
Then(/^the output should be (\d+) bytes long$/) do |size|
|
149
|
-
expect(
|
120
|
+
expect(last_command_started.output).to have_output_size size.to_i
|
150
121
|
end
|
151
122
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
when :stderr
|
157
|
-
:have_output_on_stderr
|
158
|
-
when :stdout
|
159
|
-
:have_output_on_stdout
|
160
|
-
end
|
161
|
-
|
162
|
-
commands = if cmd
|
163
|
-
[aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
|
164
|
-
else
|
165
|
-
all_commands
|
166
|
-
end
|
123
|
+
## the stderr should contain "hello"
|
124
|
+
Then(/^(?:the )?(output|stderr|stdout) should( not)? contain( exactly)? "([^"]*)"$/) \
|
125
|
+
do |channel, negated, exactly, expected|
|
126
|
+
combined_output = send("all_#{channel}")
|
167
127
|
|
168
128
|
output_string_matcher = if exactly
|
169
129
|
:an_output_string_being_eq
|
@@ -171,47 +131,93 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
|
|
171
131
|
:an_output_string_including
|
172
132
|
end
|
173
133
|
|
174
|
-
if
|
175
|
-
combined_output
|
176
|
-
c.stop
|
177
|
-
c.send(channel.to_sym).chomp
|
178
|
-
end.join("\n")
|
179
|
-
|
180
|
-
if negated
|
181
|
-
expect(combined_output).not_to send(output_string_matcher, expected)
|
182
|
-
else
|
183
|
-
expect(combined_output).to send(output_string_matcher, expected)
|
184
|
-
end
|
134
|
+
if negated
|
135
|
+
expect(combined_output).not_to send(output_string_matcher, expected)
|
185
136
|
else
|
186
|
-
|
187
|
-
expect(commands).not_to include_an_object send(matcher, send(output_string_matcher, expected))
|
188
|
-
else
|
189
|
-
expect(commands).to include_an_object send(matcher, send(output_string_matcher, expected))
|
190
|
-
end
|
137
|
+
expect(combined_output).to send(output_string_matcher, expected)
|
191
138
|
end
|
192
139
|
end
|
193
140
|
|
194
|
-
## the stderr should contain "hello"
|
195
141
|
## the stderr from "echo -n 'Hello'" should contain "hello"
|
142
|
+
Then(
|
143
|
+
/^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)? "([^"]*)"$/
|
144
|
+
) do |channel, cmd, exactly, expected|
|
145
|
+
matcher = case channel
|
146
|
+
when 'output'; then :have_output
|
147
|
+
when 'stderr'; then :have_output_on_stderr
|
148
|
+
when 'stdout'; then :have_output_on_stdout
|
149
|
+
end
|
150
|
+
|
151
|
+
command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
|
152
|
+
|
153
|
+
output_string_matcher = if exactly
|
154
|
+
:an_output_string_being_eq
|
155
|
+
else
|
156
|
+
:an_output_string_including
|
157
|
+
end
|
158
|
+
|
159
|
+
expect(command).to send(matcher, send(output_string_matcher, expected))
|
160
|
+
end
|
161
|
+
|
162
|
+
## the stderr from "echo -n 'Hello'" should not contain "hello"
|
163
|
+
Then(
|
164
|
+
/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)? "([^"]*)"$/
|
165
|
+
) do |channel, cmd, exactly, expected|
|
166
|
+
matcher = case channel
|
167
|
+
when 'output'; then :have_output
|
168
|
+
when 'stderr'; then :have_output_on_stderr
|
169
|
+
when 'stdout'; then :have_output_on_stdout
|
170
|
+
end
|
171
|
+
|
172
|
+
command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
|
173
|
+
|
174
|
+
output_string_matcher = if exactly
|
175
|
+
:an_output_string_being_eq
|
176
|
+
else
|
177
|
+
:an_output_string_including
|
178
|
+
end
|
179
|
+
|
180
|
+
expect(command).not_to send(matcher, send(output_string_matcher, expected))
|
181
|
+
end
|
182
|
+
|
183
|
+
## the stderr should not contain exactly:
|
184
|
+
Then(/^(?:the )?(output|stderr|stdout) should not contain( exactly)?:$/) \
|
185
|
+
do |channel, exactly, expected|
|
186
|
+
combined_output = send("all_#{channel}")
|
187
|
+
|
188
|
+
output_string_matcher = if exactly
|
189
|
+
:an_output_string_being_eq
|
190
|
+
else
|
191
|
+
:an_output_string_including
|
192
|
+
end
|
193
|
+
|
194
|
+
expect(combined_output).not_to send(output_string_matcher, expected)
|
195
|
+
end
|
196
|
+
|
196
197
|
## the stderr should contain exactly:
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
198
|
+
Then(/^(?:the )?(output|stderr|stdout) should contain( exactly)?:$/) \
|
199
|
+
do |channel, exactly, expected|
|
200
|
+
combined_output = send("all_#{channel}")
|
201
|
+
|
202
|
+
output_string_matcher = if exactly
|
203
|
+
:an_output_string_being_eq
|
204
|
+
else
|
205
|
+
:an_output_string_including
|
206
|
+
end
|
207
|
+
|
208
|
+
expect(combined_output).to send(output_string_matcher, expected)
|
209
|
+
end
|
210
|
+
|
211
|
+
## the stderr from "echo -n 'Hello'" should not contain exactly:
|
212
|
+
Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)?:$/) \
|
213
|
+
do |channel, cmd, exactly, expected|
|
214
|
+
matcher = case channel
|
215
|
+
when 'output'; then :have_output
|
216
|
+
when 'stderr'; then :have_output_on_stderr
|
217
|
+
when 'stdout'; then :have_output_on_stdout
|
208
218
|
end
|
209
219
|
|
210
|
-
|
211
|
-
[aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
|
212
|
-
else
|
213
|
-
all_commands
|
214
|
-
end
|
220
|
+
command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
|
215
221
|
|
216
222
|
output_string_matcher = if exactly
|
217
223
|
:an_output_string_being_eq
|
@@ -219,55 +225,66 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
|
|
219
225
|
:an_output_string_including
|
220
226
|
end
|
221
227
|
|
222
|
-
|
223
|
-
|
224
|
-
c.stop
|
225
|
-
c.send(channel.to_sym).chomp
|
226
|
-
end.join("\n")
|
228
|
+
expect(command).not_to send(matcher, send(output_string_matcher, expected))
|
229
|
+
end
|
227
230
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
231
|
+
## the stderr from "echo -n 'Hello'" should contain exactly:
|
232
|
+
Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)?:$/) \
|
233
|
+
do |channel, cmd, exactly, expected|
|
234
|
+
matcher = case channel
|
235
|
+
when 'output'; then :have_output
|
236
|
+
when 'stderr'; then :have_output_on_stderr
|
237
|
+
when 'stdout'; then :have_output_on_stdout
|
238
|
+
end
|
239
|
+
|
240
|
+
command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
|
241
|
+
|
242
|
+
output_string_matcher = if exactly
|
243
|
+
:an_output_string_being_eq
|
244
|
+
else
|
245
|
+
:an_output_string_including
|
246
|
+
end
|
247
|
+
|
248
|
+
expect(command).to send(matcher, send(output_string_matcher, expected))
|
240
249
|
end
|
241
250
|
|
242
251
|
# "the output should match" allows regex in the partial_output, if
|
243
252
|
# you don't need regex, use "the output should contain" instead since
|
244
253
|
# that way, you don't have to escape regex characters that
|
245
254
|
# appear naturally in the output
|
246
|
-
Then(
|
255
|
+
Then(%r{^the output should( not)? match /([^/]*)/$}) do |negated, expected|
|
247
256
|
if negated
|
248
|
-
expect(all_commands)
|
257
|
+
expect(all_commands)
|
258
|
+
.not_to include_an_object have_output an_output_string_matching(expected)
|
249
259
|
else
|
250
|
-
expect(all_commands)
|
260
|
+
expect(all_commands)
|
261
|
+
.to include_an_object have_output an_output_string_matching(expected)
|
251
262
|
end
|
252
263
|
end
|
253
264
|
|
254
265
|
Then(/^the output should( not)? match %r<([^>]*)>$/) do |negated, expected|
|
255
266
|
if negated
|
256
|
-
expect(all_commands)
|
267
|
+
expect(all_commands)
|
268
|
+
.not_to include_an_object have_output an_output_string_matching(expected)
|
257
269
|
else
|
258
|
-
expect(all_commands)
|
270
|
+
expect(all_commands)
|
271
|
+
.to include_an_object have_output an_output_string_matching(expected)
|
259
272
|
end
|
260
273
|
end
|
261
274
|
|
262
275
|
Then(/^the output should( not)? match:$/) do |negated, expected|
|
263
276
|
if negated
|
264
|
-
expect(all_commands)
|
277
|
+
expect(all_commands)
|
278
|
+
.not_to include_an_object have_output an_output_string_matching(expected)
|
265
279
|
else
|
266
|
-
expect(all_commands)
|
280
|
+
expect(all_commands)
|
281
|
+
.to include_an_object have_output an_output_string_matching(expected)
|
267
282
|
end
|
268
283
|
end
|
269
284
|
|
270
285
|
Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
|
286
|
+
last_command_started.stop if last_command_stopped.nil?
|
287
|
+
|
271
288
|
if negated
|
272
289
|
expect(last_command_stopped).not_to have_exit_status exit_status.to_i
|
273
290
|
else
|
@@ -275,134 +292,154 @@ Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
|
|
275
292
|
end
|
276
293
|
end
|
277
294
|
|
278
|
-
Then(/^it should
|
295
|
+
Then(/^it should not (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
|
296
|
+
last_command_started.stop
|
297
|
+
|
279
298
|
if pass_fail == 'pass'
|
280
299
|
expect(last_command_stopped).to be_successfully_executed
|
281
300
|
else
|
282
301
|
expect(last_command_stopped).not_to be_successfully_executed
|
283
302
|
end
|
284
303
|
|
285
|
-
|
286
|
-
|
304
|
+
expect(last_command_stopped).not_to have_output an_output_string_including(expected)
|
305
|
+
end
|
306
|
+
|
307
|
+
Then(/^it should (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
|
308
|
+
last_command_started.stop
|
309
|
+
|
310
|
+
if pass_fail == 'pass'
|
311
|
+
expect(last_command_stopped).to be_successfully_executed
|
287
312
|
else
|
288
|
-
expect(last_command_stopped).
|
313
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
289
314
|
end
|
315
|
+
|
316
|
+
expect(last_command_stopped).to have_output an_output_string_including(expected)
|
290
317
|
end
|
291
318
|
|
292
|
-
Then(/^it should
|
319
|
+
Then(/^it should not (pass|fail) with:$/) do |pass_fail, expected|
|
320
|
+
last_command_started.stop
|
321
|
+
|
293
322
|
if pass_fail == 'pass'
|
294
323
|
expect(last_command_stopped).to be_successfully_executed
|
295
324
|
else
|
296
325
|
expect(last_command_stopped).not_to be_successfully_executed
|
297
326
|
end
|
298
327
|
|
299
|
-
|
300
|
-
|
328
|
+
expect(last_command_stopped).not_to have_output an_output_string_including(expected)
|
329
|
+
end
|
330
|
+
|
331
|
+
Then(/^it should (pass|fail) with:$/) do |pass_fail, expected|
|
332
|
+
last_command_started.stop
|
333
|
+
|
334
|
+
if pass_fail == 'pass'
|
335
|
+
expect(last_command_stopped).to be_successfully_executed
|
301
336
|
else
|
302
|
-
expect(last_command_stopped).
|
337
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
303
338
|
end
|
339
|
+
|
340
|
+
expect(last_command_stopped).to have_output an_output_string_including(expected)
|
304
341
|
end
|
305
342
|
|
306
|
-
Then(/^it should
|
343
|
+
Then(/^it should not (pass|fail) with exactly:$/) do |pass_fail, expected|
|
344
|
+
last_command_started.stop
|
345
|
+
|
307
346
|
if pass_fail == 'pass'
|
308
347
|
expect(last_command_stopped).to be_successfully_executed
|
309
348
|
else
|
310
349
|
expect(last_command_stopped).not_to be_successfully_executed
|
311
350
|
end
|
312
351
|
|
313
|
-
|
314
|
-
|
352
|
+
expect(last_command_stopped).not_to have_output an_output_string_eq(expected)
|
353
|
+
end
|
354
|
+
|
355
|
+
Then(/^it should (pass|fail) with exactly:$/) do |pass_fail, expected|
|
356
|
+
last_command_started.stop
|
357
|
+
|
358
|
+
if pass_fail == 'pass'
|
359
|
+
expect(last_command_stopped).to be_successfully_executed
|
315
360
|
else
|
316
|
-
expect(last_command_stopped).
|
361
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
317
362
|
end
|
363
|
+
|
364
|
+
expect(last_command_stopped).to have_output an_output_string_being_eq(expected)
|
318
365
|
end
|
319
366
|
|
320
|
-
Then(/^it should
|
367
|
+
Then(/^it should not (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
|
368
|
+
last_command_started.stop
|
369
|
+
|
321
370
|
if pass_fail == 'pass'
|
322
371
|
expect(last_command_stopped).to be_successfully_executed
|
323
372
|
else
|
324
373
|
expect(last_command_stopped).not_to be_successfully_executed
|
325
374
|
end
|
326
375
|
|
327
|
-
|
328
|
-
|
376
|
+
expect(last_command_stopped).not_to have_output an_output_string_matching(expected)
|
377
|
+
end
|
378
|
+
|
379
|
+
Then(/^it should (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
|
380
|
+
last_command_started.stop
|
381
|
+
|
382
|
+
if pass_fail == 'pass'
|
383
|
+
expect(last_command_stopped).to be_successfully_executed
|
329
384
|
else
|
330
|
-
expect(last_command_stopped).
|
385
|
+
expect(last_command_stopped).not_to be_successfully_executed
|
331
386
|
end
|
387
|
+
|
388
|
+
expect(last_command_stopped).to have_output an_output_string_matching(expected)
|
332
389
|
end
|
333
390
|
|
334
391
|
Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel|
|
335
|
-
matcher = case channel
|
336
|
-
when :
|
337
|
-
|
338
|
-
when :
|
339
|
-
:have_output_on_stderr
|
340
|
-
when :stdout
|
341
|
-
:have_output_on_stdout
|
342
|
-
else
|
343
|
-
fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
|
392
|
+
matcher = case channel
|
393
|
+
when 'output'; then :have_output
|
394
|
+
when 'stderr'; then :have_output_on_stderr
|
395
|
+
when 'stdout'; then :have_output_on_stdout
|
344
396
|
end
|
345
397
|
|
346
398
|
expect(all_commands).to include_an_object send(matcher, be_nil.or(be_empty))
|
347
399
|
end
|
348
400
|
|
349
|
-
Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/)
|
401
|
+
Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) \
|
402
|
+
do |channel, negated, table|
|
350
403
|
table.raw.flatten.each do |expected|
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
else
|
359
|
-
fail ArgumentError, %(Invalid channel "#{channel}" chosen. Only "output", "stdout" and "stderr" are supported.)
|
360
|
-
end
|
404
|
+
_matcher = case channel
|
405
|
+
when 'output'; then :have_output
|
406
|
+
when 'stderr'; then :have_output_on_stderr
|
407
|
+
when 'stdout'; then :have_output_on_stdout
|
408
|
+
end
|
409
|
+
|
410
|
+
# TODO: This isn't actually using the above. It's hardcoded to use have_output only
|
361
411
|
|
362
412
|
if negated
|
363
|
-
expect(all_commands)
|
413
|
+
expect(all_commands)
|
414
|
+
.not_to include_an_object have_output an_output_string_including(expected)
|
364
415
|
else
|
365
|
-
expect(all_commands)
|
416
|
+
expect(all_commands)
|
417
|
+
.to include_an_object have_output an_output_string_including(expected)
|
366
418
|
end
|
367
419
|
end
|
368
420
|
end
|
369
421
|
|
370
|
-
Given(
|
371
|
-
|
372
|
-
Aruba.platform.deprecated(%{The /^the default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
|
373
|
-
# rubocop:enable Metrics/LineLength
|
374
|
-
|
375
|
-
aruba.config.exit_timeout = seconds.to_i
|
376
|
-
end
|
377
|
-
|
378
|
-
Given(/The default aruba timeout is (\d+) seconds/) do |seconds|
|
379
|
-
# rubocop:disable Metrics/LineLength
|
380
|
-
Aruba.platform.deprecated(%{The /^The default aruba timeout is (\d+) seconds/ step definition is deprecated. Please use /^the default aruba exit timeout is (\d+) seconds/ step definition is deprecated.})
|
381
|
-
# rubocop:enable Metrics/LineLength
|
382
|
-
|
383
|
-
aruba.config.exit_timeout = seconds.to_i
|
384
|
-
end
|
385
|
-
|
386
|
-
Given(/^the (?:default )?aruba io wait timeout is (\d+) seconds?$/) do |seconds|
|
387
|
-
aruba.config.io_wait_timeout = seconds.to_i
|
422
|
+
Given(/^the (?:default )?aruba io wait timeout is ([\d.]+) seconds?$/) do |seconds|
|
423
|
+
aruba.config.io_wait_timeout = seconds.to_f
|
388
424
|
end
|
389
425
|
|
390
|
-
Given(/^the (?:default )?aruba exit timeout is (\d+) seconds?$/) do |seconds|
|
391
|
-
aruba.config.exit_timeout = seconds.
|
426
|
+
Given(/^the (?:default )?aruba exit timeout is ([\d.]+) seconds?$/) do |seconds|
|
427
|
+
aruba.config.exit_timeout = seconds.to_f
|
392
428
|
end
|
393
429
|
|
394
430
|
Given(/^the (?:default )?aruba stop signal is "([^"]*)"$/) do |signal|
|
395
431
|
aruba.config.stop_signal = signal
|
396
432
|
end
|
397
433
|
|
398
|
-
Given(/^I wait (\d+) seconds? for (?:a|the) command to start up$/) do |seconds|
|
399
|
-
aruba.config.startup_wait_time = seconds.
|
434
|
+
Given(/^I wait ([\d.]+) seconds? for (?:a|the) command to start up$/) do |seconds|
|
435
|
+
aruba.config.startup_wait_time = seconds.to_f
|
400
436
|
end
|
401
437
|
|
402
|
-
When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/)
|
438
|
+
When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/) \
|
439
|
+
do |signal, command|
|
403
440
|
if command
|
404
441
|
cmd = all_commands.find { |c| c.commandline == command }
|
405
|
-
|
442
|
+
raise ArgumentError, %(No command "#{command}" found) if cmd.nil?
|
406
443
|
|
407
444
|
cmd.send_signal signal
|
408
445
|
else
|