From 3d1302525645d4c82eded04511e9f6c05facf9d8 Mon Sep 17 00:00:00 2001 From: Andrew Walter Date: Sun, 10 Jun 2018 23:36:19 +1000 Subject: [PATCH] CI: Windows - Fixed `check_for_exit_status` feature (Cucumber) --- .../command/check_for_exit_statuses.feature | 4 +- features/step_definitions/hooks.rb | 6 + .../command/check_for_exit_statuses.feature | 131 ++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 features/unpublished/windows/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature diff --git a/features/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature b/features/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature index ead89af92..61178ae5f 100644 --- a/features/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature +++ b/features/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature @@ -1,3 +1,4 @@ +@requires-bash Feature: Check exit status of commands Use the `the exit status should be \d`-step to check the exit status of the @@ -6,7 +7,7 @@ Feature: Check exit status of commands Background: Given I use a fixture named "cli-app" - + Scenario: Test for exit status of 0 Given an executable named "bin/aruba-test-cli" with: """ @@ -85,6 +86,7 @@ Feature: Check exit status of commands When I run `cucumber` Then the features should not all pass + @requires-sleep Scenario: Overwrite the default exit timeout via step Given an executable named "bin/aruba-test-cli" with: """ diff --git a/features/step_definitions/hooks.rb b/features/step_definitions/hooks.rb index 43126803f..b1125802d 100644 --- a/features/step_definitions/hooks.rb +++ b/features/step_definitions/hooks.rb @@ -54,6 +54,12 @@ skip_this_scenario end +Before "@requires-platform-windows" do + next if FFI::Platform.windows? + + skip_this_scenario +end + Before "@requires-posix-standard-tools" do next unless Aruba.platform.which("printf").nil? diff --git a/features/unpublished/windows/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature b/features/unpublished/windows/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature new file mode 100644 index 000000000..075a7f797 --- /dev/null +++ b/features/unpublished/windows/03_testing_frameworks/cucumber/steps/command/check_for_exit_statuses.feature @@ -0,0 +1,131 @@ +@requires-platform-windows +Feature: Check exit status of commands + + Use the `the exit status should be \d`-step to check the exit status of the + last command which was finished. If no commands have finished yet, it stops + the one that was started last. + + Background: + Given I use a fixture named "cli-app" + + + Scenario: Test for exit status of 0 + Given an executable named "bin/aruba-test-cli.bat" with: + """ + exit 0 + """ + And a file named "features/exit_status.feature" with: + """ + Feature: Exit status + Scenario: Run command + When I run `aruba-test-cli` + Then the exit status should be 0 + """ + When I run `cucumber` + Then the features should all pass + + Scenario: Test for exit status 1 + Given an executable named "bin/aruba-test-cli.bat" with: + """ + exit 1 + """ + And a file named "features/exit_status.feature" with: + """ + Feature: Failing program + Scenario: Run command + When I run `aruba-test-cli` + Then the exit status should be 1 + """ + When I run `cucumber` + Then the features should all pass + + Scenario: Test for non-zero exit status + Given an executable named "bin/aruba-test-cli.bat" with: + """ + exit 1 + """ + And a file named "features/exit_status.feature" with: + """ + Feature: Failing program + Scenario: Run command + When I run `aruba-test-cli` + Then the exit status should not be 0 + """ + When I run `cucumber` + Then the features should all pass + + Scenario: Successfully run something + Given an executable named "bin/aruba-test-cli.bat" with: + """ + exit 0 + """ + And a file named "features/exit_status.feature" with: + """ + Feature: Failing program + Scenario: Run command + When I successfully run `aruba-test-cli` + """ + When I run `cucumber` + Then the features should all pass + + Scenario: Fail to run something successfully + Given an executable named "bin/aruba-test-cli.bat" with: + """ + exit 1 + """ + And a file named "features/exit_status.feature" with: + """ + Feature: Failing program + Scenario: Run command + When I successfully run `aruba-test-cli` + """ + When I run `cucumber` + Then the features should not all pass + + Scenario: Overwrite the default exit timeout via step + Given an executable named "bin/aruba-test-cli.bat" with: + """ + ruby -e 'sleep 0.1' + """ + And a file named "features/exit_status.feature" with: + """ + Feature: Failing program + Scenario: Run command + Given the default aruba exit timeout is 3.5 seconds + When I successfully run `aruba-test-cli` + """ + When I run `cucumber` + Then the features should all pass + + Scenario: Successfully run something longer then the default time + Given an executable named "bin/aruba-test-cli.bat" with: + """ + ruby -e 'sleep 0.1' + """ + And a file named "features/exit_status.feature" with: + """ + 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 5.1 seconds + """ + When I run `cucumber` + Then the features should all pass + + Scenario: Unsuccessfully run something that takes too long + Given an executable named "bin/aruba-test-cli.bat" with: + """ + ruby -e 'sleep 0.1' + """ + And a file named "features/exit_status.feature" with: + """ + Feature: Failing program + Scenario: Run command + Given the default aruba exit timeout is 0 seconds + When I successfully run `aruba-test-cli` + """ + When I run `cucumber` + Then the features should not all pass with: + """ + expected "aruba-test-cli" to have finished in time + """