Skip to content

Commit

Permalink
Allow decimal values for seconds values
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Mar 6, 2018
1 parent 28b4dc5 commit b81e865
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Feature: Check exit status of commands
"""
Feature: Failing program
Scenario: Run command
Given the default aruba exit timeout is 1 second
Given the default aruba exit timeout is 0.2 seconds
When I successfully run `aruba-test-cli`
"""
When I run `cucumber`
Expand All @@ -112,7 +112,7 @@ Feature: Check exit status of commands
Feature: Failing program
Scenario: Run command
Given the default aruba exit timeout is 0 seconds
When I successfully run `aruba-test-cli` for up to 2 seconds
When I successfully run `aruba-test-cli` for up to 0.2 seconds
"""
When I run `cucumber`
Then the features should all pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Feature: Stop commands
"""
Feature: Run it
Scenario: Run command
Given the default aruba exit timeout is 1 second
And I wait 1 second for a command to start up
Given the default aruba exit timeout is 0.2 seconds
And I wait 0.1 seconds for a command to start up
When I run `aruba-test-cli1` in background
And I run `aruba-test-cli2` in background
And I terminate the command started last
Expand Down Expand Up @@ -97,8 +97,8 @@ Feature: Stop commands
Background:
Scenario: Run command
Given the default aruba exit timeout is 1 second
And I wait 1 second for a command to start up
Given the default aruba exit timeout is 0.2 seconds
And I wait 0.1 seconds for a command to start up
When I run `aruba-test-cli1` in background
And I run `aruba-test-cli2` in background
And I stop the command started last
Expand Down Expand Up @@ -145,10 +145,10 @@ Feature: Stop commands
"""
Feature: Run it
Background:
Given the default aruba exit timeout is 1 second
Given the default aruba exit timeout is 0.2 seconds
Scenario: Run command
Given I wait 1 second for a command to start up
Given I wait 0.1 seconds for a command to start up
When I run `aruba-test-cli1` in background
When I run `aruba-test-cli2` in background
And I terminate the command "aruba-test-cli1"
Expand Down Expand Up @@ -197,10 +197,10 @@ Feature: Stop commands
"""
Feature: Run it
Background:
Given the default aruba exit timeout is 1 second
Given the default aruba exit timeout is 0.2 seconds
Scenario: Run command
Given I wait 1 second for a command to start up
Given I wait 0.1 seconds for a command to start up
When I run `aruba-test-cli1` in background
And I run `aruba-test-cli2` in background
When I stop the command "aruba-test-cli1"
Expand Down Expand Up @@ -239,7 +239,7 @@ Feature: Stop commands
Feature: Run it
Scenario: Run command
Given the default aruba stop signal is "HUP"
And the default aruba exit timeout is 1 second
And the default aruba exit timeout is 0.2 seconds
When I run `aruba-test-cli`
And I terminate the command started last
Then the exit status should be 155
Expand Down Expand Up @@ -267,8 +267,8 @@ Feature: Stop commands
"""
Feature: Run it
Scenario: Run command
Given the default aruba exit timeout is 1 second
And I wait 1 second for a command to start up
Given the default aruba exit timeout is 0.2 seconds
And I wait 0.1 seconds for a command to start up
When I run `aruba-test-cli1` in background
And I terminate the command started last
Then the exit status should be 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Feature: Access STDERR of command

Background:
Given I use a fixture named "cli-app"
And the default aruba io wait timeout is 0 seconds
And the default aruba io wait timeout is 0.1 seconds

Scenario: Existing executable
Given an executable named "bin/aruba-test-cli" with:
Expand Down
16 changes: 8 additions & 8 deletions lib/aruba/cucumber/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

## I successfully run `echo -n "Hello"`
## I successfully run `sleep 29` for up to 30 seconds
When(/^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/) do |cmd, secs|
When(/^I successfully run `(.*?)`(?: for up to ([\d.]+) seconds)?$/) do |cmd, secs|
cmd = sanitize_text(cmd)
run_command_and_stop(cmd, fail_on_error: true, exit_timeout: secs && secs.to_i)
run_command_and_stop(cmd, fail_on_error: true, exit_timeout: secs && secs.to_f)
end

When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) do |shell, commands|
Expand Down Expand Up @@ -323,20 +323,20 @@
end
end

Given(/^the (?:default )?aruba io wait timeout is (\d+) seconds?$/) do |seconds|
aruba.config.io_wait_timeout = seconds.to_i
Given(/^the (?:default )?aruba io wait timeout is ([\d.]+) seconds?$/) do |seconds|
aruba.config.io_wait_timeout = seconds.to_f
end

Given(/^the (?:default )?aruba exit timeout is (\d+) seconds?$/) do |seconds|
aruba.config.exit_timeout = seconds.to_i
Given(/^the (?:default )?aruba exit timeout is ([\d.]+) seconds?$/) do |seconds|
aruba.config.exit_timeout = seconds.to_f
end

Given(/^the (?:default )?aruba stop signal is "([^"]*)"$/) do |signal|
aruba.config.stop_signal = signal
end

Given(/^I wait (\d+) seconds? for (?:a|the) command to start up$/) do |seconds|
aruba.config.startup_wait_time = seconds.to_i
Given(/^I wait ([\d.]+) seconds? for (?:a|the) command to start up$/) do |seconds|
aruba.config.startup_wait_time = seconds.to_f
end

When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/) do |signal, command|
Expand Down

0 comments on commit b81e865

Please sign in to comment.