Permalink
Browse files

Add support for async steps.

  • Loading branch information...
rejeep committed Dec 26, 2012
1 parent c915913 commit 85c0f13217c04aa902d6e1a41260382a15a8c6ef
Showing with 25 additions and 2 deletions.
  1. +15 −2 ecukes-run.el
  2. +10 −0 test/ecukes-run-test.el
View
@@ -104,8 +104,21 @@
(args (ecukes-steps-args step))
(args (if arg (cons arg args) args))
(step-def (ecukes-steps-find body))
- (fn (ecukes-step-def-fn step-def)))
- (apply fn args))
+ (fn (ecukes-step-def-fn step-def))
+ (fn-args-count
+ (length
+ (if (byte-code-function-p fn)
+ (aref fn 0)
+ (if (listp fn)
+ (cadr fn))))))
+ (if (and (not (symbolp fn)) (> fn-args-count (length args)))
+ (progn
+ (let ((wait t))
+ (add-to-list 'args (lambda (&rest args) (setq wait nil)) t)
+ (apply fn args)
+ (while wait
+ (accept-process-output nil 0.005))))
+ (apply fn args)))
(setq success t))
(error
(setf (ecukes-step-err step) (error-message-string err)))
View
@@ -435,3 +435,13 @@
(should
(ecukes-run-step
(mock-step "Given this:" :type 'table :arg "py-string"))))))
+
+(ert-deftest run-step-with-callback ()
+ "Should run step with callback."
+ (with-steps
+ (Given "^command \\(.+\\)$"
+ (lambda (command callback)
+ (funcall callback)))
+ (should
+ (ecukes-run-step
+ (mock-step "Given command azmzz")))))

0 comments on commit 85c0f13

Please sign in to comment.