Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 147 lines (112 sloc) 4.685 kB
00bd269 @rejeep Do not hardcode path to Emacs bin, use env instead.
rejeep authored
1 #!/usr/bin/env emacs --script
5ff12c7 @rejeep Adding comments in ecukes file.
rejeep authored
2
5b9efea @rejeep Is not named ecukes.el anymore.
rejeep authored
3 ;;; ecukes --- Cucumber for Emacs
5ff12c7 @rejeep Adding comments in ecukes file.
rejeep authored
4
5 ;; Copyright (C) 2010 Johan Andersson
6
7 ;; Author: Johan Andersson <johan.rejeep@gmail.com>
8 ;; Maintainer: Johan Andersson <johan.rejeep@gmail.com>
c97f866 @rejeep Minor version upgrade.
rejeep authored
9 ;; Version: 0.1.0
38e724c @rejeep Updating keywords.
rejeep authored
10 ;; Keywords: testing, cucumber
5ff12c7 @rejeep Adding comments in ecukes file.
rejeep authored
11 ;; URL: http://github.com/rejeep/ecukes
12
13 ;; This file is NOT part of GNU Emacs.
14
15 ;;; License:
16
17 ;; This program is free software; you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by
19 ;; the Free Software Foundation; either version 3, or (at your option)
20 ;; any later version.
21
22 ;; This program is distributed in the hope that it will be useful,
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;; GNU General Public License for more details.
26
27 ;; You should have received a copy of the GNU General Public License
28 ;; along with GNU Emacs; see the file COPYING. If not, write to the
29 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
30 ;; Boston, MA 02110-1301, USA.
31
32 ;;; Commentary:
33
c7e1e5f @rejeep Commentary is in README.
rejeep authored
34 ;; See README
35
5ff12c7 @rejeep Adding comments in ecukes file.
rejeep authored
36 ;;; Code:
37
6262c6e @rejeep Move these to top of file.
rejeep authored
38 (setq debug-on-error t)
39 (setq debug-on-entry t)
40
ae6db23 @rejeep Set variables and load path.
rejeep authored
41 (defvar ecukes-path
42 (file-name-directory load-file-name)
43 "Path to ecukes.")
44
45 (defvar ecukes-vendor-path
46 (expand-file-name "vendor" ecukes-path)
47 "Path to ecukes vendor.")
48
93097a9 @rejeep Set a global variable called ecukes-path, which is the absolute path …
rejeep authored
49 (add-to-list 'load-path ecukes-path)
ae6db23 @rejeep Set variables and load path.
rejeep authored
50 (add-to-list 'load-path ecukes-vendor-path)
51
7e2fbe5 @rejeep Eval when compile Ecukes libraries.
rejeep authored
52 (eval-when-compile
16ee1d8 @rejeep Only require cl when compiling.
rejeep authored
53 (require 'cl))
54
39a4c4f @rejeep Add ansi.el.
rejeep authored
55 (require 'ansi)
86a09b6 @rejeep Update run script.
rejeep authored
56 (require 'ecukes-template)
16ee1d8 @rejeep Only require cl when compiling.
rejeep authored
57 (require 'ecukes-new)
58 (require 'ecukes-def)
86a09b6 @rejeep Update run script.
rejeep authored
59 (require 'ecukes-startup)
16ee1d8 @rejeep Only require cl when compiling.
rejeep authored
60 (require 'ecukes-parse)
86a09b6 @rejeep Update run script.
rejeep authored
61 (require 'ecukes-steps)
16ee1d8 @rejeep Only require cl when compiling.
rejeep authored
62 (require 'ecukes-run)
86a09b6 @rejeep Update run script.
rejeep authored
63 (require 'ecukes-print)
16ee1d8 @rejeep Only require cl when compiling.
rejeep authored
64 (require 'ecukes-hooks)
65 (require 'ecukes-stats)
66
67 (add-to-list 'command-switch-alist '("--new" . ecukes-new-handler))
95aed06 @rejeep Load project first when we know the input is valid.
rejeep authored
68
86a09b6 @rejeep Update run script.
rejeep authored
69 (when (ecukes-startup-run-p)
70
4cc5684 @rejeep Do not print background steps again.
rejeep authored
71 (defun run-step (step &optional print)
86a09b6 @rejeep Update run script.
rejeep authored
72 "Run STEP, including increasing counters."
73 (ecukes-stats-step
74 (if previous-step-success
75 (cond
76 ((ecukes-run-step step)
77 (ecukes-stats-step-pass)
78 (ecukes-stats-scenario-pass)
4cc5684 @rejeep Do not print background steps again.
rejeep authored
79 (if print
80 (ecukes-print-step-success step)))
86a09b6 @rejeep Update run script.
rejeep authored
81 (t
82 (ecukes-stats-step-fail)
83 (ecukes-stats-scenario-fail)
4cc5684 @rejeep Do not print background steps again.
rejeep authored
84 (if print
85 (ecukes-print-step-failure step))
86a09b6 @rejeep Update run script.
rejeep authored
86 (setq previous-step-success nil)))
87 (ecukes-stats-step-skip)
4cc5684 @rejeep Do not print background steps again.
rejeep authored
88 (if print
89 (ecukes-print-step-pending step)))))
86a09b6 @rejeep Update run script.
rejeep authored
90
91 (let ((feature-files (ecukes-startup-features argv)))
bb0de7d @rejeep Instead of a separate script (ecukes-init) "ecukes --init" is used to…
rejeep authored
92 (cond (feature-files
86a09b6 @rejeep Update run script.
rejeep authored
93
94 (ecukes-startup-load)
4cc5684 @rejeep Do not print background steps again.
rejeep authored
95
86a09b6 @rejeep Update run script.
rejeep authored
96 (ecukes-hooks-run-setup)
97
98 (dolist (feature-file feature-files)
99 (let* ((feature (ecukes-parse-feature feature-file))
100 (background (ecukes-feature-background feature))
101 (scenarios (ecukes-feature-scenarios feature))
102 (steps
103 (apply
104 'append
105 (if background (ecukes-background-steps background))
106 (mapcar 'ecukes-scenario-steps scenarios)))
107 (undefined (ecukes-steps-undefined steps)))
4cc5684 @rejeep Do not print background steps again.
rejeep authored
108
86a09b6 @rejeep Update run script.
rejeep authored
109 (setq previous-step-success t)
110 (setq background-runned nil)
111
112 (cond (undefined
113 (ecukes-print-undefined-steps undefined))
114 ((let ((intro (ecukes-feature-intro feature)))
115 (ecukes-print-intro intro)
116
117 (when background
118 (ecukes-print-background-header)
119 (dolist (step (ecukes-background-steps background))
4cc5684 @rejeep Do not print background steps again.
rejeep authored
120 (run-step step t))
86a09b6 @rejeep Update run script.
rejeep authored
121 (setq background-runned t))
122
123 (dolist (scenario scenarios)
124 (ecukes-stats-scenario
125 (ecukes-hooks-run-before)
126
127 (when background
128 (dolist (step (ecukes-background-steps background))
129 (run-step step)))
130
131 (ecukes-print-newline)
132 (ecukes-print-scenario-header scenario)
133 (dolist (step (ecukes-scenario-steps scenario))
4cc5684 @rejeep Do not print background steps again.
rejeep authored
134 (run-step step t))
135
136 (setq previous-step-success t)
86a09b6 @rejeep Update run script.
rejeep authored
137
138 (ecukes-hooks-run-after))))))))
139 (ecukes-hooks-run-teardown)
140
141 (ecukes-stats-print-summary))
142 (t
143 (ecukes-print-message
144 (ansi-red "You did not provide any features to run"))))))
ce677a5 @rejeep Rename ecukes script to ecukes.el
rejeep authored
145
5ff12c7 @rejeep Adding comments in ecukes file.
rejeep authored
146 ;;; ecukes.el ends here
Something went wrong with that request. Please try again.