aruba 0.10.2 → 0.11.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -5
  3. data/Gemfile +0 -4
  4. data/History.md +17 -1
  5. data/features/api/command/run.feature +101 -1
  6. data/features/api/command/send_signal.feature +53 -0
  7. data/features/api/command/stop.feature +79 -0
  8. data/features/api/text/replace_variables.feature +45 -0
  9. data/features/configuration/startup_wait_time.feature +48 -0
  10. data/features/step_definitions/hooks.rb +85 -6
  11. data/features/steps/{commands → command}/exit_statuses.feature +0 -0
  12. data/features/steps/{commands → command}/in_process.feature +174 -0
  13. data/features/steps/{commands → command}/run.feature +1 -0
  14. data/features/steps/command/send_signal.feature +104 -0
  15. data/features/steps/command/stop.feature +313 -0
  16. data/features/steps/overview.feature +60 -0
  17. data/lib/aruba/announcer.rb +2 -0
  18. data/lib/aruba/api/command.rb +24 -9
  19. data/lib/aruba/api/text.rb +9 -0
  20. data/lib/aruba/command.rb +4 -1
  21. data/lib/aruba/config.rb +2 -0
  22. data/lib/aruba/cucumber/command.rb +75 -0
  23. data/lib/aruba/cucumber/core.rb +0 -24
  24. data/lib/aruba/cucumber/hooks.rb +10 -0
  25. data/lib/aruba/errors.rb +3 -0
  26. data/lib/aruba/matchers/command/have_output.rb +1 -1
  27. data/lib/aruba/process_monitor.rb +25 -1
  28. data/lib/aruba/processes/basic_process.rb +22 -2
  29. data/lib/aruba/processes/debug_process.rb +7 -1
  30. data/lib/aruba/processes/in_process.rb +15 -1
  31. data/lib/aruba/processes/null_process.rb +26 -0
  32. data/lib/aruba/processes/spawn_process.rb +81 -48
  33. data/lib/aruba/rspec.rb +6 -0
  34. data/lib/aruba/version.rb +1 -1
  35. metadata +26 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce4f4fe54f79eca8c6cfc08194256c53dd705c0b
4
- data.tar.gz: 051de04325eb5ea8d638c23f8ea72740ede9ff72
3
+ metadata.gz: d0d970f3502a082de16bb266924f0c7900377b76
4
+ data.tar.gz: 011f90e024a29624795ad9883d29b8547c3fdeda
5
5
  SHA512:
6
- metadata.gz: bc5656959786aaf00ad27c1215309176bfbf3dd07693ccd23c96305eb34fb185d663a933645d04907d3722d022b186f0f9356c427be612d75825f1bd3dfc113c
7
- data.tar.gz: 9d0a45ca8b640fcd8fed7df60d3480304f65069bc7b4c978834c1f448977aa11df024f6e00413f02f8a81cb44e9764c505c76caee8ab741639d4d014f062fb2d
6
+ metadata.gz: e769fd6414236a83911ef5e5c3a068ea88f8795d2de079ae140b834b452fc0a89167ff2e7466fed1a88c920105cd884652d791d5d246d20361da5fbe763f3faa
7
+ data.tar.gz: e2415039514fa5fa15ebf0649e13aaafaf339f77348c5a1167b792f08ea7c7c31ba37eb9af6cf1dae1f54cdb40634d90cc8a0dbc97479fd84a43b668a2e5f0ec
data/.travis.yml CHANGED
@@ -3,8 +3,8 @@ language: ruby
3
3
  script: script/test
4
4
  install: script/bootstrap --without development debug
5
5
  rvm:
6
- - 2.2.2
7
- - 2.1.6
6
+ - 2.2.3
7
+ - 2.1.7
8
8
  - 2.0.0
9
9
  - 1.9.2
10
10
  - 1.9.3
@@ -24,9 +24,10 @@ matrix:
24
24
  - rvm: jruby-9.0.0.0-21mode
25
25
  notifications:
26
26
  email:
27
- - cukes-devs@googlegroups.com
28
- irc:
29
- - irc.freenode.org#cucumber
27
+ - cukes-devs@googlegroups.com
28
+ webhooks:
29
+ urls:
30
+ - https://webhooks.gitter.im/e/d4d9080e2a8c4910f609
30
31
  env:
31
32
  global:
32
33
  - secure: l8uznA5K4K9mZ1krmP3lTMD8WcJ32qGxFOR3jubKHcOBSLB4xSzU2aIqjyJdO+rLzebkwamhJc8pGSIWOUDQYvFiX7splK+uEkbBJ5huAhXtLF4Qgl86bCWbEXYzN7rvn0DQfpJAovyFMNRMnfo70XhwqWzFsaYa7Z0YbqYsJE4=
data/Gemfile CHANGED
@@ -15,10 +15,6 @@ group :debug do
15
15
  gem 'pry-debugger', '~> 0.2.3'
16
16
  end
17
17
 
18
- if RUBY_VERSION >= '1.9.3' && !RUBY_PLATFORM.include?('java')
19
- gem 'pry-stack_explorer', '~> 0.4.9'
20
- end
21
-
22
18
  gem 'pry-doc', '~> 0.8.0'
23
19
  end
24
20
 
data/History.md CHANGED
@@ -1,14 +1,30 @@
1
1
  # Latest Release
2
2
 
3
+ ## [v0.11.0.pre](https://github.com/cucumber/aruba/compare/v0.10.2...v0.11.0.pre)
4
+
5
+ * Set stop signal which should be used to stop a process after a timeout or
6
+ used to terminate a process. This can be used to stop processes running
7
+ docker + "systemd". If you send a systemd-enable container SIGINT it will be
8
+ stopped.
9
+ * Added a configurable amount of time after a command was started -
10
+ startup_wait_time. Otherwise you get problems when a process takes to long to
11
+ startup when you run in background and want to sent it a signal.
12
+ * Replace `<variable>` in commandline, e.g. `<pid-last-command-started>`
13
+ [experimental]
14
+ * Added announce formatter for time spans, e.g. `startup_wait_time`
15
+ * All `*Process`-classes e.g. `BasicProcess`, `SpawnProcess` etc. are marked as
16
+ private. Users should use `#run('cmd')` and don't use the classes directly.
17
+
3
18
  ## [v0.10.2](https://github.com/cucumber/aruba/compare/v0.10.1...v0.10.2)
4
19
 
5
20
  * Fixed problem in regex after merge of step definitions
6
21
 
22
+ # Old releases
23
+
7
24
  ## [v0.10.1](https://github.com/cucumber/aruba/compare/v0.10.0...v0.10.1)
8
25
 
9
26
  * Merged remove steps for file and directory from 4 into 2 step definitions
10
27
 
11
- # Old releases
12
28
 
13
29
  ## [v0.10.0](https://github.com/cucumber/aruba/compare/v0.10.0.pre2...v0.10.0)
14
30
 
@@ -1,6 +1,24 @@
1
1
  Feature: Run command
2
2
 
3
- To run a command use the `#run`-method.
3
+ To run a command use the `#run`-method. There are some configuration options
4
+ which are relevant here:
5
+
6
+ - `startup_wait_time`:
7
+
8
+ Given this option `aruba` waits n seconds after it started the command.
9
+ This is most useful when using `#run()` and not really makes sense for
10
+ `#run_simple()`.
11
+
12
+ You can use `#run()` + `startup_wait_time` to start background jobs.
13
+
14
+ - `exit_timeout`:
15
+
16
+ The exit timeout is used, when `aruba` waits for a command to finished.
17
+
18
+ - `io_wait_timeout`:
19
+
20
+ The io wait timeout is used, when you access `stdout` or `stderr` of a
21
+ command.
4
22
 
5
23
  Background:
6
24
  Given I use a fixture named "cli-app"
@@ -53,3 +71,85 @@ Feature: Run command
53
71
  """
54
72
  When I run `rspec`
55
73
  Then the specs should all pass
74
+
75
+ Scenario: Command with long startup phase
76
+
77
+ If you have got a command with a long startup phase or use `ruby` together
78
+ with `bundler`, you should consider using the `startup_wait_time`-option.
79
+ Otherwise methods like `#send_signal` don't work since they require the
80
+ command to be running and have setup it's signal handler.
81
+
82
+ Given an executable named "bin/cli" with:
83
+ """bash
84
+ #!/usr/bin/env bash
85
+
86
+ function initialize_script {
87
+ sleep 2
88
+ }
89
+
90
+ function do_some_work {
91
+ echo "Hello, Aruba is working"
92
+ }
93
+
94
+ function recurring_work {
95
+ echo "Hello, Aruba here"
96
+ }
97
+
98
+ function stop_script {
99
+ exit 0
100
+ }
101
+
102
+ trap recurring_work HUP
103
+ trap stop_script TERM
104
+
105
+ initialize_script
106
+ do_some_work
107
+
108
+ while [ true ]; do sleep 1; done
109
+ """
110
+ And a file named "spec/run_spec.rb" with:
111
+ """ruby
112
+ require 'spec_helper'
113
+
114
+ RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 2 do
115
+ before(:each) { run('cli') }
116
+ before(:each) { last_command_started.send_signal 'HUP' }
117
+
118
+ it { expect(last_command_started).to be_successfully_executed }
119
+ it { expect(last_command_started).to have_output /Hello, Aruba is working/ }
120
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
121
+
122
+ end
123
+ """
124
+ When I run `rspec`
125
+ Then the specs should all pass
126
+
127
+ Scenario: Long running command
128
+
129
+ If you have got a "long running" command, you should consider using the
130
+ `exit_timeout`-option.
131
+
132
+ Given an executable named "bin/cli" with:
133
+ """bash
134
+ #!/usr/bin/env bash
135
+
136
+ function do_some_work {
137
+ sleep 2
138
+ echo "Hello, Aruba here"
139
+ }
140
+
141
+ do_some_work
142
+ """
143
+ And a file named "spec/run_spec.rb" with:
144
+ """ruby
145
+ require 'spec_helper'
146
+
147
+ RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 3 do
148
+ before(:each) { run('cli') }
149
+
150
+ it { expect(last_command_started).to be_successfully_executed }
151
+ it { expect(last_command_started).to have_output /Hello, Aruba here/ }
152
+ end
153
+ """
154
+ When I run `rspec`
155
+ Then the specs should all pass
@@ -0,0 +1,53 @@
1
+ Feature: Send running command a signal
2
+
3
+ You can send a running command a signal using
4
+ `last_command_started#send_signal`. This is only supported with
5
+ `aruba.config.command_launcher = :spawn` (default).
6
+
7
+ Background:
8
+ Given I use a fixture named "cli-app"
9
+
10
+ Scenario: Existing executable
11
+ Given an executable named "bin/cli" with:
12
+ """ruby
13
+ #!/usr/bin/env bash
14
+
15
+ function hup {
16
+ echo 'Exit...' >&2
17
+ exit 0
18
+ }
19
+
20
+ trap hup HUP
21
+
22
+ while [ true ]; do sleep 1; done
23
+ """
24
+ And a file named "spec/run_spec.rb" with:
25
+ """ruby
26
+ require 'spec_helper'
27
+
28
+ RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 5 do
29
+ before(:each) { run('cli') }
30
+ before(:each) { last_command_started.send_signal 'HUP' }
31
+ it { expect(last_command_started).to have_output /Exit/ }
32
+ end
33
+ """
34
+ When I run `rspec`
35
+ Then the specs should all pass
36
+
37
+ Scenario: Dying command
38
+ Given an executable named "bin/cli" with:
39
+ """ruby
40
+ #!/usr/bin/env bash
41
+ exit 1
42
+ """
43
+ And a file named "spec/run_spec.rb" with:
44
+ """ruby
45
+ require 'spec_helper'
46
+
47
+ RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 5 do
48
+ before(:each) { run('cli') }
49
+ it { expect { last_command_started.send_signal 'HUP' }.to raise_error Aruba::CommandAlreadyStoppedError, /Command "cli" with PID/ }
50
+ end
51
+ """
52
+ When I run `rspec`
53
+ Then the specs should all pass
@@ -0,0 +1,79 @@
1
+ Feature: Stop command
2
+
3
+ To stop commands via API you can do the following:
4
+
5
+ - `last_command_started.stop`
6
+ - `stop_all_commands`
7
+
8
+ Background:
9
+ Given I use a fixture named "cli-app"
10
+
11
+ Scenario: Stop successful command with configured signal
12
+ Given an executable named "bin/cli" with:
13
+ """bash
14
+ #!/bin/bash
15
+ function hup {
16
+ echo "Exit..."
17
+ exit 0
18
+ }
19
+
20
+ function term {
21
+ echo "No! No exit here. Try HUP. I stop the command with exit 1."
22
+ exit 1
23
+ }
24
+
25
+ trap hup HUP
26
+ trap term TERM
27
+ while [ true ]; do sleep 1; done
28
+ """
29
+ And a file named "spec/run_spec.rb" with:
30
+ """ruby
31
+ require 'spec_helper'
32
+
33
+ Aruba.configure do |config|
34
+ config.stop_signal = 'HUP'
35
+ config.exit_timeout = 1
36
+ end
37
+
38
+ RSpec.describe 'Run command', :type => :aruba do
39
+ before(:each) { run('cli') }
40
+ it { expect(last_command_started).to be_successfully_executed }
41
+ end
42
+ """
43
+ When I run `rspec`
44
+ Then the specs should all pass
45
+
46
+ Scenario: Stop unsuccessful command with configured signal
47
+ Given an executable named "bin/cli" with:
48
+ """bash
49
+ #!/bin/bash
50
+ function hup {
51
+ echo "Exit..."
52
+ exit 2
53
+ }
54
+
55
+ function term {
56
+ echo "No! No exit here. Try HUP. I stop the command with exit 1."
57
+ exit 1
58
+ }
59
+
60
+ trap hup HUP
61
+ trap term TERM
62
+ while [ true ]; do sleep 1; done
63
+ """
64
+ And a file named "spec/run_spec.rb" with:
65
+ """ruby
66
+ require 'spec_helper'
67
+
68
+ Aruba.configure do |config|
69
+ config.stop_signal = 'HUP'
70
+ config.exit_timeout = 1
71
+ end
72
+
73
+ RSpec.describe 'Run command', :type => :aruba do
74
+ before(:each) { run('cli') }
75
+ it { expect(last_command_started).to have_exit_status 2 }
76
+ end
77
+ """
78
+ When I run `rspec`
79
+ Then the specs should all pass
@@ -0,0 +1,45 @@
1
+ @experimental
2
+ Feature: Replace variables
3
+
4
+ There are use cases where you need access to some information from aruba in
5
+ your command line. The `#replace_variables`-method makes this information
6
+ available.
7
+
8
+ Please note, this feature is experimental for now. The implementation of this
9
+ feature and the name of variables may change without further notice.
10
+
11
+ Background:
12
+ Given I use a fixture named "cli-app"
13
+
14
+ Scenario: PID of last command started
15
+ Given an executable named "bin/cli" with:
16
+ """
17
+ #!/bin/bash
18
+ exit 0
19
+ """
20
+ And a file named "spec/replace_spec.rb" with:
21
+ """
22
+ require 'spec_helper'
23
+
24
+ RSpec.describe 'Run command', :type => :aruba do
25
+ before(:each) { run('cli') }
26
+ before(:each) { stop_all_commands }
27
+
28
+ it { expect(replace_variables('<pid-last-command-started>')).to eq last_command_started.pid.to_s }
29
+ end
30
+ """
31
+ When I run `rspec`
32
+ Then the specs should all pass
33
+
34
+ Scenario: No last command started
35
+ Given a file named "spec/replace_spec.rb" with:
36
+ """
37
+ require 'spec_helper'
38
+
39
+ RSpec.describe 'Run command', :type => :aruba do
40
+ it { expect(replace_variables('<pid-last-command-started>')).to eq '0' }
41
+ end
42
+ """
43
+ When I run `rspec`
44
+ Then the specs should all pass
45
+
@@ -0,0 +1,48 @@
1
+ Feature: Set time to wait after spawning command
2
+
3
+ As a developer
4
+ I want to configure a time span to wait after the command was spawned
5
+ In order to prevent failure of some commands which take a little bit longer
6
+ to load.
7
+
8
+
9
+ If you setup a ruby script, this may load bundler. This makes the script to
10
+ start up a little bit longer. If you want to run a command in background,
11
+ starting the command in a background process may take longer then sending it
12
+ a signal.
13
+
14
+ If you experience some brittle tests with background commands, try to set the
15
+ `#startup_wait_time`.
16
+
17
+ Background:
18
+ Given I use the fixture "cli-app"
19
+
20
+ Scenario: Default value
21
+ Given a file named "features/support/aruba.rb" with:
22
+ """ruby
23
+ Aruba.configure do |config|
24
+ puts %(The default value is "#{config.startup_wait_time}")
25
+ end
26
+ """
27
+ When I successfully run `cucumber`
28
+ Then the output should contain:
29
+ """
30
+ The default value is "0"
31
+ """
32
+
33
+ Scenario: Modify value
34
+ Given a file named "features/support/aruba.rb" with:
35
+ """ruby
36
+ Aruba.configure do |config|
37
+ config.startup_wait_time = 2
38
+ end
39
+
40
+ Aruba.configure do |config|
41
+ puts %(The new value is "#{config.startup_wait_time}")
42
+ end
43
+ """
44
+ Then I successfully run `cucumber`
45
+ Then the output should contain:
46
+ """
47
+ The new value is "2"
48
+ """
@@ -1,17 +1,96 @@
1
1
  require 'cucumber/platform'
2
2
 
3
- Before '@requires-ruby-version-193' do
4
- next unless RUBY_VERSION < '1.9.3'
3
+ Before '@requires-ruby-version-193' do |scenario|
4
+ next if RUBY_VERSION >= '1.9.3'
5
5
 
6
6
  if Cucumber::VERSION < '2'
7
- pending
7
+ scenario.skip_invoke!
8
8
  else
9
9
  skip_this_scenario
10
10
  end
11
11
  end
12
12
 
13
- Before '@requires-aruba-version-1' do
14
- next unless Aruba::VERSION > '1'
13
+ Before '@requires-ruby-version-19' do |scenario|
14
+ next if RUBY_VERSION >= '1.9'
15
15
 
16
- skip_this_scenario if Cucumber::VERSION >= '2'
16
+ if Cucumber::VERSION < '2'
17
+ scenario.skip_invoke!
18
+ else
19
+ skip_this_scenario
20
+ end
21
+ end
22
+
23
+ Before '@requires-ruby-version-2' do |scenario|
24
+ next if RUBY_VERSION >= '2'
25
+
26
+ if Cucumber::VERSION < '2'
27
+ scenario.skip_invoke!
28
+ else
29
+ skip_this_scenario
30
+ end
31
+ end
32
+
33
+ Before '@requires-aruba-version-1' do |scenario|
34
+ next if Aruba::VERSION > '1'
35
+
36
+ if Cucumber::VERSION < '2'
37
+ scenario.skip_invoke!
38
+ else
39
+ skip_this_scenario
40
+ end
41
+ end
42
+
43
+ Before '@requires-ruby-platform-java' do |scenario|
44
+ # leave if java
45
+ next if RUBY_PLATFORM.include? 'java'
46
+
47
+ if Cucumber::VERSION < '2'
48
+ scenario.skip_invoke!
49
+ else
50
+ skip_this_scenario
51
+ end
52
+ end
53
+
54
+ Before '@requires-ruby-platform-mri' do |scenario|
55
+ # leave if not java
56
+ next unless RUBY_PLATFORM.include? 'java'
57
+
58
+ if Cucumber::VERSION < '2'
59
+ scenario.skip_invoke!
60
+ else
61
+ skip_this_scenario
62
+ end
63
+ end
64
+
65
+ Before '@unsupported-on-platform-windows' do |scenario|
66
+ # leave if not windows
67
+ next unless FFI::Platform.windows?
68
+
69
+ if Cucumber::VERSION < '2'
70
+ scenario.skip_invoke!
71
+ else
72
+ skip_this_scenario
73
+ end
74
+ end
75
+
76
+ Before '@unsupported-on-platform-unix' do |scenario|
77
+ # leave if not windows
78
+ next unless FFI::Platform.unix?
79
+
80
+ if Cucumber::VERSION < '2'
81
+ scenario.skip_invoke!
82
+ else
83
+ skip_this_scenario
84
+ end
85
+ end
86
+
87
+ Before '@unsupported-on-platform-mac' do |scenario|
88
+ # leave if not windows
89
+ next unless FFI::Platform.mac?
90
+
91
+ if Cucumber::VERSION < '2'
92
+ scenario.skip_invoke!
93
+ else
94
+ skip_this_scenario
95
+ end
17
96
  end