From 12b0506e79aa109fcbe1c8007a68c31cf09c9d71 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Fri, 2 Nov 2007 22:42:07 -0400 Subject: [PATCH] cleaner emacs frontend; added clear backend --- lib/backends/clear_backend.rb | 12 ++++++++++++ lib/backends/coloring_backend.rb | 4 ++-- lib/backends/test_unit_backend.rb | 2 +- lib/frontends/augment.el | 16 ++++++++++++++-- spec/emacs-frontend-test.el | 21 +++++++++++++++++++++ 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 lib/backends/clear_backend.rb diff --git a/lib/backends/clear_backend.rb b/lib/backends/clear_backend.rb new file mode 100644 index 0000000..106a3d3 --- /dev/null +++ b/lib/backends/clear_backend.rb @@ -0,0 +1,12 @@ +require 'find' +require 'fileutils' + +class ClearBackend < Backend + class << self + def run(file) + Find.find(file) { |f| FileUtils.rm_rf(f) if f =~ /\.augment$/ } + end + end + + Augment::BACKENDS['clear'] = self +end diff --git a/lib/backends/coloring_backend.rb b/lib/backends/coloring_backend.rb index 2a0fec1..b9a0fda 100644 --- a/lib/backends/coloring_backend.rb +++ b/lib/backends/coloring_backend.rb @@ -20,6 +20,6 @@ class ColoringBackend < Backend write_layers end end + + Augment::BACKENDS['color'] = self end - -Augment::BACKENDS['color'] = ColoringBackend diff --git a/lib/backends/test_unit_backend.rb b/lib/backends/test_unit_backend.rb index e197b2a..f160a10 100644 --- a/lib/backends/test_unit_backend.rb +++ b/lib/backends/test_unit_backend.rb @@ -40,7 +40,7 @@ end def Layer.from_failure(file, klass, method, exception) color = Test::Assertion === exception ? 'red' : 'yellow' - trace = exception.backtrace.detect { |e| e =~ /test_drink/ } + trace = exception.backtrace.detect { |e| e =~ Regexp.new(file) } line = trace.match(/:(\d*):/)[1] range = Layer.line_to_char_range(file, line.to_i) diff --git a/lib/frontends/augment.el b/lib/frontends/augment.el index 00a59cb..73cdf62 100644 --- a/lib/frontends/augment.el +++ b/lib/frontends/augment.el @@ -52,6 +52,8 @@ (defstruct layer begin end color message backend) +(setq augment-debug t) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun augment-layer-from-plist (plist) @@ -107,7 +109,13 @@ (setq layers nil) (augment-clear) (augment-start-process) - (process-send-string "augment" (concat (or file (buffer-file-name)) "\n"))) + (setq in (concat (or file + (expand-file-name (buffer-file-name))) + "\n")) + + (process-send-string "augment" (concat (or file + (expand-file-name (buffer-file-name))) + "\n"))) (defun augment-start-process () (unless (get-process "augment") ;; only one should be running at a time @@ -117,6 +125,9 @@ 'augment-filter))) (defun augment-filter (process output) + (setq out output) +;; (if augment-debug (with-current-buffer "*augment-debug*" +;; (insert output))) (if (string-match "^Error augmenting \\(.*\\)\\." output) (error "Error augmenting %s." (match-string 1 output)) ;; layers need to be cached in local var for messages @@ -141,7 +152,8 @@ (defun augment-reset () (interactive) - (kill-process "augment") + (if (get-process "augment") + (kill-process "augment")) (augment-clear)) (provide 'augment) diff --git a/spec/emacs-frontend-test.el b/spec/emacs-frontend-test.el index 030880b..da122e4 100644 --- a/spec/emacs-frontend-test.el +++ b/spec/emacs-frontend-test.el @@ -19,6 +19,7 @@ (elunit-clear-suites) (defsuite augment-suite nil) +(augment-reset) (deftest layer-from-plist augment-suite "The layer struct should populated from a plist." @@ -60,4 +61,24 @@ (augment-filter nil (flymake-read-file-to-string "fixtures/augment-output.txt")) (assert-overlay 2))) +(deftest no-problems-file augment-suite + (save-excursion + (find-file "fixtures/working_test.rb") + (augment-initiate) + (sleep-for 1) + (kill-buffer "working_test.rb"))) + +(deftest fix-all-problems augment-suite + (save-excursion + (find-file "fixtures/fix_test.rb") + (augment-initiate) + (sleep-for 1) + (assert-overlay 77) + (beginning-of-buffer) + (replace-regexp "assert false" "assert true") + (augment-initiate) + (sleep-for 1) + (assert-no-overlay 77) + (kill-buffer "fix_test.rb"))) + (elunit "augment-suite") \ No newline at end of file -- 2.11.4.GIT