aruba 0.14.7 → 0.14.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Gemfile +8 -0
  4. data/History.md +9 -0
  5. data/README.md +0 -1
  6. data/Rakefile +4 -3
  7. data/aruba.gemspec +1 -1
  8. data/features/api/command/find_command.feature +5 -5
  9. data/features/api/command/last_command_started.feature +3 -3
  10. data/features/api/command/last_command_stopped.feature +6 -6
  11. data/features/api/command/run.feature +22 -22
  12. data/features/api/command/run_simple.feature +12 -12
  13. data/features/api/command/send_signal.feature +2 -2
  14. data/features/api/command/stderr.feature +2 -2
  15. data/features/api/command/stdout.feature +2 -2
  16. data/features/api/command/stop.feature +4 -4
  17. data/features/api/command/stop_all_commands.feature +5 -5
  18. data/features/api/command/terminate_all_commands.feature +5 -5
  19. data/features/api/environment/append_environment_variable.feature +5 -5
  20. data/features/api/environment/delete_environment_variable.feature +3 -3
  21. data/features/api/environment/prepend_environment_variable.feature +6 -6
  22. data/features/api/environment/set_environment_variable.feature +15 -15
  23. data/features/api/filesystem/cd.feature +2 -2
  24. data/features/api/text/extract_text.feature +4 -4
  25. data/features/api/text/replace_variables.feature +1 -1
  26. data/features/api/text/sanitize_text.feature +11 -11
  27. data/features/api/text/unescape_text.feature +6 -6
  28. data/features/configuration/command_runtime_environment.feature +5 -5
  29. data/features/configuration/usage.feature +5 -5
  30. data/features/hooks/after/command.feature +1 -1
  31. data/features/hooks/before/command.feature +2 -2
  32. data/features/matchers/timeouts.feature +2 -2
  33. data/features/step_definitions/aruba_dev_steps.rb +1 -1
  34. data/lib/aruba/api.rb +1 -1
  35. data/lib/aruba/api/{command.rb → commands.rb} +10 -9
  36. data/lib/aruba/api/deprecated.rb +65 -7
  37. data/lib/aruba/api/rvm.rb +3 -3
  38. data/lib/aruba/basic_configuration.rb +0 -2
  39. data/lib/aruba/config.rb +0 -1
  40. data/lib/aruba/console.rb +0 -2
  41. data/lib/aruba/cucumber/command.rb +6 -6
  42. data/lib/aruba/generators/script_file.rb +1 -1
  43. data/lib/aruba/matchers/deprecated/file.rb +3 -1
  44. data/lib/aruba/platforms/command_monitor.rb +0 -5
  45. data/lib/aruba/platforms/unix_environment_variables.rb +1 -3
  46. data/lib/aruba/platforms/unix_which.rb +0 -4
  47. data/lib/aruba/platforms/windows_which.rb +0 -4
  48. data/lib/aruba/processes/basic_process.rb +1 -0
  49. data/lib/aruba/processes/spawn_process.rb +1 -3
  50. data/lib/aruba/runtime.rb +4 -3
  51. data/lib/aruba/version.rb +1 -1
  52. data/spec/aruba/api/deprecated_spec.rb +5 -5
  53. data/spec/aruba/api_spec.rb +7 -7
  54. data/spec/aruba/matchers/command_spec.rb +18 -18
  55. data/spec/aruba/matchers/deprecated_spec.rb +1 -2
  56. data/spec/aruba/matchers/file_spec.rb +1 -2
  57. data/spec/event_bus_spec.rb +0 -2
  58. metadata +6 -6
@@ -17,7 +17,7 @@ Feature: Unescape special characters in text
17
17
  require 'spec_helper'
18
18
 
19
19
  RSpec.describe 'Run command', :type => :aruba do
20
- before(:each) { run('cli') }
20
+ before(:each) { run_command('cli') }
21
21
  before(:each) { stop_all_commands }
22
22
 
23
23
  it { expect(unescape_text(last_command.output)).to eq "text\ntext" }
@@ -37,7 +37,7 @@ Feature: Unescape special characters in text
37
37
  require 'spec_helper'
38
38
 
39
39
  RSpec.describe 'Run command', :type => :aruba do
40
- before(:each) { run('cli') }
40
+ before(:each) { run_command('cli') }
41
41
  before(:each) { stop_all_commands }
42
42
 
43
43
  it { expect(unescape_text(last_command.output)).to eq "texttext" }
@@ -57,7 +57,7 @@ Feature: Unescape special characters in text
57
57
  require 'spec_helper'
58
58
 
59
59
  RSpec.describe 'Run command', :type => :aruba do
60
- before(:each) { run('cli') }
60
+ before(:each) { run_command('cli') }
61
61
  before(:each) { stop_all_commands }
62
62
 
63
63
  it { expect(unescape_text(last_command.output)).to eq "text\"text" }
@@ -77,7 +77,7 @@ Feature: Unescape special characters in text
77
77
  require 'spec_helper'
78
78
 
79
79
  RSpec.describe 'Run command', :type => :aruba do
80
- before(:each) { run('cli') }
80
+ before(:each) { run_command('cli') }
81
81
  before(:each) { stop_all_commands }
82
82
 
83
83
  it { expect(unescape_text(last_command.output)).to eq "texttext" }
@@ -97,7 +97,7 @@ Feature: Unescape special characters in text
97
97
  require 'spec_helper'
98
98
 
99
99
  RSpec.describe 'Run command', :type => :aruba do
100
- before(:each) { run('cli') }
100
+ before(:each) { run_command('cli') }
101
101
  before(:each) { stop_all_commands }
102
102
 
103
103
  it { expect(unescape_text(last_command.output)).to eq "texttext" }
@@ -117,7 +117,7 @@ Feature: Unescape special characters in text
117
117
  require 'spec_helper'
118
118
 
119
119
  RSpec.describe 'Run command', :type => :aruba do
120
- before(:each) { run('cli') }
120
+ before(:each) { run_command('cli') }
121
121
  before(:each) { stop_all_commands }
122
122
 
123
123
  it { expect(unescape_text(last_command.output)).to eq "texttext" }
@@ -27,7 +27,7 @@ Feature: Define default process environment
27
27
  end
28
28
 
29
29
  RSpec.describe 'Environment command', :type => :aruba do
30
- before(:each) { run('env') }
30
+ before(:each) { run_command('env') }
31
31
  before(:each) { stop_all_commands }
32
32
 
33
33
  it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=x' }
@@ -50,7 +50,7 @@ Feature: Define default process environment
50
50
  RSpec.describe 'Environment command', :type => :aruba do
51
51
  before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', 'z' }
52
52
 
53
- before(:each) { run('env') }
53
+ before(:each) { run_command('env') }
54
54
  before(:each) { stop_all_commands }
55
55
 
56
56
  it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=z' }
@@ -73,7 +73,7 @@ Feature: Define default process environment
73
73
  RSpec.describe 'Environment command', :type => :aruba do
74
74
  before(:each) { append_environment_variable 'LONG_LONG_VARIABLE', 'z' }
75
75
 
76
- before(:each) { run('env') }
76
+ before(:each) { run_command('env') }
77
77
  before(:each) { stop_all_commands }
78
78
 
79
79
  it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=xz' }
@@ -96,7 +96,7 @@ Feature: Define default process environment
96
96
  RSpec.describe 'Environment command', :type => :aruba do
97
97
  before(:each) { prepend_environment_variable 'LONG_LONG_VARIABLE', 'z' }
98
98
 
99
- before(:each) { run('env') }
99
+ before(:each) { run_command('env') }
100
100
  before(:each) { stop_all_commands }
101
101
 
102
102
  it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=zx' }
@@ -119,7 +119,7 @@ Feature: Define default process environment
119
119
  RSpec.describe 'Environment command', :type => :aruba do
120
120
  before(:each) { delete_environment_variable 'LONG_LONG_VARIABLE' }
121
121
 
122
- before(:each) { run('env') }
122
+ before(:each) { run_command('env') }
123
123
  before(:each) { stop_all_commands }
124
124
 
125
125
  it { expect(last_command_started.output).not_to include 'LONG_LONG_VARIABLE' }
@@ -35,12 +35,12 @@ Feature: Usage of configuration
35
35
 
36
36
  RSpec.describe 'Run command', :type => :aruba do
37
37
  context 'when fast command' do
38
- before(:each) { run('cli 0') }
38
+ before(:each) { run_command('cli 0') }
39
39
  it { expect(last_command_started).to be_successfully_executed }
40
40
  end
41
41
 
42
42
  context 'when slow command' do
43
- before(:each) { run('cli 2') }
43
+ before(:each) { run_command('cli 2') }
44
44
  it { expect(last_command_started).not_to be_successfully_executed }
45
45
  end
46
46
  end
@@ -78,17 +78,17 @@ Feature: Usage of configuration
78
78
 
79
79
  RSpec.describe 'Run command', :type => :aruba do
80
80
  context 'when fast command' do
81
- before(:each) { run('cli 0') }
81
+ before(:each) { run_command('cli 0') }
82
82
  it { expect(last_command_started).to be_successfully_executed }
83
83
  end
84
84
 
85
85
  context 'when slow command and this is known by the developer', :slow_command => true do
86
- before(:each) { run('cli 2') }
86
+ before(:each) { run_command('cli 2') }
87
87
  it { expect(last_command_started).to be_successfully_executed }
88
88
  end
89
89
 
90
90
  context 'when slow command, but this might be a failure' do
91
- before(:each) { run('cli 2') }
91
+ before(:each) { run_command('cli 2') }
92
92
  it { expect(last_command_started).not_to be_successfully_executed }
93
93
  end
94
94
  end
@@ -32,7 +32,7 @@ Feature: After command hooks
32
32
  require 'spec_helper'
33
33
 
34
34
  RSpec.describe 'Hooks', :type => :aruba do
35
- before(:each) { run_simple 'echo running' }
35
+ before(:each) { run_command_and_stop 'echo running' }
36
36
 
37
37
  it { expect(last_command_started.stdout.chomp).to eq 'running' }
38
38
  end
@@ -34,7 +34,7 @@ Feature: before_cmd hooks
34
34
  require 'spec_helper'
35
35
 
36
36
  RSpec.describe 'Hooks', :type => :aruba do
37
- before(:each) { run_simple 'echo running' }
37
+ before(:each) { run_command_and_stop 'echo running' }
38
38
 
39
39
  it { expect(last_command_started.stdout.chomp).to eq 'running' }
40
40
  end
@@ -62,7 +62,7 @@ Feature: before_cmd hooks
62
62
  require 'spec_helper'
63
63
 
64
64
  RSpec.describe 'Hooks', :type => :aruba do
65
- before(:each) { run_simple 'echo running' }
65
+ before(:each) { run_command_and_stop 'echo running' }
66
66
 
67
67
  it { expect(last_command_started.stdout.chomp).to eq 'running' }
68
68
  end
@@ -18,7 +18,7 @@ Feature: Check if a timeout occured during command execution
18
18
  RSpec.describe 'Long running command', :type => :aruba do
19
19
  before(:each) { aruba.config.exit_timeout = 0 }
20
20
 
21
- before(:each) { run('cli') }
21
+ before(:each) { run_command('cli') }
22
22
 
23
23
  it { expect(last_command_started).to run_too_long }
24
24
  end
@@ -39,7 +39,7 @@ Feature: Check if a timeout occured during command execution
39
39
  RSpec.describe 'Short running command', :type => :aruba do
40
40
  before(:each) { aruba.config.exit_timeout = 5 }
41
41
 
42
- before(:each) { run('cli') }
42
+ before(:each) { run_command('cli') }
43
43
 
44
44
  it { expect(last_command_started).to have_finished_in_time }
45
45
  end
@@ -51,6 +51,6 @@ Given(/^the default feature-test$/) do
51
51
  end
52
52
 
53
53
  Then(/^aruba should be installed on the local system$/) do
54
- run('gem list aruba')
54
+ run_command('gem list aruba')
55
55
  expect(last_command_started).to have_output(/aruba/)
56
56
  end
@@ -6,7 +6,7 @@ require 'aruba/extensions/string/strip'
6
6
 
7
7
  require 'aruba/platform'
8
8
  require 'aruba/api/core'
9
- require 'aruba/api/command'
9
+ require 'aruba/api/commands'
10
10
 
11
11
  if Aruba::VERSION <= '1.0.0'
12
12
  require 'aruba/api/deprecated'
@@ -136,8 +136,8 @@ module Aruba
136
136
  #
137
137
  # rubocop:disable Metrics/MethodLength
138
138
  # rubocop:disable Metrics/CyclomaticComplexity
139
- def run(*args)
140
- fail ArgumentError, 'Please pass at least a command as first argument.' if args.size < 1
139
+ def run_command(*args)
140
+ fail ArgumentError, 'Please pass at least a command as first argument.' if args.empty?
141
141
 
142
142
  cmd = args.shift
143
143
 
@@ -149,8 +149,9 @@ module Aruba
149
149
  stop_signal = opts[:stop_signal].nil? ? aruba.config.stop_signal : opts[:stop_signal]
150
150
  startup_wait_time = opts[:startup_wait_time].nil? ? aruba.config.startup_wait_time : opts[:startup_wait_time]
151
151
  else
152
- if args.size > 1
153
- Aruba.platform.deprecated("Please pass options to `#run` as named parameters/hash and don\'t use the old style, e.g. `#run('cmd', :exit_timeout => 5)`.")
152
+ if args.size > 0
153
+ Aruba.platform.deprecated(
154
+ "Please pass options to `#run_command` as named parameters/hash and don\'t use the old style, e.g. `#run_command('cmd', :exit_timeout => 5)`.")
154
155
  end
155
156
 
156
157
  exit_timeout = args[0].nil? ? aruba.config.exit_timeout : args[0]
@@ -243,8 +244,8 @@ module Aruba
243
244
  #
244
245
  # rubocop:disable Metrics/CyclomaticComplexity
245
246
  # rubocop:disable Metrics/MethodLength
246
- def run_simple(*args)
247
- fail ArgumentError, 'Please pass at least a command as first argument.' if args.size < 1
247
+ def run_command_and_stop(*args)
248
+ fail ArgumentError, 'Please pass at least a command as first argument.' if args.empty?
248
249
 
249
250
  cmd = args.shift
250
251
 
@@ -252,9 +253,9 @@ module Aruba
252
253
  opts = args.pop
253
254
  fail_on_error = opts.delete(:fail_on_error) == true ? true : false
254
255
  else
255
- if args.size > 1
256
+ if args.size > 0
256
257
  # rubocop:disable Metrics/LineLength
257
- Aruba.platform.deprecated("Please pass options to `#run_simple` as named parameters/hash and don\'t use the old style with positional parameters, NEW: e.g. `#run_simple('cmd', :exit_timeout => 5)`.")
258
+ Aruba.platform.deprecated("Please pass options to `#run_command_and_stop` as named parameters/hash and don\'t use the old style with positional parameters, NEW: e.g. `#run_command_and_stop('cmd', :exit_timeout => 5)`.")
258
259
  # rubocop:enable Metrics/LineLength
259
260
  end
260
261
 
@@ -268,7 +269,7 @@ module Aruba
268
269
  }
269
270
  end
270
271
 
271
- command = run(cmd, opts)
272
+ command = run_command(cmd, opts)
272
273
  command.stop
273
274
 
274
275
  if Aruba::VERSION < '1'
@@ -116,13 +116,75 @@ module Aruba
116
116
  # The command to by run
117
117
  #
118
118
  # @see #cmd
119
- # @deprectated
119
+ # @deprecated
120
120
  def run_interactive(cmd)
121
- Aruba.platform.deprecated('The use of "#run_interactive" is deprecated. You can simply use "run" instead')
121
+ Aruba.platform.deprecated('The use of "#run_interactive" is deprecated. You can simply use "run_command" instead')
122
+
123
+ run_command(cmd)
124
+ end
125
+
126
+ # Run given command and stop it if timeout is reached
127
+ #
128
+ # @param [String] cmd
129
+ # The command which should be executed
130
+ #
131
+ # @param [Hash] opts
132
+ # Options
133
+ #
134
+ # @option [Integer] exit_timeout
135
+ # If the timeout is reached the command will be killed
136
+ #
137
+ # @option [Integer] io_wait_timeout
138
+ # Wait for IO to finish
139
+ #
140
+ # @option [Integer] startup_wait_time
141
+ # Wait for a command to start
142
+ #
143
+ # @option [String] stop_signal
144
+ # Use signal to stop command
145
+ #
146
+ # @yield [SpawnProcess]
147
+ # Run block with process
148
+ #
149
+ # @see #run_command
150
+ # @deprecated
151
+ def run(*args)
152
+ Aruba.platform.deprecated(
153
+ 'The use of "#run" is deprecated. Use "run_command" instead')
154
+
155
+ run_command(*args)
156
+ end
122
157
 
123
- run(cmd)
158
+ # Run a command with aruba
159
+ #
160
+ # Checks for error during command execution and checks the output to detect
161
+ # an timeout error.
162
+ #
163
+ # @param [String] cmd
164
+ # The command to be executed
165
+ #
166
+ # @param [Hash] options
167
+ # Options for aruba
168
+ #
169
+ # @option [TrueClass,FalseClass] fail_on_error
170
+ # Should aruba fail on error?
171
+ #
172
+ # @option [Integer] exit_timeout
173
+ # Timeout for execution
174
+ #
175
+ # @option [Integer] io_wait_timeout
176
+ # Timeout for IO - STDERR, STDOUT
177
+ #
178
+ # rubocop:disable Metrics/CyclomaticComplexity
179
+ # rubocop:disable Metrics/MethodLength
180
+ def run_simple(*args)
181
+ Aruba.platform.deprecated(
182
+ 'The use of "#run_simple" is deprecated. Use "run_command_and_stop" instead')
183
+
184
+ run_command_and_stop(*args)
124
185
  end
125
186
 
187
+
126
188
  # @deprecated
127
189
  # Create an empty file
128
190
  #
@@ -523,8 +585,6 @@ module Aruba
523
585
  end
524
586
 
525
587
  # @deprecated
526
- # rubocop:disable Metrics/CyclomaticComplexity
527
- # rubocop:disable Metrics/MethodLength
528
588
  def check_for_deprecated_variables
529
589
  if defined? @aruba_exit_timeout
530
590
  Aruba.platform.deprecated('The use of "@aruba_exit_timeout" is deprecated. Use "#aruba.config.exit_timeout = <numeric>" instead')
@@ -548,8 +608,6 @@ module Aruba
548
608
  aruba.config.root_directory = @aruba_root_directory.to_s
549
609
  end
550
610
  end
551
- # rubocop:enable Metrics/CyclomaticComplexity
552
- # rubocop:enable Metrics/MethodLength
553
611
 
554
612
  # Last command started
555
613
  def last_command
@@ -1,5 +1,5 @@
1
1
  require 'aruba/api/environment'
2
- require 'aruba/api/command'
2
+ require 'aruba/api/commands'
3
3
 
4
4
  # Aruba
5
5
  module Aruba
@@ -16,7 +16,7 @@ module Aruba
16
16
  # @param [String] gemset
17
17
  # The name of the gemset to be used
18
18
  def use_clean_gemset(gemset)
19
- run_simple(%{rvm gemset create "#{gemset}"}, true)
19
+ run_command_and_stop(%{rvm gemset create "#{gemset}"}, true)
20
20
  if all_stdout =~ /'#{gemset}' gemset created \((.*)\)\./
21
21
  gem_home = Regexp.last_match[1]
22
22
  set_environment_variable('GEM_HOME', gem_home)
@@ -27,7 +27,7 @@ module Aruba
27
27
  paths.unshift(File.join(gem_home, 'bin'))
28
28
  set_environment_variable('PATH', paths.uniq.join(File::PATH_SEPARATOR))
29
29
 
30
- run_simple("gem install bundler", true)
30
+ run_command_and_stop("gem install bundler", true)
31
31
  else
32
32
  raise "I didn't understand rvm's output: #{all_stdout}"
33
33
  end
@@ -57,7 +57,6 @@ module Aruba
57
57
  # @option [Object] default
58
58
  # The default value
59
59
  #
60
- # rubocop:disable Metrics/CyclomaticComplexity
61
60
  def option_accessor(name, opts = {})
62
61
  contract = opts[:contract]
63
62
  default = opts[:default]
@@ -75,7 +74,6 @@ module Aruba
75
74
  # Add reader
76
75
  option_reader name, :contract => { None => contract.values.first }
77
76
  end
78
- # rubocop:enable Metrics/CyclomaticComplexity
79
77
 
80
78
  private
81
79
 
@@ -46,7 +46,6 @@ module Aruba
46
46
  option_accessor :command_launcher, :contract => { Aruba::Contracts::Enum[:in_process, :spawn, :debug] => Aruba::Contracts::Enum[:in_process, :spawn, :debug] }, :default => :spawn
47
47
  # rubocop:enable Metrics/LineLength
48
48
  option_accessor :main_class, :contract => { Class => Maybe[Class] }, :default => nil
49
- # rubocop:disable Metrics/LineLength
50
49
 
51
50
  # rubocop:disable Metrics/LineLength
52
51
  if Aruba::VERSION >= '1.0.0'
@@ -35,7 +35,6 @@ module Aruba
35
35
  IRB.conf[:SAVE_HISTORY] = 1000
36
36
  IRB.conf[:HISTORY_FILE] = Aruba.config.console_history_file
37
37
 
38
- # rubocop:disable Lint/NestedMethodDefinition
39
38
  context = Class.new do
40
39
  include Aruba::Api
41
40
  include Aruba::Console::Help
@@ -48,7 +47,6 @@ module Aruba
48
47
  'nil'
49
48
  end
50
49
  end
51
- # rubocop:enable Lint/NestedMethodDefinition
52
50
 
53
51
  irb = IRB::Irb.new(IRB::WorkSpace.new(context.new))
54
52
  IRB.conf[:MAIN_CONTEXT] = irb.context
@@ -7,26 +7,26 @@ When(/^I run "(.*)"$/)do |cmd|
7
7
  warn(%{\e[35m The /^I run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
8
8
 
9
9
  cmd = sanitize_text(cmd)
10
- run_simple(cmd, false)
10
+ run_command_and_stop(cmd, false)
11
11
  end
12
12
 
13
13
  When(/^I run `([^`]*)`$/)do |cmd|
14
14
  cmd = sanitize_text(cmd)
15
- run_simple(cmd, :fail_on_error => false)
15
+ run_command_and_stop(cmd, :fail_on_error => false)
16
16
  end
17
17
 
18
18
  When(/^I successfully run "(.*)"$/)do |cmd|
19
19
  warn(%{\e[35m The /^I successfully run "(.*)"$/ step definition is deprecated. Please use the `backticks` version\e[0m})
20
20
 
21
21
  cmd = sanitize_text(cmd)
22
- run_simple(cmd)
22
+ run_command_and_stop(cmd)
23
23
  end
24
24
 
25
25
  ## I successfully run `echo -n "Hello"`
26
26
  ## I successfully run `sleep 29` for up to 30 seconds
27
27
  When(/^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/)do |cmd, secs|
28
28
  cmd = sanitize_text(cmd)
29
- run_simple(cmd, :fail_on_error => true, :exit_timeout => secs && secs.to_i)
29
+ run_command_and_stop(cmd, :fail_on_error => true, :exit_timeout => secs && secs.to_i)
30
30
  end
31
31
 
32
32
  When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) do |shell, commands|
@@ -48,12 +48,12 @@ end
48
48
 
49
49
  When(/^I run `([^`]*)` interactively$/)do |cmd|
50
50
  cmd = sanitize_text(cmd)
51
- @interactive = run(cmd)
51
+ @interactive = run_command(cmd)
52
52
  end
53
53
 
54
54
  # Merge interactive and background after refactoring with event queue
55
55
  When(/^I run `([^`]*)` in background$/)do |cmd|
56
- run(sanitize_text(cmd))
56
+ run_command(sanitize_text(cmd))
57
57
  end
58
58
 
59
59
  When(/^I type "([^"]*)"$/) do |input|