Sha256: d6be8102613631c5ac5d6d91ac7fca564a3c532c04c2c35cadf9b12d5283199c

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'systemu'
require 'win32/process'

def launch_cuke4nuke_process(step_definitions_dll_path)
  cuke4nuke_server_exe = File.expand_path(File.join(File.dirname(__FILE__), '../dotnet/Cuke4Nuke.Server.exe'))
  command = %{"#{cuke4nuke_server_exe}" -a "#{step_definitions_dll_path}"}
  process = IO.popen(command, 'r')
  @cuke4nuke_server_pid = process.pid
end

def kill_cuke4nuke_process
  Process.kill(9, @cuke4nuke_server_pid)
end

def launch_cucumber(args)
  command = "cucumber #{args.join(' ')} 2>&1"
  status, stdout, stderr = systemu(command)
  puts stdout
  status
end

def show_usage
  puts "Usage: cuke4nuke STEP_DEFINITION_DLL_PATH [CUCUMBER_ARGUMENTS]\n\n"
  puts "The following is Cucumber's help. Anything after the cucumber command can be"
  puts "passed in the CUCUMBER_ARGUMENTS argument for cuke4nuke:\n\n"
  launch_cucumber(['--help'])
end

if ARGV.empty? || ['-h', '-?', '/?', '--help'].include?(ARGV[0])
  show_usage
else
  args = ARGV.clone
  step_definitions_dll_path = File.expand_path(args.shift)
  
  if !File.exists?(step_definitions_dll_path)
    puts %{"#{step_definitions_dll_path}" is not a valid file path.\n\n}
    show_usage
    exit 1
  end
  
  launch_cuke4nuke_process(step_definitions_dll_path)
  
  @exit_status = 1
  begin
    cucumber_status = launch_cucumber(args)
    @exit_status = cucumber_status.exitstatus
  ensure
    kill_cuke4nuke_process
  end
  exit @exit_status
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cuke4nuke-0.2.2 bin/cuke4nuke
cuke4nuke-0.2.1 bin/cuke4nuke
cuke4nuke-0.2.0 bin/cuke4nuke