Skip to content

Commit 659039e

Browse files
author
Le Tien Tai
committed
Setup for testing
1 parent b65179b commit 659039e

File tree

8 files changed

+116
-0
lines changed

8 files changed

+116
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*~
33
.DS_Store
44
tags
5+
vader.vim/

test/basic.vader

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Do (Sample):
2+
iHello, world!
3+
4+
Expect(Sample):
5+
Hello, world!

test/custom-template.vader

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Do (Test 2):
2+
iThis is the second test file.
3+
4+
Expect (Test 2):
5+
This is the second test file.

test/minimal_vimrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
" Minimal vimrc to run tests
2+
" --------------------------
3+
4+
set nocompatible
5+
set nu
6+
" Clear all rtp
7+
set rtp=
8+
9+
" Now add vader.vim to runtime path
10+
set rtp+=./vader.vim
11+
filetype plugin indent on

test/nodemon.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"watch": "../",
3+
"ignore": [
4+
".git",
5+
"node_modules/**/node_modules",
6+
"vader.vim"
7+
],
8+
"verbose": true,
9+
"ext": "vader vim",
10+
"execMap": {
11+
"vader": "./run-single-test-file.sh"
12+
}
13+
}

test/readme.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Test cases for vim-pydocstring
2+
==========================================
3+
4+
Prerequisite
5+
------------
6+
7+
- [vader.vim](https://github.com/junegunn/vader.vim)
8+
9+
Before running test, clone vader into this directory with:
10+
11+
```
12+
git clone https://github.com/junegunn/vader.vim
13+
```
14+
15+
16+
Run
17+
---
18+
19+
```
20+
./run.sh
21+
```
22+
23+
Note that the command need to be executed under `test` folder.
24+
25+
Use TDD during development (optional)
26+
-------------------------------------
27+
28+
You need [nodemon](https://github.com/remy/nodemon) to watch for files
29+
change and re-run the test cases in given file. Here I already provide
30+
nodemon configuration (see `nodemon.json`.)
31+
32+
Run (again, this need to be executed under `test` folder)
33+
34+
```
35+
nodemon <test-file>.vader
36+
```
37+
38+
Now, if you modify the `vader` or `vim` files in this project, nodemon will
39+
re-run all the test cases (via `run-single-test-file.sh`).
40+
41+
42+
### Know issue
43+
44+
Vim warns `Input is not from a terminal` when we run tests with
45+
`nodemon`. Neovim doesn't. That why in the scripts, we prefer to use
46+
`nvim` if it is found on path.

test/run-single-test-file.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
###############################################################################
4+
# Execute a single test file #
5+
###############################################################################
6+
7+
if [ $# -eq 0 ]; then
8+
echo "Please supply an input *.vader file"
9+
exit
10+
fi
11+
12+
VIM_EXE="vim"
13+
14+
if hash nvim 2>/dev/null ; then
15+
VIM_EXE="nvim"
16+
fi
17+
18+
# Open vim with readonly mode just to execute all *.vader tests.
19+
$VIM_EXE -Nu minimal_vimrc -R "+Vader $1"

test/run.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
###############################################################################
4+
# Execute all test case #
5+
###############################################################################
6+
7+
VIM_EXE="vim"
8+
9+
# If nvim is available in PATH, then we prefer to use nvim
10+
# since it works better with nodemon
11+
if hash nvim 2>/dev/null ; then
12+
VIM_EXE="nvim"
13+
fi
14+
15+
# Open vim with readonly mode just to execute all *.vader tests.
16+
$VIM_EXE -Nu minimal_vimrc -R '+Vader *.vader'

0 commit comments

Comments
 (0)