clucumber 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +5 -4
- data/lib/clucumber.rb +23 -15
- data/lib/clucumber/clucumber-bootstrap.lisp +1 -1
- data/lib/clucumber/server.lisp +23 -10
- metadata +9 -12
- data/test/helper.rb +0 -10
- data/test/test_clucumber.rb +0 -7
data/README.md
CHANGED
@@ -13,7 +13,7 @@ First, install the clucumber gem via rubygems:
|
|
13
13
|
|
14
14
|
gem install clucumber
|
15
15
|
|
16
|
-
On the lisp side, clucumber depends on cl-interpol, cl-ppcre, trivial-backtrace, usocket and st-json. All of these are available in
|
16
|
+
On the lisp side, clucumber depends on cl-interpol, cl-ppcre, trivial-backtrace, usocket and st-json. All of these are available in [quicklisp](http://quicklisp.org), and I recommend you use this to manage your lisp libraries.
|
17
17
|
|
18
18
|
Getting started
|
19
19
|
---------------
|
@@ -30,19 +30,20 @@ Files in support and step_definitions/ are loaded (not file-compiled)
|
|
30
30
|
in alphabetical order, with support/ files being loaded before step
|
31
31
|
definitions.
|
32
32
|
|
33
|
+
Put a .wire file into your step_definitions dir; I like to name it `features/step_definitions/clucumber.wire`. See [examples/clucumber.wire](//github.com/antifuchs/clucumber/tree/master/examples/clucumber.wire) for one that works for me.
|
34
|
+
|
33
35
|
In your `features/support/env.rb`, you use something like this:
|
34
36
|
|
35
37
|
require 'clucumber'
|
36
38
|
begin
|
37
|
-
ClucumberSubprocess.launch(File.expand_path("../", File.dirname(__FILE__))
|
38
|
-
:port => 42428).listen <<-LISP
|
39
|
+
ClucumberSubprocess.launch(File.expand_path("../", File.dirname(__FILE__))).listen <<-LISP
|
39
40
|
;; Put code here that loads your application.
|
40
41
|
LISP
|
41
42
|
rescue PTY::ChildExited
|
42
43
|
STDERR.puts(@main_clucumber && @main_clucumber.output)
|
43
44
|
end
|
44
45
|
|
45
|
-
This will launch a lisp with clucumber loaded (pass :lisp parameter to `ClucumberSubprocess.new` to specify which lisp, it defaults to sbcl), and start listening on port 42428.
|
46
|
+
This will launch a lisp with clucumber loaded (pass :lisp parameter to `ClucumberSubprocess.new` to specify which lisp, it defaults to sbcl), and (if you used the [examples/clucumber.wire](//github.com/antifuchs/clucumber/tree/master/examples/clucumber.wire) file) start listening on port 42428.
|
46
47
|
|
47
48
|
Then, on the command line, you run cucumber:
|
48
49
|
|
data/lib/clucumber.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pty'
|
2
|
+
require 'erb'
|
2
3
|
require 'fileutils'
|
3
4
|
|
4
5
|
class ClucumberSubprocess
|
@@ -18,19 +19,19 @@ class ClucumberSubprocess
|
|
18
19
|
def initialize(dir, options={})
|
19
20
|
@dir = dir
|
20
21
|
@lisp = options[:lisp] || ENV['LISP'] || 'sbcl --disable-debugger'
|
21
|
-
@port = options[:port]
|
22
|
+
@port = options[:port]
|
22
23
|
@output = ""
|
23
24
|
end
|
24
25
|
|
25
26
|
def run
|
26
|
-
|
27
|
+
set_port
|
27
28
|
|
28
29
|
Dir.chdir(@dir) do
|
29
30
|
@out, @in, @pid = PTY.spawn(@lisp)
|
30
31
|
end
|
31
32
|
@reader = Thread.start {
|
32
33
|
record_output
|
33
|
-
}
|
34
|
+
}
|
34
35
|
cluke_dir = File.expand_path("clucumber/", File.dirname(__FILE__))
|
35
36
|
Dir[cluke_dir + '/**/*.fasl'].each do |fasl|
|
36
37
|
FileUtils.rm(fasl)
|
@@ -46,21 +47,24 @@ class ClucumberSubprocess
|
|
46
47
|
(asdf:oos 'asdf:load-op :clucumber)
|
47
48
|
(clucumber-external:start #p"./" "localhost" #{@port})
|
48
49
|
LISP
|
50
|
+
sleep 1
|
49
51
|
end
|
50
52
|
|
51
53
|
def listen(additional_forms="")
|
52
|
-
start_clucumber_server(additional_forms) unless
|
53
|
-
|
54
|
-
until socket = TCPSocket.new("localhost", @port) rescue nil
|
54
|
+
start_clucumber_server(additional_forms) unless connectable?
|
55
|
+
until connectable?
|
55
56
|
raise LaunchFailed, "Couldn't start clucumber:\n#{@output}" unless alive?
|
56
|
-
sleep 0.
|
57
|
+
sleep 0.5
|
57
58
|
end
|
58
|
-
|
59
|
+
sleep 1
|
60
|
+
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
def connectable?
|
63
|
+
if socket = TCPSocket.new("127.0.0.1", @port) rescue nil
|
64
|
+
socket.close
|
65
|
+
true
|
66
|
+
else
|
67
|
+
false
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
@@ -77,7 +81,6 @@ class ClucumberSubprocess
|
|
77
81
|
|
78
82
|
def kill
|
79
83
|
if @pid
|
80
|
-
FileUtils.rm_f wire_file
|
81
84
|
@reader.terminate!
|
82
85
|
Process.kill("TERM", @pid)
|
83
86
|
Process.waitpid(@pid)
|
@@ -110,7 +113,12 @@ class ClucumberSubprocess
|
|
110
113
|
File.exist?(wire_file)
|
111
114
|
end
|
112
115
|
|
113
|
-
def
|
114
|
-
@port
|
116
|
+
def set_port
|
117
|
+
unless @port
|
118
|
+
@port = YAML.load(ERB.new(File.read(wire_file)).result)['port'] ||
|
119
|
+
ENV['CLUCUMBER_PORT'] ||
|
120
|
+
raise("Need a port to run clucumber on.")
|
121
|
+
@port = @port.to_i
|
122
|
+
end
|
115
123
|
end
|
116
124
|
end
|
data/lib/clucumber/server.lisp
CHANGED
@@ -34,15 +34,27 @@
|
|
34
34
|
(defvar *stream*)
|
35
35
|
|
36
36
|
(defun serve-cucumber-requests (socket &aux (*stream* (socket-stream socket)))
|
37
|
-
(handler-case
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
(handler-case
|
38
|
+
(loop
|
39
|
+
(let* ((line (handler-case (read-line *stream*)
|
40
|
+
(error ()
|
41
|
+
(close *stream*)
|
42
|
+
(return :socket-error))))
|
43
|
+
(message (read-json line nil))
|
44
|
+
(reply (call-wire-protocol-method message)))
|
45
|
+
(format *trace-output* "Read json message ~s -> ~s~%" line message)
|
46
|
+
(handler-case (progn (st-json:write-json reply *stream*)
|
47
|
+
(terpri *stream*)
|
48
|
+
(finish-output *stream*))
|
49
|
+
(error ()
|
50
|
+
(close *stream*)
|
51
|
+
(return :socket-error)))))
|
52
|
+
(error ()
|
53
|
+
(close *stream*)
|
54
|
+
(format t "OHAI ich bin ein scheissprogramm~%")
|
55
|
+
(force-output *standard-output*)
|
56
|
+
(sleep 10)
|
57
|
+
(return-from serve-cucumber-requests :socket-error))))
|
46
58
|
|
47
59
|
|
48
60
|
;;; Step definitions
|
@@ -89,8 +101,9 @@
|
|
89
101
|
(let ((server (usocket:socket-listen host port :reuse-address t)))
|
90
102
|
(unwind-protect
|
91
103
|
(loop
|
104
|
+
(with-open-file (*trace-output* #p"/tmp/trace.out" :direction :output :if-exists :append :if-does-not-exist :create)
|
92
105
|
(let ((socket (usocket:socket-accept server :element-type 'character)))
|
93
|
-
|
106
|
+
(serve-cucumber-requests socket)))
|
94
107
|
(when quit (return)))
|
95
108
|
(usocket:socket-close server))))
|
96
109
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andreas Fuchs
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-06-15 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -199,15 +199,13 @@ files:
|
|
199
199
|
- lib/clucumber/vendor/usocket/vendor/split-sequence.lisp
|
200
200
|
- LICENSE
|
201
201
|
- README.md
|
202
|
-
- test/helper.rb
|
203
|
-
- test/test_clucumber.rb
|
204
202
|
has_rdoc: true
|
205
203
|
homepage: http://github.com/antifuchs/clucumber
|
206
204
|
licenses: []
|
207
205
|
|
208
206
|
post_install_message:
|
209
|
-
rdoc_options:
|
210
|
-
|
207
|
+
rdoc_options: []
|
208
|
+
|
211
209
|
require_paths:
|
212
210
|
- lib
|
213
211
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -235,6 +233,5 @@ rubygems_version: 1.3.7
|
|
235
233
|
signing_key:
|
236
234
|
specification_version: 3
|
237
235
|
summary: Test drive your Common Lisp application from Cucumber
|
238
|
-
test_files:
|
239
|
-
|
240
|
-
- test/test_clucumber.rb
|
236
|
+
test_files: []
|
237
|
+
|
data/test/helper.rb
DELETED