Skip to content

Commit 2f5463d

Browse files
committed
patch 8.0.0368: not all options are tested with a range of values
Problem: Not all options are tested with a range of values. Solution: Generate a test script from the source code.
1 parent f7506ca commit 2f5463d

File tree

5 files changed

+216
-1
lines changed

5 files changed

+216
-1
lines changed

Filelist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ SRC_ALL = \
9797
src/tee/tee.c \
9898
src/xxd/xxd.c \
9999
src/main.aap \
100+
src/gen_opt_test.vim \
100101
src/testdir/main.aap \
101102
src/testdir/README.txt \
102103
src/testdir/Make_all.mak \

src/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,7 @@ test check: scripttests unittests
20252025
#
20262026
scripttests:
20272027
$(MAKE) -f Makefile $(VIMTARGET)
2028+
$(MAKE) -f Makefile testdir/opt_test.vim
20282029
if test -n "$(MAKEMO)" -a -f $(PODIR)/Makefile; then \
20292030
cd $(PODIR); $(MAKE) -f Makefile check VIM=../$(VIMTARGET); \
20302031
fi
@@ -2033,6 +2034,8 @@ scripttests:
20332034
fi
20342035
cd testdir; $(MAKE) -f Makefile $(GUI_TESTTARGET) VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
20352036

2037+
testdir/opt_test.vim: option.c gen_opt_test.vim
2038+
./$(VIMTARGET) -u gen_opt_test.vim --noplugin --not-a-term
20362039

20372040
# Run the tests with the GUI. Assumes vim/gvim was already built
20382041
testgui:
@@ -2753,6 +2756,7 @@ clean celan: testclean
27532756
-rm -f *.o objects/* core $(VIMTARGET).core $(VIMTARGET) vim xxd/*.o
27542757
-rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c auto/gui_gtk_gresources.c auto/gui_gtk_gresources.h
27552758
-rm -f conftest* *~ auto/link.sed
2759+
-rm -f testdir/opt_test.vim
27562760
-rm -f $(UNITTEST_TARGETS)
27572761
-rm -f runtime pixmaps
27582762
-rm -rf $(APPDIR)
@@ -2767,7 +2771,7 @@ SHADOWDIR = shadow
27672771

27682772
shadow: runtime pixmaps
27692773
mkdir $(SHADOWDIR)
2770-
cd $(SHADOWDIR); ln -s ../*.[chm] ../*.in ../*.sh ../*.xs ../*.xbm ../gui_gtk_res.xml ../toolcheck ../proto ../vimtutor ../gvimtutor ../mkinstalldirs .
2774+
cd $(SHADOWDIR); ln -s ../*.[chm] ../*.in ../*.vim ../*.sh ../*.xs ../*.xbm ../gui_gtk_res.xml ../toolcheck ../proto ../vimtutor ../gvimtutor ../mkinstalldirs .
27712775
mkdir $(SHADOWDIR)/auto
27722776
cd $(SHADOWDIR)/auto; ln -s ../../auto/configure .
27732777
mkdir $(SHADOWDIR)/po

src/gen_opt_test.vim

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
" Script to generate testdir/opt_test.vim from option.c
2+
3+
if 0
4+
finish
5+
endif
6+
7+
set cpo=&vim
8+
set nomore
9+
10+
let script = [
11+
\ 'let save_columns = &columns',
12+
\ 'let save_lines = &lines',
13+
\ 'let save_term = &term',
14+
\ ]
15+
16+
edit option.c
17+
/#define p_term
18+
let end = line('.')
19+
20+
" Two lists with values: values that work and values that fail.
21+
" When not listed, "othernum" or "otherstring" is used.
22+
let test_values = {
23+
\ 'cmdheight': [[1, 2, 10], [-1, 0]],
24+
\ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
25+
\ 'columns': [[12, 80], [-1, 0, 10]],
26+
\ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
27+
\ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
28+
\ 'helpheight': [[0, 10, 100], [-1]],
29+
\ 'history': [[0, 1, 100], [-1, 10001]],
30+
\ 'iminsert': [[0, 1, 2], [-1, 3, 999]],
31+
\ 'imsearch': [[-1, 0, 1, 2], [-2, 3, 999]],
32+
\ 'lines': [[2, 24], [-1, 0, 1]],
33+
\ 'numberwidth': [[1, 4, 8, 10], [-1, 0, 11]],
34+
\ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
35+
\ 'report': [[0, 1, 2, 9999], [-1]],
36+
\ 'scroll': [[0, 1, 2, 20], [-1]],
37+
\ 'scrolljump': [[-50, -1, 0, 1, 2, 20], [999]],
38+
\ 'scrolloff': [[0, 1, 2, 20], [-1]],
39+
\ 'shiftwidth': [[0, 1, 8, 999], [-1]],
40+
\ 'sidescroll': [[0, 1, 8, 999], [-1]],
41+
\ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
42+
\ 'tabstop': [[1, 4, 8, 12], [-1, 0]],
43+
\ 'textwidth': [[0, 1, 8, 99], [-1]],
44+
\ 'timeoutlen': [[0, 8, 99999], [-1]],
45+
\ 'titlelen': [[0, 1, 8, 9999], [-1]],
46+
\ 'updatecount': [[0, 1, 8, 9999], [-1]],
47+
\ 'updatetime': [[0, 1, 8, 9999], [-1]],
48+
\ 'verbose': [[-1, 0, 1, 8, 9999], []],
49+
\ 'winheight': [[1, 10, 999], [-1, 0]],
50+
\ 'winminheight': [[0, 1], [-1]],
51+
\ 'winminwidth': [[0, 1, 10], [-1]],
52+
\ 'winwidth': [[1, 10, 999], [-1, 0]],
53+
\
54+
\ 'ambiwidth': [['', 'single'], ['xxx']],
55+
\ 'background': [['', 'light', 'dark'], ['xxx']],
56+
\ 'backspace': [[0, 2, '', 'eol', 'eol,start'], ['xxx']],
57+
\ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']],
58+
\ 'backupext': [['xxx'], ['']],
59+
\ 'belloff': [['', 'all', 'copy,error'], ['xxx']],
60+
\ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']],
61+
\ 'browsedir': [['', 'last', '/tmp/'], ['xxx']],
62+
\ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
63+
\ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
64+
\ 'casemap': [['', 'internal'], ['xxx']],
65+
\ 'cedit': [['', '\<Esc>'], ['xxx', 'f']],
66+
\ 'clipboard': [['', 'unnamed', 'autoselect,unnamed'], ['xxx']],
67+
\ 'colorcolumn': [['', '8', '+2'], ['xxx']],
68+
\ 'comments': [['', 'b:#'], ['xxx']],
69+
\ 'commentstring': [['', '/*%s*/'], ['xxx']],
70+
\ 'complete': [['', 'w,b'], ['xxx']],
71+
\ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
72+
\ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
73+
\ 'cryptmethod': [['', 'zip'], ['xxx']],
74+
\ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
75+
\ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
76+
\ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx']],
77+
\ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
78+
\ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
79+
\ 'encoding': [['latin1'], ['xxx', '']],
80+
\ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']],
81+
\ 'fileencoding': [['', 'latin1', 'xxx'], []],
82+
\ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
83+
\ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
84+
\ 'fillchars': [['', 'vert:x'], ['xxx']],
85+
\ 'foldclose': [['', 'all'], ['xxx']],
86+
\ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
87+
\ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
88+
\ 'foldmarker': [['((,))'], ['', 'xxx']],
89+
\ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
90+
\ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
91+
\ 'helplang': [['', 'de', 'de,it'], ['xxx']],
92+
\ 'highlight': [['', 'e:Error'], ['xxx']],
93+
\ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
94+
\ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
95+
\ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
96+
\ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
97+
\ 'keymap': [['', 'accents'], ['xxx']],
98+
\ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
99+
\ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
100+
\ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
101+
\ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
102+
\ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
103+
\ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
104+
\ 'mousemodel': [['', 'popup'], ['xxx']],
105+
\ 'mouseshape': [['', 'n:arrow'], ['xxx']],
106+
\ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
107+
\ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
108+
\ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
109+
\ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
110+
\ 'selection': [['old', 'inclusive'], ['', 'xxx']],
111+
\ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
112+
\ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
113+
\ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
114+
\ 'spellfile': [['', 'file.en.add'], ['xxx', '/tmp/file']],
115+
\ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
116+
\ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
117+
\ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
118+
\ 'term': [['ansi'], ['', 'gui']],
119+
\ 'toolbar': [['', 'icons', 'text'], ['xxx']],
120+
\ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
121+
\ 'ttymouse': [['', 'xterm'], ['xxx']],
122+
\ 'ttytype': [['ansi'], ['', 'gui']],
123+
\ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
124+
\ 'viminfo': [['', '''50', '"30'], ['xxx']],
125+
\ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
126+
\ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
127+
\ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx']],
128+
\ 'wildoptions': [['', 'tagfile'], ['xxx']],
129+
\ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
130+
\
131+
\ 'luadll': [[], []],
132+
\ 'macatsui': [[], []],
133+
\ 'perldll': [[], []],
134+
\ 'pythondll': [[], []],
135+
\ 'pythonthreedll': [[], []],
136+
\ 'pyxversion': [[], []],
137+
\ 'rubydll': [[], []],
138+
\ 'tcldll': [[], []],
139+
\
140+
\ 'othernum': [[-1, 0, 100], []],
141+
\ 'otherstring': [['', 'xxx'], []],
142+
\}
143+
144+
1
145+
/struct vimoption options
146+
while 1
147+
/{"
148+
if line('.') > end
149+
break
150+
endif
151+
let line = getline('.')
152+
let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
153+
let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
154+
155+
if has_key(test_values, name)
156+
let a = test_values[name]
157+
elseif line =~ 'P_NUM'
158+
let a = test_values['othernum']
159+
else
160+
let a = test_values['otherstring']
161+
endif
162+
if len(a[0]) > 0 || len(a[1]) > 0
163+
if line =~ 'P_BOOL'
164+
call add(script, 'set ' . name)
165+
call add(script, 'set ' . shortname)
166+
call add(script, 'set no' . name)
167+
call add(script, 'set no' . shortname)
168+
else
169+
for val in a[0]
170+
call add(script, 'set ' . name . '=' . val)
171+
call add(script, 'set ' . shortname . '=' . val)
172+
endfor
173+
for val in a[1]
174+
call add(script, "call assert_fails('set " . name . "=" . val . "')")
175+
call add(script, "call assert_fails('set " . shortname . "=" . val . "')")
176+
endfor
177+
endif
178+
179+
call add(script, 'set ' . name . '&')
180+
call add(script, 'set ' . shortname . '&')
181+
endif
182+
endwhile
183+
184+
call add(script, 'let &term = save_term')
185+
call add(script, 'let &columns = save_columns')
186+
call add(script, 'let &lines = save_lines')
187+
188+
call writefile(script, 'testdir/opt_test.vim')
189+
190+
qa!

src/testdir/test_options.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,21 @@ func Test_set_ttytype()
275275
call assert_equal(&ttytype, &term)
276276
endif
277277
endfunc
278+
279+
func Test_set_all()
280+
set tw=75
281+
set iskeyword=a-z,A-Z
282+
set nosplitbelow
283+
let out = execute('set all')
284+
call assert_match('textwidth=75', out)
285+
call assert_match('iskeyword=a-z,A-Z', out)
286+
call assert_match('nosplitbelow', out)
287+
set tw& iskeyword& splitbelow&
288+
endfunc
289+
290+
func Test_set_values()
291+
" The file is only generated when running "make test" in the src directory.
292+
if filereadable('opt_test.vim')
293+
source opt_test.vim
294+
endif
295+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
368,
767769
/**/
768770
367,
769771
/**/

0 commit comments

Comments
 (0)