aruba 0.9.0.pre → 0.9.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -3
- data/History.md +61 -19
- data/README.md +10 -6
- data/TODO.md +6 -1
- data/cucumber.yml +10 -6
- data/features/.nav +72 -0
- data/features/announce.feature +203 -0
- data/features/api/command/extract_text.feature +10 -0
- data/features/api/command/run.feature +6 -6
- data/features/api/command/stop_all_commands.feature +53 -0
- data/features/api/command/terminate_all_commands.feature +53 -0
- data/features/api/command/unescape_text.feature +12 -0
- data/features/api/command/which.feature +3 -3
- data/features/api/core/expand_path.feature +4 -4
- data/features/api/environment/append_environment_variable.feature +18 -8
- data/features/api/environment/prepend_environment_variable.feature +18 -8
- data/features/api/environment/set_environment_variable.feature +33 -16
- data/features/api/filesystem/cd.feature +23 -13
- data/features/api/filesystem/create_directory.feature +2 -2
- data/features/api/filesystem/disk_usage.feature +7 -6
- data/features/api/filesystem/does_exist.feature +2 -2
- data/features/api/filesystem/is_absolute.feature +2 -2
- data/features/api/filesystem/is_directory.feature +2 -2
- data/features/api/filesystem/is_file.feature +2 -2
- data/features/api/filesystem/is_relative.feature +2 -2
- data/features/api/filesystem/move.feature +119 -0
- data/features/cli/console.feature +3 -3
- data/features/commands/debug_command.feature +93 -0
- data/features/commands/environment_variables.feature +64 -0
- data/features/commands/flushing.feature +74 -0
- data/features/commands/interactive.feature +90 -0
- data/features/commands/output/all_output.feature +445 -0
- data/features/commands/output/stdout.feature +66 -0
- data/features/configuration/exit_timeout.feature +5 -5
- data/features/configuration/fixtures_directories.feature +3 -3
- data/features/configuration/fixtures_path_prefix.feature +1 -1
- data/features/configuration/home_directory.feature +4 -4
- data/features/configuration/io_timeout.feature +2 -2
- data/features/configuration/keep_ansi.feature +2 -2
- data/features/configuration/log_level.feature +3 -3
- data/features/configuration/physical_block_size.feature +3 -3
- data/features/configuration/usage.feature +159 -0
- data/features/core/cleanup_aruba_directory.feature +52 -0
- data/features/development/build.feature +16 -0
- data/features/development/test.feature +24 -0
- data/features/file_system_commands.feature +12 -12
- data/features/getting_started/supported_programming_languages.feature +89 -0
- data/features/hooks/after/command.feature +1 -1
- data/features/hooks/before/command.feature +2 -2
- data/features/matchers/collection/include_an_object.feature +72 -0
- data/features/matchers/timeouts.feature +2 -2
- data/features/output.feature +60 -181
- data/features/step_definitions/aruba_dev_steps.rb +17 -10
- data/features/step_definitions/hooks.rb +11 -0
- data/features/steps/commands/exit_statuses.feature +3 -3
- data/features/steps/commands/run.feature +0 -15
- data/features/steps/filesystem/copy.feature +45 -0
- data/features/steps/filesystem/create_directory.feature +47 -0
- data/features/steps/filesystem/create_file.feature +53 -0
- data/features/steps/filesystem/file_content.feature +1 -1
- data/features/steps/filesystem/move.feature +45 -0
- data/features/steps/filesystem/overwrite_file.feature +72 -0
- data/features/steps/filesystem/use_fixture.feature +77 -0
- data/features/usage/install.feature +8 -0
- data/{features/fixtures → fixtures}/cli-app/.gitignore +0 -0
- data/{features/fixtures → fixtures}/cli-app/.rspec +0 -0
- data/{features/fixtures → fixtures}/cli-app/README.md +0 -0
- data/{features/fixtures → fixtures}/cli-app/Rakefile +0 -0
- data/{features/fixtures → fixtures}/cli-app/bin/cli +0 -0
- data/{features/fixtures → fixtures}/cli-app/cli-app.gemspec +0 -0
- data/{features/fixtures → fixtures}/cli-app/features/support/env.rb +0 -0
- data/{features/fixtures → fixtures}/cli-app/lib/cli/app.rb +0 -0
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +15 -0
- data/{features/fixtures → fixtures}/cli-app/lib/cli/app/version.rb +0 -0
- data/{features/fixtures/empty-app → fixtures/cli-app}/script/console +3 -3
- data/{features/fixtures → fixtures}/cli-app/spec/spec_helper.rb +0 -0
- data/{features/fixtures → fixtures}/cli-app/spec/support/aruba.rb +0 -0
- data/{features/fixtures → fixtures}/copy/file.txt +0 -0
- data/{features/fixtures → fixtures}/empty-app/.gitignore +0 -0
- data/{features/fixtures → fixtures}/empty-app/.rspec +0 -0
- data/{features/fixtures → fixtures}/empty-app/README.md +0 -0
- data/{features/fixtures → fixtures}/empty-app/Rakefile +0 -0
- data/{features/fixtures → fixtures}/empty-app/bin/cli +0 -0
- data/{features/fixtures → fixtures}/empty-app/cli-app.gemspec +0 -0
- data/{features/fixtures → fixtures}/empty-app/lib/cli/app.rb +0 -0
- data/{features/fixtures → fixtures}/empty-app/lib/cli/app/version.rb +0 -0
- data/{features/fixtures/cli-app → fixtures/empty-app}/script/console +3 -3
- data/{features/fixtures → fixtures}/empty-app/spec/spec_helper.rb +0 -0
- data/{features/fixtures → fixtures}/fixtures-app/test.txt +0 -0
- data/fixtures/getting-started-app/.gitignore +4 -0
- data/fixtures/getting-started-app/Gemfile +4 -0
- data/fixtures/getting-started-app/README.md +3 -0
- data/fixtures/getting-started-app/features/support/env.rb +1 -0
- data/{features/fixtures → fixtures}/spawn_process/stderr.sh +0 -0
- data/lib/aruba/announcer.rb +6 -2
- data/lib/aruba/api.rb +0 -16
- data/lib/aruba/api/command.rb +64 -266
- data/lib/aruba/api/core.rb +24 -26
- data/lib/aruba/api/deprecated.rb +370 -12
- data/lib/aruba/api/filesystem.rb +64 -15
- data/lib/aruba/aruba_path.rb +4 -0
- data/lib/aruba/config.rb +1 -1
- data/lib/aruba/cucumber.rb +5 -449
- data/lib/aruba/cucumber/command.rb +378 -0
- data/lib/aruba/cucumber/core.rb +29 -0
- data/lib/aruba/cucumber/environment.rb +30 -0
- data/lib/aruba/cucumber/file.rb +210 -0
- data/lib/aruba/cucumber/hooks.rb +11 -14
- data/lib/aruba/cucumber/rvm.rb +3 -0
- data/lib/aruba/matchers/base/base_matcher.rb +94 -0
- data/lib/aruba/matchers/collection.rb +1 -0
- data/lib/aruba/matchers/collection/all_objects.rb +2 -0
- data/lib/aruba/matchers/collection/include_an_object.rb +120 -0
- data/lib/aruba/matchers/command/be_successfully_executed.rb +3 -3
- data/lib/aruba/matchers/command/have_exit_status.rb +2 -11
- data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
- data/lib/aruba/matchers/command/have_output.rb +46 -0
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +42 -0
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +42 -0
- data/lib/aruba/matchers/command/have_output_size.rb +28 -0
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +1 -1
- data/lib/aruba/matchers/file/be_an_existing_file.rb +1 -1
- data/lib/aruba/matchers/file/have_file_content.rb +1 -1
- data/lib/aruba/matchers/file/have_file_size.rb +2 -2
- data/lib/aruba/matchers/file/have_same_file_content.rb +1 -1
- data/lib/aruba/matchers/path/have_permissions.rb +1 -1
- data/lib/aruba/platforms/aruba_file_creator.rb +2 -3
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -3
- data/lib/aruba/platforms/determine_disk_usage.rb +23 -0
- data/lib/aruba/platforms/determine_file_size.rb +13 -0
- data/lib/aruba/platforms/disk_usage_calculator.rb +11 -0
- data/lib/aruba/platforms/local_environment.rb +15 -0
- data/lib/aruba/platforms/unix_environment_variables.rb +1 -1
- data/lib/aruba/platforms/unix_platform.rb +35 -14
- data/lib/aruba/process_monitor.rb +53 -7
- data/lib/aruba/processes/basic_process.rb +25 -5
- data/lib/aruba/processes/debug_process.rb +27 -25
- data/lib/aruba/processes/in_process.rb +7 -22
- data/lib/aruba/processes/spawn_process.rb +74 -31
- data/lib/aruba/rspec.rb +1 -6
- data/lib/aruba/version.rb +1 -1
- data/script/console +0 -1
- data/spec/aruba/api/environment/restore_env_spec.rb +65 -0
- data/spec/aruba/api/environment/set_env_spec.rb +42 -0
- data/spec/aruba/api/filesystem/file_size_spec.rb +28 -0
- data/spec/aruba/api_spec.rb +10 -7
- data/spec/aruba/matchers/command/have_output_size_spec.rb +25 -0
- data/spec/aruba/matchers/command_spec.rb +135 -4
- data/spec/aruba/spawn_process_spec.rb +1 -1
- metadata +107 -65
- data/.nav +0 -12
- data/features/debug.feature +0 -15
- data/features/fixtures/cli-app/spec/cli/app_spec.rb +0 -7
- data/features/flushing.feature +0 -26
- data/features/interactive.feature +0 -66
- data/features/no_clobber.feature +0 -25
- data/lib/aruba/disk_usage_calculator.rb +0 -7
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SimpleCov
|
2
|
+
module Formatter
|
3
|
+
class HTMLFormatter
|
4
|
+
def format(result)
|
5
|
+
Dir[File.join(File.dirname(__FILE__), "../public/*")].each do |path|
|
6
|
+
FileUtils.cp_r(path, asset_output_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
File.open(File.join(output_path, "index.html"), "wb") do |file|
|
10
|
+
file.puts template("layout").result(binding)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'cli/app'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "cli/app"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'cli/app'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "cli/app"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba/cucumber'
|
File without changes
|
data/lib/aruba/announcer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
1
3
|
module Aruba
|
2
4
|
# Announcer
|
3
5
|
#
|
@@ -78,10 +80,12 @@ module Aruba
|
|
78
80
|
def after_init
|
79
81
|
output_format :directory, '$ cd %s'
|
80
82
|
output_format :command, '$ %s'
|
81
|
-
output_format :environment, '$ export %s=%s
|
82
|
-
output_format :modified_environment, '$ export %s=%s
|
83
|
+
output_format :environment, proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
84
|
+
output_format :modified_environment, proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
83
85
|
output_format :full_environment, proc { |h| Aruba.platform.simple_table(h) }
|
84
86
|
output_format :timeout, '# %s-timeout: %s seconds'
|
87
|
+
output_format :stderr, "<<-STDERR\n%s\nSTDERR"
|
88
|
+
output_format :stdout, "<<-STDOUT\n%s\nSTDOUT"
|
85
89
|
|
86
90
|
# rubocop:disable Metrics/LineLength
|
87
91
|
if @options[:stdout]
|
data/lib/aruba/api.rb
CHANGED
@@ -26,21 +26,5 @@ module Aruba
|
|
26
26
|
include Aruba::Api::Filesystem
|
27
27
|
include Aruba::Api::Rvm
|
28
28
|
include Aruba::Api::Deprecated
|
29
|
-
|
30
|
-
# Access to announcer
|
31
|
-
def announcer
|
32
|
-
@announcer ||= Announcer.new(
|
33
|
-
self,
|
34
|
-
:stdout => defined?(@announce_stdout),
|
35
|
-
:stderr => defined?(@announce_stderr),
|
36
|
-
:dir => defined?(@announce_dir),
|
37
|
-
:cmd => defined?(@announce_cmd),
|
38
|
-
:env => defined?(@announce_env)
|
39
|
-
)
|
40
|
-
|
41
|
-
@announcer
|
42
|
-
end
|
43
|
-
|
44
|
-
module_function :announcer
|
45
29
|
end
|
46
30
|
end
|
data/lib/aruba/api/command.rb
CHANGED
@@ -63,205 +63,19 @@ module Aruba
|
|
63
63
|
file_name = expand_path(file_name)
|
64
64
|
|
65
65
|
File.open(file_name, 'r').each_line do |line|
|
66
|
-
|
66
|
+
last_command_started.write(line)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
#
|
70
|
+
# Return all commands
|
71
71
|
#
|
72
|
-
# @
|
73
|
-
#
|
74
|
-
def
|
75
|
-
process_monitor.
|
76
|
-
end
|
77
|
-
|
78
|
-
# Fetch stdout from command
|
79
|
-
#
|
80
|
-
# @param [String] cmd
|
81
|
-
# The command
|
82
|
-
def stdout_from(cmd)
|
83
|
-
process_monitor.stdout_from(cmd)
|
84
|
-
end
|
85
|
-
|
86
|
-
# Fetch stderr from command
|
87
|
-
#
|
88
|
-
# @param [String] cmd
|
89
|
-
# The command
|
90
|
-
def stderr_from(cmd)
|
91
|
-
process_monitor.stderr_from(cmd)
|
92
|
-
end
|
93
|
-
|
94
|
-
# Get stdout of all processes
|
95
|
-
#
|
96
|
-
# @return [String]
|
97
|
-
# The stdout of all process which have run before
|
98
|
-
def all_stdout
|
99
|
-
process_monitor.all_stdout
|
100
|
-
end
|
101
|
-
|
102
|
-
# Get stderr of all processes
|
103
|
-
#
|
104
|
-
# @return [String]
|
105
|
-
# The stderr of all process which have run before
|
106
|
-
def all_stderr
|
107
|
-
process_monitor.all_stderr
|
108
|
-
end
|
109
|
-
|
110
|
-
# Get stderr and stdout of all processes
|
111
|
-
#
|
112
|
-
# @return [String]
|
113
|
-
# The stderr and stdout of all process which have run before
|
114
|
-
def all_output
|
115
|
-
process_monitor.all_output
|
116
|
-
end
|
117
|
-
|
118
|
-
# Full compare arg1 and arg2
|
119
|
-
#
|
120
|
-
# @return [TrueClass, FalseClass]
|
121
|
-
# If arg1 is exactly the same as arg2 return true, otherwise false
|
122
|
-
def assert_exact_output(expected, actual)
|
123
|
-
actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
|
124
|
-
|
125
|
-
actual = unescape_text(actual)
|
126
|
-
actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
127
|
-
|
128
|
-
expected = unescape_text(expected)
|
129
|
-
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
130
|
-
|
131
|
-
expect(actual).to eq expected
|
132
|
-
end
|
133
|
-
|
134
|
-
# Partial compare arg1 and arg2
|
135
|
-
#
|
136
|
-
# @return [TrueClass, FalseClass]
|
137
|
-
# If arg2 contains arg1 return true, otherwise false
|
138
|
-
def assert_partial_output(expected, actual)
|
139
|
-
actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
|
140
|
-
|
141
|
-
actual = unescape_text(actual)
|
142
|
-
actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
143
|
-
|
144
|
-
expected = unescape_text(expected)
|
145
|
-
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
146
|
-
|
147
|
-
expect(actual).to include expected
|
148
|
-
end
|
149
|
-
|
150
|
-
# Regex Compare arg1 and arg2
|
151
|
-
#
|
152
|
-
# @return [TrueClass, FalseClass]
|
153
|
-
# If arg2 matches arg1 return true, otherwise false
|
154
|
-
def assert_matching_output(expected, actual)
|
155
|
-
actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
|
156
|
-
|
157
|
-
actual = unescape_text(actual)
|
158
|
-
actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
159
|
-
|
160
|
-
expected = unescape_text(expected)
|
161
|
-
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
162
|
-
|
163
|
-
expect(actual).to match Regexp.new(expected, Regexp::MULTILINE)
|
164
|
-
end
|
165
|
-
|
166
|
-
# Negative regex compare arg1 and arg2
|
167
|
-
#
|
168
|
-
# @return [TrueClass, FalseClass]
|
169
|
-
# If arg2 does not match arg1 return true, otherwise false
|
170
|
-
def assert_not_matching_output(expected, actual)
|
171
|
-
actual.force_encoding(expected.encoding) if RUBY_VERSION >= "1.9"
|
172
|
-
|
173
|
-
actual = unescape_text(actual)
|
174
|
-
actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
175
|
-
|
176
|
-
expected = unescape_text(expected)
|
177
|
-
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
178
|
-
|
179
|
-
expect(actual).not_to match Regexp.new(expected, Regexp::MULTILINE)
|
180
|
-
end
|
181
|
-
|
182
|
-
# Negative partial compare arg1 and arg2
|
183
|
-
#
|
184
|
-
# @return [TrueClass, FalseClass]
|
185
|
-
# If arg2 does not match/include arg1 return true, otherwise false
|
186
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
187
|
-
def assert_no_partial_output(unexpected, actual)
|
188
|
-
actual.force_encoding(unexpected.encoding) if RUBY_VERSION >= "1.9"
|
189
|
-
|
190
|
-
actual = unescape_text(actual)
|
191
|
-
actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
192
|
-
|
193
|
-
if Regexp === unexpected
|
194
|
-
expect(actual).not_to match unexpected
|
195
|
-
else
|
196
|
-
unexpected = unescape_text(unexpected)
|
197
|
-
unexpected = extract_text(unexpected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
198
|
-
|
199
|
-
expect(actual).not_to include(unexpected)
|
200
|
-
end
|
201
|
-
end
|
202
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
203
|
-
|
204
|
-
# Partial compare output of interactive command and arg1
|
205
|
-
#
|
206
|
-
# @return [TrueClass, FalseClass]
|
207
|
-
# If output of interactive command includes arg1 return true, otherwise false
|
208
|
-
def assert_partial_output_interactive(expected)
|
209
|
-
actual = unescape_text(last_command.stdout)
|
210
|
-
actual = extract_text(actual) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
211
|
-
|
212
|
-
expected = unescape_text(expected)
|
213
|
-
expected = extract_text(expected) if !aruba.config.keep_ansi || aruba.config.remove_ansi_escape_sequences
|
214
|
-
|
215
|
-
actual.include?(expected) ? true : false
|
216
|
-
end
|
217
|
-
|
218
|
-
# Check if command succeeded and if arg1 is included in output
|
219
|
-
#
|
220
|
-
# @return [TrueClass, FalseClass]
|
221
|
-
# If exit status is 0 and arg1 is included in output return true, otherwise false
|
222
|
-
def assert_passing_with(expected)
|
223
|
-
assert_success(true)
|
224
|
-
assert_partial_output(expected, all_output)
|
225
|
-
end
|
226
|
-
|
227
|
-
# Check if command failed and if arg1 is included in output
|
228
|
-
#
|
229
|
-
# @return [TrueClass, FalseClass]
|
230
|
-
# If exit status is not equal 0 and arg1 is included in output return true, otherwise false
|
231
|
-
def assert_failing_with(expected)
|
232
|
-
assert_success(false)
|
233
|
-
assert_partial_output(expected, all_output)
|
234
|
-
end
|
235
|
-
|
236
|
-
# Check exit status of process
|
237
|
-
#
|
238
|
-
# @return [TrueClass, FalseClass]
|
239
|
-
# If arg1 is true, return true if command was successful
|
240
|
-
# If arg1 is false, return true if command failed
|
241
|
-
def assert_success(success)
|
242
|
-
if success
|
243
|
-
expect(last_command).to be_successfully_executed
|
244
|
-
else
|
245
|
-
expect(last_command).not_to be_successfully_executed
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
# @private
|
250
|
-
def assert_exit_status(status)
|
251
|
-
expect(last_command).to have_exit_status(status)
|
252
|
-
end
|
253
|
-
|
254
|
-
# @private
|
255
|
-
def assert_not_exit_status(status)
|
256
|
-
expect(last_exit_status).not_to eq(status),
|
257
|
-
append_output_to("Exit status was #{last_exit_status} which was not expected.")
|
72
|
+
# @return [Array]
|
73
|
+
# List of commands
|
74
|
+
def all_commands
|
75
|
+
process_monitor.all_commands
|
258
76
|
end
|
259
77
|
|
260
78
|
# @private
|
261
|
-
def append_output_to(message)
|
262
|
-
"#{message} Output:\n\n#{all_output}\n"
|
263
|
-
end
|
264
|
-
|
265
79
|
def process_monitor
|
266
80
|
return @process_monitor if defined? @process_monitor
|
267
81
|
|
@@ -275,29 +89,48 @@ module Aruba
|
|
275
89
|
process_monitor.send(:processes)
|
276
90
|
end
|
277
91
|
|
278
|
-
#
|
279
|
-
def
|
280
|
-
process_monitor.
|
92
|
+
# Last command started
|
93
|
+
def last_command_started
|
94
|
+
process_monitor.last_command_started
|
281
95
|
end
|
282
96
|
|
283
|
-
#
|
284
|
-
def
|
285
|
-
process_monitor.
|
97
|
+
# Last command stopped
|
98
|
+
def last_command_stopped
|
99
|
+
process_monitor.last_command_stopped
|
286
100
|
end
|
287
101
|
|
288
|
-
#
|
289
|
-
|
290
|
-
|
291
|
-
|
102
|
+
# Stop all commands
|
103
|
+
#
|
104
|
+
# @yield [Command]
|
105
|
+
# If block is given use it to filter the commands which should be
|
106
|
+
# stoppend.
|
107
|
+
def stop_all_commands(&block)
|
108
|
+
cmds = if block_given?
|
109
|
+
all_commands.select(&block)
|
110
|
+
else
|
111
|
+
all_commands
|
112
|
+
end
|
292
113
|
|
293
|
-
|
294
|
-
|
295
|
-
|
114
|
+
cmds.each { |c| c.stop(announcer) }
|
115
|
+
|
116
|
+
self
|
296
117
|
end
|
297
118
|
|
298
|
-
#
|
299
|
-
|
300
|
-
|
119
|
+
# Terminate all commands
|
120
|
+
#
|
121
|
+
# @yield [Command]
|
122
|
+
# If block is given use it to filter the commands which should be
|
123
|
+
# terminated.
|
124
|
+
def terminate_all_commands(&block)
|
125
|
+
cmds = if block_given?
|
126
|
+
all_commands.select(&block)
|
127
|
+
else
|
128
|
+
all_commands
|
129
|
+
end
|
130
|
+
|
131
|
+
cmds.each(&:terminate)
|
132
|
+
|
133
|
+
self
|
301
134
|
end
|
302
135
|
|
303
136
|
# Run given command and stop it if timeout is reached
|
@@ -312,17 +145,18 @@ module Aruba
|
|
312
145
|
# Run block with process
|
313
146
|
#
|
314
147
|
# rubocop:disable Metrics/MethodLength
|
315
|
-
def run(cmd,
|
316
|
-
|
148
|
+
def run(cmd, exit_timeout = nil, io_wait_timeout = nil)
|
149
|
+
exit_timeout ||= aruba.config.exit_timeout
|
150
|
+
io_wait_timeout ||= aruba.config.io_wait_timeout
|
151
|
+
|
317
152
|
@commands ||= []
|
318
153
|
@commands << cmd
|
319
154
|
|
320
|
-
cmd = Aruba.platform.detect_ruby(cmd)
|
321
|
-
|
322
|
-
announcer.announce(:directory, Dir.pwd)
|
323
155
|
announcer.announce(:command, cmd)
|
324
|
-
|
325
|
-
|
156
|
+
|
157
|
+
cmd = Aruba.platform.detect_ruby(cmd)
|
158
|
+
environment = aruba.environment.to_h
|
159
|
+
working_directory = expand_path('.')
|
326
160
|
|
327
161
|
mode = if Aruba.process
|
328
162
|
# rubocop:disable Metrics/LineLength
|
@@ -341,13 +175,19 @@ module Aruba
|
|
341
175
|
else
|
342
176
|
aruba.config.main_class
|
343
177
|
end
|
178
|
+
|
179
|
+
announcer.announce(:directory, working_directory)
|
180
|
+
announcer.announce(:timeout, 'exit', exit_timeout)
|
181
|
+
announcer.announce(:timeout, 'io wait', io_wait_timeout)
|
182
|
+
announcer.announce(:full_environment, environment)
|
183
|
+
|
344
184
|
command = Command.new(
|
345
185
|
cmd,
|
346
186
|
:mode => mode,
|
347
|
-
:exit_timeout =>
|
348
|
-
:io_wait_timeout =>
|
349
|
-
:working_directory =>
|
350
|
-
:environment =>
|
187
|
+
:exit_timeout => exit_timeout,
|
188
|
+
:io_wait_timeout => io_wait_timeout,
|
189
|
+
:working_directory => working_directory,
|
190
|
+
:environment => environment,
|
351
191
|
:main_class => main_class
|
352
192
|
)
|
353
193
|
|
@@ -361,7 +201,7 @@ module Aruba
|
|
361
201
|
aruba.config.before(:command, self, command)
|
362
202
|
|
363
203
|
process_monitor.register_process(cmd, command)
|
364
|
-
command.
|
204
|
+
command.start
|
365
205
|
|
366
206
|
aruba.config.after(:command, self, command)
|
367
207
|
|
@@ -369,27 +209,6 @@ module Aruba
|
|
369
209
|
end
|
370
210
|
# rubocop:enable Metrics/MethodLength
|
371
211
|
|
372
|
-
# Default exit timeout for running commands with aruba
|
373
|
-
#
|
374
|
-
# Overwrite this method if you want a different timeout or set
|
375
|
-
# `@aruba_timeout_seconds`.
|
376
|
-
def exit_timeout
|
377
|
-
aruba.config.exit_timeout
|
378
|
-
end
|
379
|
-
|
380
|
-
# Default io wait timeout
|
381
|
-
#
|
382
|
-
# Overwrite this method if you want a different timeout or set
|
383
|
-
# `@aruba_io_wait_seconds
|
384
|
-
def io_wait
|
385
|
-
aruba.config.io_wait_timeout
|
386
|
-
end
|
387
|
-
|
388
|
-
# The root directory of aruba
|
389
|
-
def root_directory
|
390
|
-
aruba.config.root_directory
|
391
|
-
end
|
392
|
-
|
393
212
|
# Run a command with aruba
|
394
213
|
#
|
395
214
|
# Checks for error during command execution and checks the output to detect
|
@@ -403,8 +222,8 @@ module Aruba
|
|
403
222
|
#
|
404
223
|
# @param [Integer] timeout
|
405
224
|
# Timeout for execution
|
406
|
-
def run_simple(cmd, fail_on_error = true,
|
407
|
-
command = run(cmd,
|
225
|
+
def run_simple(cmd, fail_on_error = true, exit_timeout = nil, io_wait_timeout = nil)
|
226
|
+
command = run(cmd, exit_timeout, io_wait_timeout)
|
408
227
|
@last_exit_status = process_monitor.stop_process(command)
|
409
228
|
|
410
229
|
@timed_out = command.timed_out?
|
@@ -421,33 +240,12 @@ module Aruba
|
|
421
240
|
# The input for the command
|
422
241
|
def type(input)
|
423
242
|
return close_input if "" == input
|
424
|
-
|
243
|
+
last_command_started.write(input << "\n")
|
425
244
|
end
|
426
245
|
|
427
246
|
# Close stdin
|
428
247
|
def close_input
|
429
|
-
|
430
|
-
end
|
431
|
-
|
432
|
-
# Only processes
|
433
|
-
def only_processes
|
434
|
-
process_monitor.only_processes
|
435
|
-
end
|
436
|
-
|
437
|
-
# TODO: move some more methods under here!
|
438
|
-
|
439
|
-
private
|
440
|
-
|
441
|
-
def last_exit_status
|
442
|
-
process_monitor.last_exit_status
|
443
|
-
end
|
444
|
-
|
445
|
-
def stop_process(process)
|
446
|
-
@last_exit_status = process_monitor.stop_process(process)
|
447
|
-
end
|
448
|
-
|
449
|
-
def terminate_process(process)
|
450
|
-
process_monitor.terminate_process(process)
|
248
|
+
last_command_started.close_io(:stdin)
|
451
249
|
end
|
452
250
|
end
|
453
251
|
end
|