aruba 0.11.0.pre → 0.11.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/History.md +21 -1
  4. data/aruba.gemspec +1 -0
  5. data/features/api/command/find_command.feature +83 -0
  6. data/features/api/command/last_command_started.feature +50 -0
  7. data/features/api/command/last_command_stopped.feature +89 -0
  8. data/features/api/command/run.feature +259 -0
  9. data/features/api/command/stop.feature +53 -1
  10. data/features/api/text/replace_variables.feature +1 -1
  11. data/features/getting_started/run_commands.feature +177 -0
  12. data/features/matchers/file/be_existing_executable.feature +87 -0
  13. data/features/{integration/rspec/getting_started.feature → rspec/integration.feature} +31 -0
  14. data/fixtures/getting-started-app/Gemfile +1 -1
  15. data/lib/aruba.rb +0 -19
  16. data/lib/aruba/api.rb +2 -0
  17. data/lib/aruba/api/command.rb +103 -44
  18. data/lib/aruba/api/core.rb +13 -8
  19. data/lib/aruba/api/deprecated.rb +26 -4
  20. data/lib/aruba/api/environment.rb +21 -13
  21. data/lib/aruba/api/filesystem.rb +13 -0
  22. data/lib/aruba/api/rvm.rb +5 -0
  23. data/lib/aruba/api/text.rb +7 -1
  24. data/lib/aruba/aruba_path.rb +6 -0
  25. data/lib/aruba/basic_configuration.rb +35 -3
  26. data/lib/aruba/basic_configuration/option.rb +7 -0
  27. data/lib/aruba/cli.rb +4 -0
  28. data/lib/aruba/command.rb +47 -1
  29. data/lib/aruba/config.rb +15 -2
  30. data/lib/aruba/config_wrapper.rb +49 -8
  31. data/lib/aruba/console.rb +4 -1
  32. data/lib/aruba/console/help.rb +2 -0
  33. data/lib/aruba/contracts/absolute_path.rb +7 -0
  34. data/lib/aruba/contracts/enum.rb +5 -0
  35. data/lib/aruba/contracts/is_power_of_two.rb +9 -2
  36. data/lib/aruba/contracts/relative_path.rb +7 -0
  37. data/lib/aruba/cucumber/command.rb +6 -9
  38. data/lib/aruba/cucumber/file.rb +1 -1
  39. data/lib/aruba/cucumber/hooks.rb +36 -29
  40. data/lib/aruba/errors.rb +16 -1
  41. data/lib/aruba/events.rb +39 -0
  42. data/lib/aruba/extensions/string/strip.rb +1 -0
  43. data/lib/aruba/file_size.rb +11 -0
  44. data/lib/aruba/hooks.rb +2 -0
  45. data/lib/aruba/in_config_wrapper.rb +24 -0
  46. data/lib/aruba/in_process.rb +2 -0
  47. data/lib/aruba/initializer.rb +37 -0
  48. data/lib/aruba/matchers/base/base_matcher.rb +2 -0
  49. data/lib/aruba/matchers/base/object_formatter.rb +4 -0
  50. data/lib/aruba/matchers/collection/all.rb +2 -0
  51. data/lib/aruba/matchers/collection/include_an_object.rb +2 -0
  52. data/lib/aruba/matchers/command/have_exit_status.rb +1 -1
  53. data/lib/aruba/matchers/command/have_finished_in_time.rb +1 -10
  54. data/lib/aruba/matchers/command/have_output.rb +1 -10
  55. data/lib/aruba/matchers/command/have_output_on_stderr.rb +1 -10
  56. data/lib/aruba/matchers/command/have_output_on_stdout.rb +1 -10
  57. data/lib/aruba/matchers/file/be_an_existing_executable.rb +37 -0
  58. data/lib/aruba/platform.rb +4 -0
  59. data/lib/aruba/platforms/announcer.rb +225 -0
  60. data/lib/aruba/platforms/aruba_file_creator.rb +4 -0
  61. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +4 -0
  62. data/lib/aruba/{aruba_logger.rb → platforms/aruba_logger.rb} +4 -0
  63. data/lib/aruba/platforms/command_monitor.rb +229 -0
  64. data/lib/aruba/platforms/determine_disk_usage.rb +5 -0
  65. data/lib/aruba/platforms/determine_file_size.rb +9 -0
  66. data/lib/aruba/platforms/disk_usage_calculator.rb +9 -0
  67. data/lib/aruba/platforms/local_environment.rb +12 -0
  68. data/lib/aruba/platforms/simple_table.rb +11 -0
  69. data/lib/aruba/platforms/unix_command_string.rb +3 -0
  70. data/lib/aruba/platforms/unix_environment_variables.rb +3 -0
  71. data/lib/aruba/platforms/unix_platform.rb +20 -2
  72. data/lib/aruba/platforms/unix_which.rb +6 -2
  73. data/lib/aruba/platforms/windows_command_string.rb +7 -0
  74. data/lib/aruba/platforms/windows_environment_variables.rb +2 -0
  75. data/lib/aruba/platforms/windows_platform.rb +3 -0
  76. data/lib/aruba/platforms/windows_which.rb +6 -2
  77. data/lib/aruba/processes/basic_process.rb +20 -5
  78. data/lib/aruba/processes/debug_process.rb +3 -1
  79. data/lib/aruba/processes/in_process.rb +18 -2
  80. data/lib/aruba/processes/spawn_process.rb +14 -13
  81. data/lib/aruba/rspec.rb +34 -23
  82. data/lib/aruba/runtime.rb +65 -6
  83. data/lib/aruba/setup.rb +87 -0
  84. data/lib/aruba/version.rb +1 -1
  85. data/spec/aruba/api_spec.rb +13 -36
  86. data/spec/aruba/{config_wrapper_spec.rb → in_config_wrapper_spec.rb} +1 -1
  87. data/spec/aruba/spawn_process_spec.rb +9 -14
  88. data/spec/support/configs/pry.rb +3 -0
  89. data/spec/support/shared_contexts/aruba.rb +1 -0
  90. metadata +40 -14
  91. data/features/getting_started/supported_programming_languages.feature +0 -89
  92. data/lib/aruba/announcer.rb +0 -219
  93. data/lib/aruba/matchers/rspec.rb +0 -0
  94. data/lib/aruba/process_monitor.rb +0 -201
  95. data/lib/aruba/processes/null_process.rb +0 -26
@@ -3,11 +3,63 @@ Feature: Stop command
3
3
  To stop commands via API you can do the following:
4
4
 
5
5
  - `last_command_started.stop`
6
- - `stop_all_commands`
6
+ - `find_command('command').stop`
7
+
8
+ But normally there's no need to stop a command manually. All matchers
9
+ handling commands make sure, that they stop ALL command before check actual
10
+ against expected.
7
11
 
8
12
  Background:
9
13
  Given I use a fixture named "cli-app"
10
14
 
15
+ Scenario: Stop command started last
16
+ Given an executable named "bin/cli" with:
17
+ """bash
18
+ #!/bin/bash
19
+ function term {
20
+ exit 0
21
+ }
22
+
23
+ trap term TERM
24
+ while [ true ]; do sleep 1; done
25
+ """
26
+ And a file named "spec/run_spec.rb" with:
27
+ """ruby
28
+ require 'spec_helper'
29
+
30
+ RSpec.describe 'Run command', :type => :aruba do
31
+ before(:each) { run('cli') }
32
+ before(:each) { last_command_started.stop }
33
+ it { expect(last_command_started).to be_successfully_executed }
34
+ end
35
+ """
36
+ When I run `rspec`
37
+ Then the specs should all pass
38
+
39
+ Scenario: Find and stop command
40
+ Given an executable named "bin/cli" with:
41
+ """bash
42
+ #!/bin/bash
43
+ function term {
44
+ exit 0
45
+ }
46
+
47
+ trap term TERM
48
+ while [ true ]; do sleep 1; done
49
+ """
50
+ And a file named "spec/run_spec.rb" with:
51
+ """ruby
52
+ require 'spec_helper'
53
+
54
+ RSpec.describe 'Run command', :type => :aruba do
55
+ before(:each) { run('cli') }
56
+ before(:each) { find_command('cli').stop }
57
+ it { expect(last_command_started).to be_successfully_executed }
58
+ end
59
+ """
60
+ When I run `rspec`
61
+ Then the specs should all pass
62
+
11
63
  Scenario: Stop successful command with configured signal
12
64
  Given an executable named "bin/cli" with:
13
65
  """bash
@@ -37,7 +37,7 @@ Feature: Replace variables
37
37
  require 'spec_helper'
38
38
 
39
39
  RSpec.describe 'Run command', :type => :aruba do
40
- it { expect(replace_variables('<pid-last-command-started>')).to eq '0' }
40
+ it { expect { replace_variables('<pid-last-command-started>') }.to raise_error Aruba::NoCommandHasBeenStartedError }
41
41
  end
42
42
  """
43
43
  When I run `rspec`
@@ -0,0 +1,177 @@
1
+ Feature: Run commands with Aruba
2
+
3
+ As long as you've got the neccessary programs, libraries, runtime
4
+ environments, interpreters installed, it doesn't matter in which programming
5
+ language your commandline application is implemented. You can even use POSIX
6
+ standard tools like "printf".
7
+
8
+ Below you find some examples of the "Hello, Aruba!"-application implemented
9
+ with different programming languages and a single example for a POSIX
10
+ standard tool. This is NOT an exclusive list. Every commandline application
11
+ should run with `aruba`.
12
+
13
+ Background:
14
+ Given I use a fixture named "getting-started-app"
15
+ And a file named "features/hello_aruba.feature" with:
16
+ """
17
+ Feature: Getting Started With Aruba
18
+ Scenario: First Run of Command
19
+ Given I successfully run `cli`
20
+ Then the output should contain:
21
+ \"\"\"
22
+ Hello, Aruba!
23
+ \"\"\"
24
+ """
25
+
26
+ Scenario: Bash Program
27
+ Given an executable named "bin/cli" with:
28
+ """bash
29
+ #!/usr/bin/env bash
30
+
31
+ echo "Hello, Aruba!"
32
+ """
33
+ When I successfully run `cucumber`
34
+ Then the features should all pass
35
+
36
+ Scenario: Bash Program run via bash
37
+ Given a file named "features/hello_aruba.feature" with:
38
+ """
39
+ Feature: Getting Started With Aruba
40
+ Scenario: First Run of Command
41
+ Given a file named "cli.sh" with:
42
+ \"\"\"
43
+ echo "Hello, Aruba!"
44
+ \"\"\"
45
+ When I successfully run `bash ./cli.sh`
46
+ Then the output should contain:
47
+ \"\"\"
48
+ Hello, Aruba!
49
+ \"\"\"
50
+ """
51
+ When I successfully run `cucumber`
52
+ Then the features should all pass
53
+
54
+ Scenario: Ruby Program
55
+ Given an executable named "bin/cli" with:
56
+ """ruby
57
+ #!/usr/bin/env ruby
58
+
59
+ puts "Hello, Aruba!"
60
+ """
61
+ When I successfully run `cucumber`
62
+ Then the features should all pass
63
+
64
+ Scenario: Ruby Program via "ruby"
65
+ Given a file named "features/hello_aruba.feature" with:
66
+ """
67
+ Feature: Getting Started With Aruba
68
+ Scenario: First Run of Command
69
+ Given a file named "cli.rb" with:
70
+ \"\"\"
71
+ puts "Hello, Aruba!"
72
+ \"\"\"
73
+ When I successfully run `ruby ./cli.rb`
74
+ Then the output should contain:
75
+ \"\"\"
76
+ Hello, Aruba!
77
+ \"\"\"
78
+ """
79
+ When I successfully run `cucumber`
80
+ Then the features should all pass
81
+
82
+ Scenario: Python Program
83
+ Given an executable named "bin/cli" with:
84
+ """python
85
+ #!/usr/bin/env python
86
+
87
+ print("Hello, Aruba!")
88
+ """
89
+ When I successfully run `cucumber`
90
+ Then the features should all pass
91
+
92
+ Scenario: Python Program via "python"
93
+ Given a file named "features/hello_aruba.feature" with:
94
+ """
95
+ Feature: Getting Started With Aruba
96
+ Scenario: First Run of Command
97
+ Given a file named "cli.py" with:
98
+ \"\"\"
99
+ print("Hello, Aruba!")
100
+ \"\"\"
101
+ When I successfully run `python ./cli.py`
102
+ Then the output should contain:
103
+ \"\"\"
104
+ Hello, Aruba!
105
+ \"\"\"
106
+ """
107
+ When I successfully run `cucumber`
108
+ Then the features should all pass
109
+
110
+ Scenario: Perl Program
111
+ Given an executable named "bin/cli" with:
112
+ """perl
113
+ #!/usr/bin/env perl
114
+
115
+ print "Hello, Aruba!\n";
116
+ """
117
+ When I successfully run `cucumber`
118
+ Then the features should all pass
119
+
120
+ Scenario: Perl Program via "perl"
121
+ Given a file named "features/hello_aruba.feature" with:
122
+ """
123
+ Feature: Getting Started With Aruba
124
+ Scenario: First Run of Command
125
+ Given a file named "cli.pl" with:
126
+ \"\"\"perl
127
+ print "Hello, Aruba!\n";
128
+ \"\"\"
129
+ When I successfully run `perl ./cli.pl`
130
+ Then the output should contain:
131
+ \"\"\"
132
+ Hello, Aruba!
133
+ \"\"\"
134
+ """
135
+ When I successfully run `cucumber`
136
+ Then the features should all pass
137
+
138
+ Scenario: Java Program
139
+
140
+ It's even possible to compile and run Java programs with Aruba.
141
+
142
+ Given a file named "features/hello_aruba.feature" with:
143
+ """cucumber
144
+ Feature: Getting Started With Aruba
145
+ Scenario: First Run of Command
146
+ Given a file named "tmp/HelloArubaApp.java" with:
147
+ \"\"\"
148
+ class HelloArubaApp {
149
+ public static void main(String[] args) {
150
+ System.out.println("Hello, Aruba!");
151
+ }
152
+ }
153
+ \"\"\"
154
+ And I successfully run `javac tmp/HelloArubaApp.java`
155
+ And I cd to "tmp/"
156
+ And I successfully run `java HelloArubaApp`
157
+ Then the output should contain:
158
+ \"\"\"
159
+ Hello, Aruba!
160
+ \"\"\"
161
+ """
162
+ When I successfully run `cucumber`
163
+ Then the features should all pass
164
+
165
+ Scenario: POSIX standard tools
166
+ Given a file named "features/hello_aruba.feature" with:
167
+ """
168
+ Feature: Getting Started With Aruba
169
+ Scenario: First Run of Command
170
+ Given I successfully run `printf "%s" "Hello, Aruba!"`
171
+ Then the output should contain:
172
+ \"\"\"
173
+ Hello, Aruba!
174
+ \"\"\"
175
+ """
176
+ When I successfully run `cucumber`
177
+ Then the features should all pass
@@ -0,0 +1,87 @@
1
+ Feature: Check if path exists and is an executable file
2
+
3
+ If you need to check if a given path exists and is a file, you can use the
4
+ `be_an_existing_executable`-matcher.
5
+
6
+ ```ruby
7
+ require 'spec_helper'
8
+
9
+ RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
10
+ let(:file) { 'file.txt' }
11
+ before(:each) { touch(file) }
12
+
13
+ it { expect(file).to be_an_existing_executable }
14
+ end
15
+ ```
16
+
17
+ Background:
18
+ Given I use a fixture named "cli-app"
19
+
20
+ Scenario: Expect single existing executable file
21
+ Given a file named "spec/existing_executable_spec.rb" with:
22
+ """
23
+ require 'spec_helper'
24
+
25
+ RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
26
+ let(:file) { 'file.txt' }
27
+ before(:each) { touch(file) }
28
+ before(:each) { chmod(0755, file) }
29
+
30
+ it { expect(file).to be_an_existing_executable }
31
+ end
32
+ """
33
+ When I run `rspec`
34
+ Then the specs should all pass
35
+
36
+ Scenario: Expect single non-existing executable file
37
+ Given a file named "spec/existing_executable_spec.rb" with:
38
+ """
39
+ require 'spec_helper'
40
+
41
+ RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
42
+ let(:file) { 'file.txt' }
43
+ it { expect(file).not_to be_an_existing_executable }
44
+ end
45
+ """
46
+ When I run `rspec`
47
+ Then the specs should all pass
48
+
49
+ Scenario: Expect multiple existing executable files
50
+ Given a file named "spec/existing_executable_spec.rb" with:
51
+ """
52
+ require 'spec_helper'
53
+
54
+ RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
55
+ let(:files) { %w(file1.txt file2.txt) }
56
+
57
+ before :each do
58
+ files.each do |f|
59
+ touch(f)
60
+ chmod(0755, f)
61
+ end
62
+ end
63
+
64
+ it { expect(files).to all be_an_existing_executable }
65
+ end
66
+ """
67
+ When I run `rspec`
68
+ Then the specs should all pass
69
+
70
+ Scenario: Expect a least one existing executable file
71
+ Given a file named "spec/existing_executable_spec.rb" with:
72
+ """
73
+ require 'spec_helper'
74
+
75
+ RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
76
+ let(:files) { %w(file1.txt file2.txt) }
77
+
78
+ before :each do
79
+ touch(files.first)
80
+ chmod(0755, files.first)
81
+ end
82
+
83
+ it { expect(files).to include an_existing_executable }
84
+ end
85
+ """
86
+ When I run `rspec`
87
+ Then the specs should all pass
@@ -117,6 +117,35 @@ Feature: Getting started with RSpec and aruba
117
117
  When I run `rspec`
118
118
  Then the specs should all pass
119
119
 
120
+ Scenario: Setup aruba before use any of it's methods
121
+
122
+ From 1.0.0 it will be required, that you setup aruba before you use it.
123
+
124
+ Given a file named "spec/spec_helper.rb" with:
125
+ """
126
+ require 'aruba/api'
127
+
128
+ RSpec.configure do |config|
129
+ config.include Aruba::Api
130
+ end
131
+ """
132
+ And a file named "spec/getting_started_spec.rb" with:
133
+ """
134
+ require 'spec_helper'
135
+
136
+ RSpec.describe 'Custom Integration of aruba' do
137
+ let(:file) { 'file.txt' }
138
+
139
+ before(:each) { setup_aruba }
140
+
141
+ it { expect(true).to be true }
142
+ end
143
+ """
144
+ And an empty file named "tmp/aruba/garbage.txt"
145
+ When I run `rspec`
146
+ Then the specs should all pass
147
+ And the file "tmp/aruba/garbage.txt" should not exist anymore
148
+
120
149
  Scenario: Fail-safe use if "setup_aruba" is not used
121
150
 
122
151
  If you forgot to run `setup_aruba` before the first method of aruba is
@@ -125,6 +154,8 @@ Feature: Getting started with RSpec and aruba
125
154
  Make sure that you run `setup_aruba` before any method of aruba is used. At
126
155
  best before each and every test.
127
156
 
157
+ This will be not supported anymore from 1.0.0 on.
158
+
128
159
  Given a file named "spec/spec_helper.rb" with:
129
160
  """
130
161
  require 'aruba/api'
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'cucumber'
4
- gem 'aruba'
4
+ gem 'aruba', path: File.expand_path('../../../../', __FILE__)
data/lib/aruba.rb CHANGED
@@ -1,20 +1 @@
1
- # require 'contracts'
2
-
3
- # require 'fileutils'
4
- # require 'rbconfig'
5
- # require 'ostruct'
6
- # require 'pathname'
7
-
8
- # require 'aruba/hooks'
9
- # require 'aruba/basic_configuration'
10
- # require 'aruba/config_wrapper'
11
- # require 'aruba/config'
12
-
13
- # require 'aruba/announcer'
14
- # require 'aruba/process_monitor'
15
- # require 'aruba/runtime'
16
-
17
- # require 'aruba/platform'
18
- # require 'aruba/spawn_process'
19
-
20
1
  require 'aruba/api'
data/lib/aruba/api.rb CHANGED
@@ -19,7 +19,9 @@ require 'aruba/api/rvm'
19
19
 
20
20
  Aruba.platform.require_matching_files('../matchers/**/*.rb', __FILE__)
21
21
 
22
+ # Aruba
22
23
  module Aruba
24
+ # Api
23
25
  module Api
24
26
  include Aruba::Api::Core
25
27
  include Aruba::Api::Commands
@@ -1,11 +1,11 @@
1
1
  require 'pathname'
2
2
 
3
3
  require 'aruba/platform'
4
- require 'aruba/process_monitor'
5
4
  require 'aruba/command'
6
5
 
7
6
  # require 'win32/file' if File::ALT_SEPARATOR
8
7
 
8
+ # Aruba
9
9
  module Aruba
10
10
  class << self
11
11
  # @deprecated
@@ -16,8 +16,11 @@ module Aruba
16
16
  # self.process = Aruba::Processes::SpawnProcess
17
17
  end
18
18
 
19
+ # Aruba
19
20
  module Aruba
21
+ # Api
20
22
  module Api
23
+ # Command module
21
24
  module Commands
22
25
  # Resolve path for command using the PATH-environment variable
23
26
  #
@@ -53,31 +56,17 @@ module Aruba
53
56
  # @return [Array]
54
57
  # List of commands
55
58
  def all_commands
56
- process_monitor.all_commands
57
- end
58
-
59
- # @private
60
- def process_monitor
61
- return @process_monitor if defined? @process_monitor
62
-
63
- @process_monitor = ProcessMonitor.new(announcer)
64
-
65
- @process_monitor
66
- end
67
-
68
- # @private
69
- def processes
70
- process_monitor.send(:processes)
59
+ aruba.command_monitor.registered_commands
71
60
  end
72
61
 
73
62
  # Last command started
74
63
  def last_command_started
75
- process_monitor.last_command_started
64
+ aruba.command_monitor.last_command_started
76
65
  end
77
66
 
78
67
  # Last command stopped
79
68
  def last_command_stopped
80
- process_monitor.last_command_stopped
69
+ aruba.command_monitor.last_command_stopped
81
70
  end
82
71
 
83
72
  # Stop all commands
@@ -92,7 +81,7 @@ module Aruba
92
81
  all_commands
93
82
  end
94
83
 
95
- cmds.each { |c| c.stop(announcer) }
84
+ cmds.each(&:stop)
96
85
 
97
86
  self
98
87
  end
@@ -114,27 +103,61 @@ module Aruba
114
103
  self
115
104
  end
116
105
 
106
+ # Find a started command
107
+ #
108
+ # @param [String, Command] commandline
109
+ # The commandline
110
+ def find_command(commandline)
111
+ aruba.command_monitor.find(commandline)
112
+ end
113
+
117
114
  # Run given command and stop it if timeout is reached
118
115
  #
119
116
  # @param [String] cmd
120
117
  # The command which should be executed
121
118
  #
122
- # @param [Integer] timeout
119
+ # @param [Hash] opts
120
+ # Options
121
+ #
122
+ # @option [Integer] exit_timeout
123
123
  # If the timeout is reached the command will be killed
124
124
  #
125
- # @param [String] stop_signal
126
- # Use signal to stop command (Private)
125
+ # @option [Integer] io_wait_timeout
126
+ # Wait for IO to finish
127
+ #
128
+ # @option [Integer] startup_wait_time
129
+ # Wait for a command to start
130
+ #
131
+ # @option [String] stop_signal
132
+ # Use signal to stop command
127
133
  #
128
134
  # @yield [SpawnProcess]
129
135
  # Run block with process
130
136
  #
131
137
  # rubocop:disable Metrics/MethodLength
132
138
  # rubocop:disable Metrics/CyclomaticComplexity
133
- def run(cmd, exit_timeout = nil, io_wait_timeout = nil, stop_signal = nil, startup_wait_time = nil)
134
- exit_timeout ||= aruba.config.exit_timeout
135
- io_wait_timeout ||= aruba.config.io_wait_timeout
136
- stop_signal ||= aruba.config.stop_signal
137
- startup_wait_time ||= aruba.config.startup_wait_time
139
+ def run(*args)
140
+ fail ArgumentError, 'Please pass at least a command as first argument.' if args.size < 1
141
+
142
+ cmd = args.shift
143
+
144
+ if args.last.is_a? Hash
145
+ opts = args.pop
146
+
147
+ exit_timeout = opts.fetch(:exit_timeout, aruba.config.exit_timeout)
148
+ io_wait_timeout = opts.fetch(:io_wait_timeout, aruba.config.io_wait_timeout)
149
+ stop_signal = opts.fetch(:stop_signal, aruba.config.stop_signal)
150
+ startup_wait_time = opts.fetch(:startup_wait_time, aruba.config.startup_wait_time)
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)`.")
154
+ end
155
+
156
+ exit_timeout = args[0] || aruba.config.exit_timeout
157
+ io_wait_timeout = args[1] || aruba.config.io_wait_timeout
158
+ stop_signal = args[2] || aruba.config.stop_signal
159
+ startup_wait_time = args[3] || aruba.config.startup_wait_time
160
+ end
138
161
 
139
162
  cmd = replace_variables(cmd)
140
163
 
@@ -143,16 +166,17 @@ module Aruba
143
166
 
144
167
  environment = aruba.environment.to_h
145
168
  working_directory = expand_path('.')
169
+ event_bus = aruba.event_bus
146
170
 
147
- announcer.announce(:full_environment, environment)
148
- announcer.announce(:timeout, 'exit', exit_timeout)
149
- announcer.announce(:timeout, 'io wait', io_wait_timeout)
150
- announcer.announce(:wait_time, 'startup wait time', startup_wait_time)
171
+ aruba.announcer.announce(:full_environment, environment)
172
+ aruba.announcer.announce(:timeout, 'exit', exit_timeout)
173
+ aruba.announcer.announce(:timeout, 'io wait', io_wait_timeout)
174
+ aruba.announcer.announce(:wait_time, 'startup wait time', startup_wait_time)
151
175
 
152
- announcer.announce(:directory, working_directory)
153
- announcer.announce(:command, cmd)
176
+ aruba.announcer.announce(:directory, working_directory)
177
+ aruba.announcer.announce(:command, cmd)
154
178
 
155
- cmd = Aruba.platform.detect_ruby(cmd)
179
+ cmd = Aruba.platform.detect_ruby(cmd)
156
180
 
157
181
  mode = if Aruba.process
158
182
  # rubocop:disable Metrics/LineLength
@@ -181,7 +205,8 @@ module Aruba
181
205
  :environment => environment,
182
206
  :main_class => main_class,
183
207
  :stop_signal => stop_signal,
184
- :startup_wait_time => startup_wait_time
208
+ :startup_wait_time => startup_wait_time,
209
+ :event_bus => event_bus
185
210
  )
186
211
 
187
212
  if aruba.config.before? :cmd
@@ -192,11 +217,9 @@ module Aruba
192
217
  end
193
218
 
194
219
  aruba.config.before(:command, self, command)
195
-
196
- process_monitor.register_process(cmd, command)
197
220
  command.start
198
221
 
199
- announcer.announce(:stop_signal, command.pid, stop_signal) if stop_signal
222
+ aruba.announcer.announce(:stop_signal, command.pid, stop_signal) if stop_signal
200
223
 
201
224
  aruba.config.after(:command, self, command)
202
225
 
@@ -213,22 +236,58 @@ module Aruba
213
236
  # @param [String] cmd
214
237
  # The command to be executed
215
238
  #
216
- # @param [TrueClass,FalseClass] fail_on_error
239
+ # @param [Hash] options
240
+ # Options for aruba
241
+ #
242
+ # @option [TrueClass,FalseClass] fail_on_error
217
243
  # Should aruba fail on error?
218
244
  #
219
- # @param [Integer] timeout
245
+ # @option [Integer] exit_timeout
220
246
  # Timeout for execution
221
- def run_simple(cmd, fail_on_error = true, exit_timeout = nil, io_wait_timeout = nil)
222
- command = run(cmd, exit_timeout, io_wait_timeout)
223
- @last_exit_status = process_monitor.stop_process(command)
247
+ #
248
+ # @option [Integer] io_wait_timeout
249
+ # Timeout for IO - STDERR, STDOUT
250
+ #
251
+ # rubocop:disable Metrics/CyclomaticComplexity
252
+ # rubocop:disable Metrics/MethodLength
253
+ def run_simple(*args)
254
+ fail ArgumentError, 'Please pass at least a command as first argument.' if args.size < 1
255
+
256
+ cmd = args.shift
257
+
258
+ if args.last.is_a? Hash
259
+ opts = args.pop
260
+
261
+ fail_on_error = opts.fetch(:fail_on_error, false) || false
262
+ exit_timeout = opts.fetch(:exit_timeout, aruba.config.exit_timeout) || aruba.config.exit_timeout
263
+ io_wait_timeout = opts.fetch(:io_wait_timeout, aruba.config.io_wait_timeout) || aruba.config.io_wait_timeout
264
+ else
265
+ if args.size > 1
266
+ # rubocop:disable Metrics/LineLength
267
+ 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)`.")
268
+ # rubocop:enable Metrics/LineLength
269
+ end
270
+
271
+ fail_on_error = args[0] || true
272
+ exit_timeout = args[1] || aruba.config.exit_timeout
273
+ io_wait_timeout = args[2] || aruba.config.io_wait_timeout
274
+ end
275
+
276
+ command = run(cmd, :exit_timeout => exit_timeout, :io_wait_timeout => io_wait_timeout)
277
+ command.stop
224
278
 
225
- @timed_out = command.timed_out?
279
+ if Aruba::VERSION < '1'
280
+ @last_exit_status = command.exit_status
281
+ @timed_out = command.timed_out?
282
+ end
226
283
 
227
284
  if fail_on_error
228
285
  expect(command).to have_finished_in_time
229
286
  expect(command).to be_successfully_executed
230
287
  end
231
288
  end
289
+ # rubocop:enable Metrics/CyclomaticComplexity
290
+ # rubocop:enable Metrics/MethodLength
232
291
 
233
292
  # Provide data to command via stdin
234
293
  #