Skip to content

Commit

Permalink
Fix Cucumber tests on Windows
Browse files Browse the repository at this point in the history
* Switch to Aruba::InProcess
* Tag tests that need a spawned shell with @Spawn
* Tag all help listings with @Spawn
* Tests tagged with @Spawn use Aruba::SpawnProcess
* Skip tests tagged with @Spawn on Windows
  • Loading branch information
rarenerd committed Dec 11, 2013
1 parent edac45e commit a687c98
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ guard 'minitest' do
watch(%r|^spec/spec_helper\.rb|) { "spec" }
end

guard 'cucumber' do
cucumber_cli = '--no-profile --color --format progress --strict'
cucumber_cli += ' --tags ~@spawn' if RUBY_PLATFORM =~ /mswin|mingw|windows/
guard 'cucumber', cli: cucumber_cli do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
Expand Down
1 change: 1 addition & 0 deletions features/kitchen_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Feature: A command line interface for Test Kitchen
As a Test Kitchen user
I want a command line interface that has sane defaults and built in help

@spawn
Scenario: Displaying help
When I run `kitchen help`
Then the exit status should be 0
Expand Down
1 change: 1 addition & 0 deletions features/kitchen_driver_create_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Feature: Create a new Test Kitchen Driver project
As a user of Test Kitchen
I want a command to run that will give me a driver gem project scaffold

@spawn
Scenario: Displaying help
When I run `kitchen help driver create`
Then the output should contain:
Expand Down
1 change: 1 addition & 0 deletions features/kitchen_driver_discover_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Feature: Search RubyGems to discover new Test Kitchen Driver gems
As a Test Kitchen user
I want to run a command which returns candidate Kitchen drivers

@spawn
Scenario: Displaying help
When I run `kitchen help driver discover`
Then the output should contain:
Expand Down
2 changes: 2 additions & 0 deletions features/kitchen_init_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Feature: Add Test Kitchen support to an existing project
As an operator
I want to run a command to initialize my project

@spawn
Scenario: Displaying help
When I run `kitchen help init`
Then the output should contain:
Expand All @@ -12,6 +13,7 @@ Feature: Add Test Kitchen support to an existing project
"""
And the exit status should be 0

@spawn
Scenario: Running init with default values
Given a sandboxed GEM_HOME directory named "kitchen-init"
And I have a git repository
Expand Down
2 changes: 2 additions & 0 deletions features/kitchen_list_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ Feature: Listing Test Kitchen instances
"""

@spawn
Scenario: Listing instances with a regular expression yielding no results
When I run `kitchen list freebsd --bare`
Then the exit status should not be 0
And the output should contain "No instances for regex `freebsd', try running `kitchen list'"

@spawn
Scenario: Listing instances with a bad regular expression
When I run `kitchen list *centos* --bare`
Then the exit status should not be 0
Expand Down
25 changes: 25 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
# Set up the environment for testing
require 'aruba/cucumber'
require 'aruba/in_process'
require 'aruba/spawn_process'
require 'kitchen'
require 'kitchen/cli'

class ArubaHelper
def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
@argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
end

def execute!
$stdout = @stdout
$stdin = @stdin

kitchen_cli = Kitchen::CLI
kitchen_cli.start(@argv)
@kernel.exit(0)
end
end

Before do
@aruba_timeout_seconds = 15
@cleanup_dirs = []

Aruba::InProcess.main_class = ArubaHelper
Aruba.process = Aruba::InProcess
end

Before('@spawn') do
Aruba.process = Aruba::SpawnProcess
end

After do |s|
Expand Down

0 comments on commit a687c98

Please sign in to comment.