aruba-jbb 0.2.6.9 → 0.2.6.10
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/README.rdoc +7 -6
- data/aruba-jbb.gemspec +1 -1
- data/features/process_timeout.feature +13 -2
- data/lib/aruba/api.rb +15 -14
- data/lib/aruba/cucumber_steps.rb +13 -6
- metadata +3 -3
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -74,21 +74,22 @@ Upstream addressed the more limited problem of locating <code>./bin</code>
|
|
74
74
|
by adding a <code>@bin</code> tag which appends <code>./bin</code> to Cucumber's
|
75
75
|
LOADPATH. This technique is supported by Aruba-jbb as well.
|
76
76
|
|
77
|
-
The aruba <tt>run</tt> api method is
|
78
|
-
This means that after the default period of
|
77
|
+
The aruba <tt>run</tt> api method is surrounded by a timeout call.
|
78
|
+
This means that after the default period of 20 seconds any process under test
|
79
79
|
is forceably terminated. However, be advised that the run api methods raises
|
80
|
-
no error
|
80
|
+
no error by default. Instead the process exit status is set to -1 and
|
81
81
|
stderr will contain <em>Aruba::Api::ProcessTimeout: execution expired</em>.
|
82
82
|
You are therefore advised to either override the When /run "([^\"])"/ do |cmd|
|
83
83
|
step definition or provide an alternative form.
|
84
84
|
|
85
|
-
The default timeout value
|
85
|
+
The default timeout value may be overriden either by defining an environmental
|
86
86
|
variable called ARUBA_RUN_TIMEOUT to the approprate value (in seconds) or by
|
87
87
|
passing an optional third parameter to the run api method. Fractional values
|
88
88
|
are acepted but granularity of less than interger seconds is not guarenteed to
|
89
|
-
work.
|
89
|
+
work. A helper step definition is provided to set environment variables
|
90
|
+
for process testing. This is documented in the api rdoc.
|
90
91
|
|
91
|
-
Timeout does not
|
92
|
+
Timeout does not handle the run_interactive api method. This is experimaental
|
92
93
|
code merged from Mike Sassak's fork.
|
93
94
|
|
94
95
|
== Ruby/RVM
|
data/aruba-jbb.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{aruba-jbb}
|
5
|
-
s.version = "0.2.6.
|
5
|
+
s.version = "0.2.6.10"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Aslak Hellesøy", "David Chelimsky", "James B. Byrne", "Mike Sassak"]
|
@@ -6,7 +6,7 @@ Feature: process should timeout
|
|
6
6
|
|
7
7
|
|
8
8
|
Scenario: process runner times out for long process
|
9
|
-
When I run "ruby -e 'sleep(
|
9
|
+
When I run "ruby -e 'sleep(21)'"
|
10
10
|
Then the exit status should not be 0
|
11
11
|
And stderr should contain "execution expired"
|
12
12
|
|
@@ -20,6 +20,17 @@ Feature: process should timeout
|
|
20
20
|
|
21
21
|
|
22
22
|
Scenario: process runner timeout can be set higher than default
|
23
|
-
When I run "ruby -e 'sleep(
|
23
|
+
When I run "ruby -e 'sleep(21)'" with timeout of "22" seconds
|
24
24
|
Then the exit status should be 0
|
25
25
|
And stderr should be empty
|
26
|
+
And stderr should not contain "execution expired"
|
27
|
+
|
28
|
+
@announce
|
29
|
+
Scenario: environment variable controls timeout value
|
30
|
+
Given I set the env variable "ARUBA_RUN_TIMEOUT" to "25" seconds
|
31
|
+
When I run "ruby -e 'sleep(21)'"
|
32
|
+
Then the exit status should be 0
|
33
|
+
When I set the env variable "ARUBA_RUN_TIMEOUT" to "5" seconds
|
34
|
+
And I run "ruby -e 'sleep(10)'"
|
35
|
+
Then the exit status should be -1
|
36
|
+
And stderr should contain "Aruba::Api::ProcessTimeout: execution expired"
|
data/lib/aruba/api.rb
CHANGED
@@ -65,19 +65,19 @@ module Aruba
|
|
65
65
|
# contained in the ARUBA_REBASE environmental variable, if found.
|
66
66
|
#
|
67
67
|
def aruba_working_dir_init
|
68
|
-
|
68
|
+
|
69
69
|
@aruba_working_dir = [ARUBA_WORKING_DIR_DEFAULT]
|
70
70
|
|
71
|
-
if
|
72
|
-
@aruba_working_dir = [ENV[ARUBA_WORKING_DIR]]
|
71
|
+
if ( ENV['ARUBA_WORKING_DIR'] != nil )
|
72
|
+
@aruba_working_dir = [ENV['ARUBA_WORKING_DIR']]
|
73
73
|
end
|
74
74
|
|
75
75
|
dirs_init
|
76
76
|
clean_up
|
77
77
|
rebase_dirs_clear
|
78
78
|
|
79
|
-
if
|
80
|
-
rebase(ENV[ARUBA_REBASE].split(%r{,|;\s*}))
|
79
|
+
if ( ENV['ARUBA_REBASE'] != nil )
|
80
|
+
rebase(ENV['ARUBA_REBASE'].split(%r{,|;\s*}))
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -579,7 +579,7 @@ module Aruba
|
|
579
579
|
class ProcessTimeout < Timeout::Error; end
|
580
580
|
# Set the default timeout in seconds for external process to finish
|
581
581
|
# May be overrriden by setting environment variable ARUBA_RUN_TIMEOUT
|
582
|
-
ARUBA_RUN_TIMEOUT_DEFAULT =
|
582
|
+
ARUBA_RUN_TIMEOUT_DEFAULT = 20
|
583
583
|
|
584
584
|
# run is the internal helper method that actually runs the external
|
585
585
|
# test process, optionally failing if the exit status != 0. Takes an
|
@@ -595,30 +595,31 @@ module Aruba
|
|
595
595
|
# When /I run a long process without error/ do
|
596
596
|
# run(long_process, true, 15) # allow 15 seconds.
|
597
597
|
#
|
598
|
-
# When /run "(.*)" with timeout of "()" seconds$/ do |cmd, time|
|
598
|
+
# When /run "(.*)" with timeout of "(\d+\.\d*)" seconds$/ do |cmd, time|
|
599
599
|
# run(unescape(cmd), true, time.to_f)
|
600
600
|
# end
|
601
|
+
#
|
602
|
+
# When I set the env variable "SOME_THING" to "some value"
|
603
|
+
#
|
601
604
|
def run(cmd, fail_on_error=true, tlimit=nil)
|
602
605
|
|
603
606
|
@last_stderr = ""
|
604
607
|
@last_stdout = ""
|
605
608
|
cmd = detect_ruby(cmd)
|
606
609
|
|
607
|
-
if tlimit == nil
|
608
|
-
if
|
609
|
-
tlimit = ENV[ARUBA_RUN_TIMEOUT]
|
610
|
+
if tlimit == nil || tlimit == ""
|
611
|
+
if ( ENV['ARUBA_RUN_TIMEOUT'] != nil )
|
612
|
+
tlimit = ENV['ARUBA_RUN_TIMEOUT']
|
610
613
|
else
|
611
614
|
tlimit = ARUBA_RUN_TIMEOUT_DEFAULT
|
612
615
|
end
|
613
|
-
|
614
|
-
tlimit = tlimit.to_f
|
615
|
-
end
|
616
|
+
end
|
616
617
|
|
617
618
|
in_current_dir do
|
618
619
|
announce_or_puts("$ cd #{Dir.pwd}") if @announce_dir
|
619
620
|
announce_or_puts("$ #{cmd}") if @announce_cmd
|
620
621
|
begin
|
621
|
-
Timeout::timeout(tlimit, ProcessTimeout) {
|
622
|
+
Timeout::timeout(tlimit.to_f, ProcessTimeout) {
|
622
623
|
ps = BackgroundProcess.run(cmd)
|
623
624
|
@last_stdout = ps.stdout.read
|
624
625
|
announce_or_puts(@last_stdout) if @announce_stdout
|
data/lib/aruba/cucumber_steps.rb
CHANGED
@@ -209,18 +209,25 @@ When /run "(.*)" interactively$/ do |cmd|
|
|
209
209
|
end
|
210
210
|
|
211
211
|
|
212
|
-
When /run "(.*)" with errors
|
213
|
-
|
212
|
+
When /run "(.*)" with errors?(?: and timeout of "(\d+\.?\d*)" seconds?)?$/\
|
213
|
+
do |cmd, time|
|
214
|
+
run(unescape(cmd), false, time)
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
When /run "(.*)" with timeout of "(\d+\.?\d*)" seconds?$/ do |cmd, time|
|
219
|
+
run(unescape(cmd), true, time)
|
214
220
|
end
|
215
221
|
|
216
222
|
|
217
|
-
When /run "(.*)"
|
218
|
-
|
223
|
+
When /run "(.*)" without errors?(?: and timeout of "(\d+\.?\d*)" seconds?)?$/\
|
224
|
+
do |cmd, time|
|
225
|
+
run(unescape(cmd), true, time)
|
219
226
|
end
|
220
227
|
|
221
228
|
|
222
|
-
When /
|
223
|
-
|
229
|
+
When /set the env variable "([^\"]*)" to "(\d+\.?\d*)" seconds?$/ do |var, val|
|
230
|
+
ENV[var] = val
|
224
231
|
end
|
225
232
|
|
226
233
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aruba-jbb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 83
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
9
|
- 6
|
10
|
-
-
|
11
|
-
version: 0.2.6.
|
10
|
+
- 10
|
11
|
+
version: 0.2.6.10
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- "Aslak Helles\xC3\xB8y"
|