Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add support for async steps.

  • Loading branch information...
commit 85c0f13217c04aa902d6e1a41260382a15a8c6ef 1 parent c915913
Johan Andersson authored December 26, 2012
17  ecukes-run.el
@@ -104,8 +104,21 @@
104 104
                  (args (ecukes-steps-args step))
105 105
                  (args (if arg (cons arg args) args))
106 106
                  (step-def (ecukes-steps-find body))
107  
-                 (fn (ecukes-step-def-fn step-def)))
108  
-            (apply fn args))
  107
+                 (fn (ecukes-step-def-fn step-def))
  108
+                 (fn-args-count
  109
+                  (length
  110
+                   (if (byte-code-function-p fn)
  111
+                       (aref fn 0)
  112
+                     (if (listp fn)
  113
+                         (cadr fn))))))
  114
+            (if (and (not (symbolp fn)) (> fn-args-count (length args)))
  115
+                (progn
  116
+                  (let ((wait t))
  117
+                    (add-to-list 'args (lambda (&rest args) (setq wait nil)) t)
  118
+                    (apply fn args)
  119
+                    (while wait
  120
+                      (accept-process-output nil 0.005))))
  121
+              (apply fn args)))
109 122
           (setq success t))
110 123
       (error
111 124
        (setf (ecukes-step-err step) (error-message-string err)))
10  test/ecukes-run-test.el
@@ -435,3 +435,13 @@
435 435
     (should
436 436
      (ecukes-run-step
437 437
       (mock-step "Given this:" :type 'table :arg "py-string"))))))
  438
+
  439
+(ert-deftest run-step-with-callback ()
  440
+  "Should run step with callback."
  441
+  (with-steps
  442
+   (Given "^command \\(.+\\)$"
  443
+          (lambda (command callback)
  444
+            (funcall callback)))
  445
+   (should
  446
+    (ecukes-run-step
  447
+     (mock-step "Given command azmzz")))))

0 notes on commit 85c0f13

Please sign in to comment.
Something went wrong with that request. Please try again.