Sha256: 0b66efff5635f4b1a71a4220a4286293f578fbd55a96f2a0bcb6b13ae6cf9422
Contents?: true
Size: 1.51 KB
Versions: 6
Compression:
Stored size: 1.51 KB
Contents
#!/usr/bin/env ruby # TODO: support an option like 'cuke4php --init' which will generate the directory structure and support files necessary to use cuke4php with a php project. # TODO: lint check all php files before starting the cuke4php server # This script will autodetect the first free port starting at 16816 and pass it to cucumber in the # CUKE4PHP_PORT environment variable. Versions of cucumber > 0.10.2 can use erb in the .wire protocol file # to dynamically pick up this port number at runtime, which allows multiple instances of a cuke4php server # to be run on the same machine without conflicting require 'socket' require 'timeout' def port_in_use?(_port) begin Timeout::timeout(1) do begin s = TCPSocket.new('localhost', _port) s.close return true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH return false end end rescue Timeout::Error end return false end def autodetect_free_port port = 16816 while port_in_use?(port) && port < 65536 do port+=1 end raise RuntimeError, "No free port detected" if port == 65536 return port end cuke4php_port=ENV['CUKE4PHP_PORT'] || autodetect_free_port server = fork do exec "#{File.dirname(__FILE__)}/cuke4php_server -p #{cuke4php_port} #{ARGV.last ? ARGV.last : 'features'}" end sleep 1 cucumber = fork do exec "export CUKE4PHP_PORT=#{cuke4php_port} && cucumber #{ARGV.join(' ')}" end pid, status = Process.wait2(cucumber,0) Process.kill("TERM",server) exit status.exitstatus
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
cuke4php-0.9.10 | bin/cuke4php |
cuke4php-0.9.9 | bin/cuke4php |
cuke4php-0.9.8 | bin/cuke4php |
cuke4php-0.9.6.c | bin/cuke4php |
cuke4php-0.9.6.b | bin/cuke4php |
cuke4php-0.9.6.a | bin/cuke4php |