Skip to content

Commit

Permalink
Add testing harness
Browse files Browse the repository at this point in the history
  • Loading branch information
magnars committed Nov 12, 2012
1 parent 1a8e233 commit 912e4e8
Show file tree
Hide file tree
Showing 5 changed files with 2,667 additions and 0 deletions.
32 changes: 32 additions & 0 deletions features/step-definitions/multifiles-steps.el
@@ -0,0 +1,32 @@
(When "^I press \"\\(.+\\)\"$"
(lambda (keybinding)
(let ((macro (edmacro-parse-keys keybinding)))
(if espuds-chain-active
(setq espuds-action-chain (vconcat espuds-action-chain macro))
(if (and (equal keybinding "C-g")
(eq (key-binding (kbd "C-g")) 'keyboard-quit))
(espuds-quit)
(execute-kbd-macro macro))))))

(When "^I go to character \"\\(.+\\)\"$"
(lambda (char)
(goto-char (point-min))
(let ((search (re-search-forward (format "%s" char) nil t))
(message "Can not go to character '%s' since it does not exist in the current buffer: %s"))
(assert search nil message char (espuds-buffer-contents)))))

(When "^I go to the \\(front\\|end\\) of the word \"\\(.+\\)\"$"
(lambda (pos word)
(goto-char (point-min))
(let ((search (re-search-forward (format "%s" word) nil t))
(message "Can not go to character '%s' since it does not exist in the current buffer: %s"))
(assert search nil message word (espuds-buffer-contents))
(if (string-equal "front" pos) (backward-word)))))

(When "^I select the last \"\\(.+\\)\"$"
(lambda (text)
(goto-char (point-max))
(let ((search (re-search-backward text nil t)))
(assert search nil "The text '%s' was not found in the current buffer." text))
(set-mark (point))
(re-search-forward text)))
26 changes: 26 additions & 0 deletions features/support/env.el
@@ -0,0 +1,26 @@
(let* ((current-directory (file-name-directory load-file-name))
(features-directory (expand-file-name ".." current-directory))
(project-directory (expand-file-name ".." features-directory)))
(setq multifiles-root-path project-directory)
(setq multifiles-util-path (expand-file-name "util" project-directory)))

(add-to-list 'load-path multifiles-root-path)
(add-to-list 'load-path multifiles-util-path)
(add-to-list 'load-path (expand-file-name "espuds" multifiles-util-path))

(require 'multiple-cursors)
(require 'espuds)
(require 'ert)

(Before
(switch-to-buffer
(get-buffer-create "*multifiles-test*"))
(erase-buffer)
(transient-mark-mode 1)
(cua-mode 0)
(delete-selection-mode 0)
(subword-mode 0)
(setq set-mark-default-inactive nil)
(deactivate-mark))

(After)
45 changes: 45 additions & 0 deletions run-tests.watchr
@@ -0,0 +1,45 @@
ENV["WATCHR"] = "1"
system 'clear'

def run(cmd)
`#{cmd}`
end

def run_all_tests
system('clear')
result = run "./util/ecukes/ecukes --graphical"
puts result
end

def run_test(file)
system('clear')
result = run "./util/ecukes/ecukes --graphical #{file}"
puts result
end

run_all_tests
watch('.*.feature') { |file| run_test file }
watch('.*.el') { run_all_tests }

# Ctrl-\
Signal.trap 'QUIT' do
puts " --- Running all tests ---\n\n"
run_all_tests
end

@interrupted = false

# Ctrl-C
Signal.trap 'INT' do
if @interrupted then
@wants_to_quit = true
abort("\n")
else
puts "Interrupt a second time to quit"
@interrupted = true
Kernel.sleep 1.5
# raise Interrupt, nil # let the run loop catch it
run_all_tests
@interrupted = false
end
end
20 changes: 20 additions & 0 deletions run-travis-ci.sh
@@ -0,0 +1,20 @@
#!/bin/sh

cd "$(dirname "$0")"

set_default () {
eval "
if [ -z \$$1 ]; then
$1=$2
fi
"
}

set_default ECUKES_EMACS "$(which emacs)"

echo "*** Emacs version ***"
echo "ECUKES_EMACS =" $(which $ECUKES_EMACS)
$ECUKES_EMACS --version
echo

exec ./util/ecukes/ecukes --graphical

0 comments on commit 912e4e8

Please sign in to comment.