Skip to content

Commit 0b3bbad

Browse files
committed
greatly expanded tests
1 parent 8d7405e commit 0b3bbad

File tree

12 files changed

+699
-12
lines changed

12 files changed

+699
-12
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
branches:
33
only:
44
- develop
5+
- dev_unstable
56
before_install:
67
- export ORIGINAL_FOLDER=$PWD
78
- sudo apt install libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev python3-dev lua5.1 lua5.1-dev libperl-dev git

ftplugin/python/pymode.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ if g:pymode_debug
228228
" Get a system independent temporary filename. The 'marker' variable is
229229
" used to get rid of a null character getting inserted at position.
230230
" substitute() was not able to remove it.
231+
" TODO: see https://superuser.com/questions/935574/get-rid-of-null-character-in-vim-variable
231232
let g:pymode_debug_tempfile=matchstr(
232233
\ execute(
233234
\ g:pymode_python

readme.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ help packages` in vim for details.
9898
cd ~/.vim
9999
mkdir -p bundle && cd bundle
100100
git clone https://github.com/python-mode/python-mode.git
101-
cd python-mode
102-
git submodule update --init --recursive
103101

104102
Enable [pathogen](https://github.com/tpope/vim-pathogen) in your `~/.vimrc`:
105103

@@ -116,7 +114,6 @@ Enable [pathogen](https://github.com/tpope/vim-pathogen) in your `~/.vimrc`:
116114

117115
% git clone https://github.com/python-mode/python-mode.git
118116
% cd python-mode
119-
% git submodule update --init --recursive
120117
% cp -R * ~/.vim
121118

122119
Then rebuild **helptags** in vim:

tests/test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
set -e
55
which vim 1>/dev/null 2>/dev/null
66

7+
cd $(dirname $0)
8+
79
# Source common variables.
810
source ./test_helpers_bash/test_variables.sh
911

tests/test_bash/test_folding.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
# Source file.
44
set +e
5-
RETURN_CODE=$(vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding1.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1)
5+
source ./test_helpers_bash/test_prepare_between_tests.sh
6+
vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding1.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
67
R1=$?
7-
bash ./test_helpers_bash/test_prepare_between_tests.sh
8-
RETURN_CODE=$(vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding2.vim" $VIM_DISPOSABLE_PYFILE > /dev/null 2>&1)
8+
source ./test_helpers_bash/test_prepare_between_tests.sh
9+
vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding2.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
910
R2=$?
11+
source ./test_helpers_bash/test_prepare_between_tests.sh
12+
vim -i NONE -u $VIM_TEST_VIMRC -c "source ./test_procedures_vimscript/folding3.vim" $VIM_DISPOSABLE_PYFILE > /dev/null
13+
R3=$?
1014
set -e
15+
1116
if [[ "$R1" -ne 0 ]]
1217
then
1318
exit 1
1419
elif [[ "$R2" -ne 0 ]]
1520
then
1621
exit 2
22+
elif [[ "$R3" -ne 0 ]]
23+
then
24+
exit 3
1725
fi
1826

19-
exit 0
20-
2127
# vim: set fileformat=unix filetype=sh wrap tw=0 :
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
#! /bin/bash
22

33
# Create minimal vimrc.
4+
echo -e "syntax on\nfiletype plugin indent on\nset nocompatible" >> $VIM_TEST_VIMRC
45
echo "call has('python3')" >> $VIM_TEST_VIMRC
5-
echo "set noswapfile" >> $VIM_TEST_VIMRC
6-
echo "set shell=bash" >> $VIM_TEST_VIMRC
6+
echo "set paste" >> $VIM_TEST_VIMRC
7+
echo "set shortmess=at" >> $VIM_TEST_VIMRC
8+
echo "set cmdheight=10" >> $VIM_TEST_VIMRC
79
echo "set ft=python" >> $VIM_TEST_VIMRC
8-
echo -e "syntax on\nfiletype plugin indent on\nset nocompatible" >> $VIM_TEST_VIMRC
10+
echo "set shell=bash" >> $VIM_TEST_VIMRC
11+
echo "set noswapfile" >> $VIM_TEST_VIMRC
12+
echo "set backupdir=" >> $VIM_TEST_VIMRC
13+
echo "set undodir=" >> $VIM_TEST_VIMRC
14+
echo "set viewdir=" >> $VIM_TEST_VIMRC
15+
echo "set directory=" >> $VIM_TEST_VIMRC
16+
echo -e "set runtimepath=" >> $VIM_TEST_VIMRC
917
echo -e "set runtimepath+=$(dirname $PWD)\n" >> $VIM_TEST_VIMRC
18+
# echo -e "redir! >> $VIM_OUTPUT_FILE\n" >> $VIM_TEST_VIMRC
1019
echo -e "set verbosefile=$VIM_OUTPUT_FILE\n" >> $VIM_TEST_VIMRC
20+
echo -e "let g:pymode_debug = 1" >> $VIM_TEST_VIMRC
21+
22+
echo "set nomore" >> $VIM_TEST_VIMRC
23+
1124

1225
# vim: set fileformat=unix filetype=sh wrap tw=0 :

tests/test_helpers_bash/test_prepare_between_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
# Prepare tests.
44
set +e
5-
rm $VIM_DISPOSABLE_PYFILE 2&>/dev/null
5+
rm $VIM_DISPOSABLE_PYFILE
6+
export VIM_DISPOSABLE_PYFILE=`mktemp /tmp/pymode.tmpfile.XXXXXXXXXX.py`
67
set -e
78
touch $VIM_DISPOSABLE_PYFILE
89

tests/test_helpers_bash/test_prepare_once.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Prepare tests.
44
set +e
55
rm $VIM_OUTPUT_FILE $VIM_TEST_VIMRC $VIM_TEST_PYMODECOMMANDS $VIM_DISPOSABLE_PYFILE 2&>/dev/null
6+
rm /tmp/*pymode* 2&>/dev/null
67
set -e
78

89
# vim: set fileformat=unix filetype=sh wrap tw=0 :
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
function! InsertRandomText(low_range, high_range) " {{{
2+
" Insert random ascii visible table text at cursor position.
3+
" Return the number of characters inserted.
4+
5+
python3 << EOF
6+
import random, string, vim
7+
# Text has to large from a larger sample in order to avoid errors.
8+
text = random.sample(
9+
(10 * string.ascii_lowercase + string.digits + ' '),
10+
random.randint(int(vim.eval('a:low_range')), int(vim.eval('a:high_range'))))
11+
vim.current.buffer.vars['random_text'] = ''.join(text)
12+
EOF
13+
let l:textwidth = &tw
14+
set tw=0
15+
execute "normal! i" . b:random_text
16+
let &tw = l:textwidth
17+
18+
return len(b:random_text)
19+
20+
endfunction " }}}
21+
22+
function! DeleteChars(nchars) " {{{
23+
" Delete n chars at cursor position.
24+
" It is the inverse of InsertRandomText().
25+
26+
let l:textwidth = &tw
27+
set tw=0
28+
execute "normal! " . (repeat('h', a:nchars - 1))
29+
execute "normal! " . repeat('x', a:nchars)
30+
let &tw = l:textwidth
31+
32+
endfunction " }}}
33+
34+
function! JumpToRandomPosition() " {{{
35+
" Jump cursor to a random position in current buffer.
36+
37+
python3 << EOF
38+
import random, vim
39+
cw = vim.current.window
40+
cb = vim.current.buffer
41+
rand_line = random.randint(1, len(cb) - 1)
42+
rand_line_len = len(cb[rand_line])
43+
rand_col = random.randint(0, rand_line_len) if rand_line_len > 0 else 0
44+
cw.cursor = (rand_line, rand_col)
45+
EOF
46+
endfunction " }}}
47+
48+
function! DeleteRandomLines(low_range, high_range) " {{{
49+
" Delete random lines between low_range and high_range.
50+
" Return the number of lines deleted.
51+
52+
python3 << EOF
53+
import random, vim
54+
del_lines = random.randint(
55+
int(vim.eval('a:low_range')), int(vim.eval('a:high_range')))
56+
vim.current.buffer.vars['del_lines'] = del_lines
57+
EOF
58+
59+
execute "normal! " . b:del_lines . "dd"
60+
61+
return b:del_lines
62+
63+
endfunction "}}}
64+
65+
function! InsertTextAtRandomPositions(ntimes) " {{{
66+
" Insert text at random positions. May either insert in insert mode or in
67+
" normal mode.
68+
69+
let l:total_lines = line('$')
70+
for i in range(a:ntimes)
71+
72+
python3 << EOF
73+
import random, vim
74+
del_method = random.randint(0, 1)
75+
vim.current.buffer.vars['del_method'] = del_method
76+
EOF
77+
78+
call JumpToRandomPosition()
79+
" b:del_method is set to either change the buffer via insert mode or
80+
" via normal mode.
81+
if b:del_method
82+
" This uses insert mode.
83+
let l:inserted_chars = InsertRandomText(3, 100)
84+
call DeleteChars(l:inserted_chars)
85+
else
86+
" This uses normal mode.
87+
let l:current_line = getpos('.')[1]
88+
let l:deleted_lines = DeleteRandomLines(1, 5)
89+
if l:current_line + l:deleted_lines <= l:total_lines
90+
execute "normal! P"
91+
else
92+
execute "normal! p"
93+
endif
94+
endif
95+
96+
endfor
97+
98+
endfunction " }}}

tests/test_helpers_vimscript/moving_around.vim

Whitespace-only changes.

0 commit comments

Comments
 (0)