Add more example unit tests and run with travis

This commit is contained in:
Thiago de Arruda
2014-02-27 18:31:45 -03:00
parent d04ca90f5c
commit fd448123aa
3 changed files with 18 additions and 4 deletions

View File

@@ -36,6 +36,6 @@ clean:
install: build/bin/nvim
${MAKE} -C build install
.PHONY: test deps cmake install
.PHONY: test unittest deps cmake install
.DEFAULT: build/bin/nvim

View File

@@ -3,6 +3,7 @@
export VALGRIND_CHECK=1
make cmake CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$PWD/dist"
make
make unittest
echo "Running tests with valgrind..."
if ! make test > /dev/null; then
if ls src/testdir/valgrind.* > /dev/null 2>&1; then

View File

@@ -8,6 +8,7 @@ cstr = ffi.typeof 'char[?]'
describe 'misc1 function', ->
describe 'fullpathcmp', ->
ffi.cdef 'int fullpathcmp(char *s1, char *s2, int checkname);'
fullpathcmp = (s1, s2, cn) ->
s1 = cstr (string.len s1) + 1, s1
s2 = cstr (string.len s2) + 1, s2
@@ -15,7 +16,7 @@ describe 'misc1 function', ->
f1 = 'f1.o'
f2 = 'f2.o'
f3 = 'test/f1.o'
FPC_SAME = 1
FPC_DIFF = 2
FPC_NOTX = 4
@@ -26,13 +27,25 @@ describe 'misc1 function', ->
-- create the three files that will be used in this spec
(io.open f1, 'w').close!
(io.open f2, 'w').close!
(io.open f3, 'w').close!
after_each ->
os.remove f1
os.remove f2
os.remove f3
it 'returns FPC_SAME when passed the same file', ->
eq FPC_SAME, (fullpathcmp f1, f1)
it 'returns FPC_SAMEX when files that dont exist and have same name', ->
eq FPC_SAMEX, (fullpathcmp 'null.txt', 'null.txt', true)
it 'returns FPC_NOTX when files that dont exist', ->
eq FPC_NOTX, (fullpathcmp 'null.txt', 'null.txt')
it 'returns FPC_DIFF when passed different files', ->
eq FPC_DIFF, (fullpathcmp f1, f2)
eq FPC_DIFF, (fullpathcmp f2, f1)
it 'returns FPC_DIFFX if only one does not exist', ->
eq FPC_DIFFX, (fullpathcmp f1, 'null.txt')
eq FPC_DIFFX, (fullpathcmp 'null.txt', f1)