Capture test run errors

This commit is contained in:
Tim Pope 2014-05-05 01:23:30 -04:00
parent 0b17709b56
commit af14811869

View File

@ -1408,6 +1408,7 @@ augroup END
function! fireplace#capture_test_run(expr) abort function! fireplace#capture_test_run(expr) abort
let expr = '(require ''clojure.test) ' let expr = '(require ''clojure.test) '
\ . '(try '
\ . '(binding [clojure.test/report (fn [m]' \ . '(binding [clojure.test/report (fn [m]'
\ . ' (case (:type m)' \ . ' (case (:type m)'
\ . ' (:fail :error)' \ . ' (:fail :error)'
@ -1420,6 +1421,9 @@ function! fireplace#capture_test_run(expr) abort
\ . ' (println " actual:" (pr-str (:actual m)))))' \ . ' (println " actual:" (pr-str (:actual m)))))'
\ . ' ((.getRawRoot #''clojure.test/report) m)))]' \ . ' ((.getRawRoot #''clojure.test/report) m)))]'
\ . ' ' . a:expr . ')' \ . ' ' . a:expr . ')'
\ . ' (catch Exception e'
\ . ' (println (str e))'
\ . ' (println (clojure.string/join "\n" (.getStackTrace e)))))'
let qflist = [] let qflist = []
let response = s:eval(expr, {'session': 0}) let response = s:eval(expr, {'session': 0})
if !has_key(response, 'out') if !has_key(response, 'out')
@ -1427,8 +1431,8 @@ function! fireplace#capture_test_run(expr) abort
return s:output_response(response) return s:output_response(response)
endif endif
for line in split(response.out, "\n") for line in split(response.out, "\n")
let entry = {'text': line}
if line =~# '\t.*\t.*\t' if line =~# '\t.*\t.*\t'
let entry = {'text': line}
let [resource, lnum, type, name] = split(line, "\t", 1) let [resource, lnum, type, name] = split(line, "\t", 1)
let entry.lnum = lnum let entry.lnum = lnum
let entry.type = (type ==# 'fail' ? 'W' : 'E') let entry.type = (type ==# 'fail' ? 'W' : 'E')
@ -1441,6 +1445,8 @@ function! fireplace#capture_test_run(expr) abort
if empty(entry.filename) if empty(entry.filename)
let entry.lnum = 0 let entry.lnum = 0
endif endif
else
let entry = s:qfmassage(line, fireplace#path())
endif endif
call add(qflist, entry) call add(qflist, entry)
endfor endfor