Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple tests to catch dumb breakage before releases
- Loading branch information
1 parent
3f15c0a
commit 2d64a28
Showing
5 changed files
with
199 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.PHONY: all | ||
.DEFAULT: all | ||
|
||
all: | ||
vim -U NONE -u test/test.vim | ||
@echo "Done." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
" Some simple tests suited to my setup. | ||
set nocompatible | ||
|
||
" Uses thinca/vim-prettyprint to dump information if available. | ||
|
||
function! s:dump(something) | ||
if exists(":PP") | ||
echomsg PP(a:something) | ||
endif | ||
endfunction | ||
|
||
unlet! s:mess | ||
redir => s:mess | ||
try | ||
exe 'set runtimepath=' . expand("%:p:h") | ||
exe 'set runtimepath+=' . expand("~/.vim/bundle/prettyprint") | ||
|
||
set verbose=1 | ||
runtime plugin/patchreview.vim | ||
runtime plugin/prettyprint.vim | ||
set verbose=0 | ||
|
||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
" argument checking is not broken | ||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
try | ||
PatchReview | ||
echomsg 'Arguments check failed.' | ||
catch /^Vim:E471:\s*Argument required:\s*PatchReview/ | ||
echomsg 'Arguments check passed.' | ||
catch /.*/ | ||
echomsg 'Arguments check failed. Unexpected error: ' . v:exception | ||
endtry | ||
|
||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
" Check patch parsing is not broken | ||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
function! s:test_parse(patchfile, expected_parse) | ||
unlet! g:patches | ||
let l:patchlines = patchreview#get_patchfile_lines(a:patchfile) | ||
call patchreview#extract_diffs(l:patchlines, 0) | ||
if g:patches !=# a:expected_parse | ||
echomsg "Parsing" a:patchfile "failed." | ||
call s:dump(g:patches) | ||
else | ||
echomsg "Parsing" a:patchfile "succeeded." | ||
endif | ||
endfunction | ||
|
||
call s:test_parse('test/test1.patch', { | ||
\ 'fail': '', | ||
\ 'patch': [ | ||
\ { | ||
\ 'content': [ | ||
\ '--- a/x', | ||
\ '+++ b/x', | ||
\ '@@ -1,7 +1,7 @@', | ||
\ ' foo', | ||
\ ' bar', | ||
\ ' ', | ||
\ '-fubar', | ||
\ '+foobar', | ||
\ ' baz', | ||
\ ' quux', | ||
\ ' hoge', | ||
\ '@@ -9,6 +9,9 @@', | ||
\ ' a', | ||
\ ' b', | ||
\ ' c', | ||
\ '+d', | ||
\ '+e', | ||
\ '+f', | ||
\ ' g', | ||
\ ' h', | ||
\ ' i' | ||
\ ], | ||
\ 'filename': 'a/x', | ||
\ 'type': '!' | ||
\ } | ||
\ ] | ||
\ }) | ||
|
||
call s:test_parse('test/test2.patch', { | ||
\ 'fail': '', | ||
\ 'patch': [ | ||
\ { | ||
\ 'content': [ | ||
\ '*** ../a/b 2013-06-29 13:22:22.000000000 +0800', | ||
\ '--- a/b 2013-10-12 20:22:22.000000000 +0800', | ||
\ '***************', | ||
\ '*** 1,4 ****', | ||
\ '! " stuff.', | ||
\ ' ', | ||
\ ' foo', | ||
\ ' bar', | ||
\ '--- 1,4 ----', | ||
\ '! other stuff', | ||
\ ' ', | ||
\ ' foo', | ||
\ ' bar' | ||
\ ], | ||
\ 'filename': '../a/b', | ||
\ 'type': '!' | ||
\ }, | ||
\ { | ||
\ 'content': [ | ||
\ '*** ../k/x/y 2013-00-01 12:36:90.000000000 +0800', | ||
\ '--- x/y 2013-00-02 00:13:04.000000000 +0100', | ||
\ '***************', | ||
\ '*** 740,741 ****', | ||
\ '--- 740,743 ----', | ||
\ ' { /* Add new patch number below this line */', | ||
\ '+ /**/', | ||
\ '+ 53,', | ||
\ ' /**/' | ||
\ ], | ||
\ 'filename': '../k/x/y', | ||
\ 'type': '!' | ||
\ } | ||
\ ] | ||
\ }) | ||
|
||
finally | ||
echomsg 'All done.' | ||
redir END | ||
$put =s:mess | ||
redraw! | ||
setlocal nomodified nomodifiable | ||
endtry | ||
" vim: set et fdm=manual fenc=utf-8 ff=unix ft=vim sts=0 sw=2 ts=2 tw=79 nowrap : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
diff --git a/x b/x | ||
index 5d361ad..33757f0 100644 | ||
--- a/x | ||
+++ b/x | ||
@@ -1,7 +1,7 @@ | ||
foo | ||
bar | ||
|
||
-fubar | ||
+foobar | ||
baz | ||
quux | ||
hoge | ||
@@ -9,6 +9,9 @@ | ||
a | ||
b | ||
c | ||
+d | ||
+e | ||
+f | ||
g | ||
h | ||
i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
cruft | ||
more cruft | ||
------------ | ||
|
||
*** ../a/b 2013-06-29 13:22:22.000000000 +0800 | ||
--- a/b 2013-10-12 20:22:22.000000000 +0800 | ||
*************** | ||
*** 1,4 **** | ||
! " stuff. | ||
|
||
foo | ||
bar | ||
--- 1,4 ---- | ||
! other stuff | ||
|
||
foo | ||
bar | ||
*** ../k/x/y 2013-00-01 12:36:90.000000000 +0800 | ||
--- x/y 2013-00-02 00:13:04.000000000 +0100 | ||
*************** | ||
*** 740,741 **** | ||
--- 740,743 ---- | ||
{ /* Add new patch number below this line */ | ||
+ /**/ | ||
+ 53, | ||
/**/ | ||
|
||
cruft at the end | ||
|
||
and some more |