From 9b21f11b2f1ee96526e03877c2699fa203d2e7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ois=C3=ADn=20Mac=20Fheara=C3=AD?= Date: Wed, 4 Aug 2021 22:39:23 +0100 Subject: [PATCH] * Use custom vimrc for tests, so results aren't affected by the user's personal vim config * Make indenter test script count passes and failures at the end * Add test result files to .gitignore * Add testcase for multiline if/then/else --- .gitignore | 1 + tests/indent/base.rc | 2 ++ tests/indent/run.sh | 12 ++++++++++-- tests/indent/test020/expected.hs | 5 +++++ tests/indent/test020/test.hs | 1 + tests/indent/test020/test.vim | 3 +++ 6 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/indent/base.rc create mode 100644 tests/indent/test020/expected.hs create mode 100644 tests/indent/test020/test.hs create mode 100644 tests/indent/test020/test.vim diff --git a/.gitignore b/.gitignore index 6e92f57..a8a6d81 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ tags +result.hs diff --git a/tests/indent/base.rc b/tests/indent/base.rc new file mode 100644 index 0000000..8a2b5af --- /dev/null +++ b/tests/indent/base.rc @@ -0,0 +1,2 @@ +set ts=2 sts=2 sw=2 expandtab +source ../../../indent/haskell.vim diff --git a/tests/indent/run.sh b/tests/indent/run.sh index 728649f..682ea1b 100644 --- a/tests/indent/run.sh +++ b/tests/indent/run.sh @@ -1,14 +1,22 @@ #!/bin/sh +COUNT_FAIL=0 +COUNT_PASS=0 + for i in test???; do cd $i - nvim --headless -s test.vim test.hs 2> /dev/null + nvim --headless -u ../base.rc -s test.vim test.hs 2> /dev/null diff expected.hs result.hs if [ $? -eq 0 ]; then - echo "$(basename $PWD) succeded" + COUNT_PASS=$((COUNT_PASS+1)) + echo "$(basename $PWD) succeeded" rm result.hs else + COUNT_FAIL=$((COUNT_FAIL+1)) echo "$(basename $PWD) failed" fi cd .. done + +echo "====" +echo "PASSED: $COUNT_PASS\tFAILED: $COUNT_FAIL" diff --git a/tests/indent/test020/expected.hs b/tests/indent/test020/expected.hs new file mode 100644 index 0000000..0fed888 --- /dev/null +++ b/tests/indent/test020/expected.hs @@ -0,0 +1,5 @@ + if True + then do + print 1 + else do + print 2 diff --git a/tests/indent/test020/test.hs b/tests/indent/test020/test.hs new file mode 100644 index 0000000..0cb5b65 --- /dev/null +++ b/tests/indent/test020/test.hs @@ -0,0 +1 @@ + if True diff --git a/tests/indent/test020/test.vim b/tests/indent/test020/test.vim new file mode 100644 index 0000000..f86759d --- /dev/null +++ b/tests/indent/test020/test.vim @@ -0,0 +1,3 @@ +GA then do print 1 else do print 2 +:saveas! result.hs +:q!