comparison src/testdir/test_quickfix.vim @ 16720:9c90cf08cfa8 v8.1.1362

patch 8.1.1362: code and data in tests can be hard to read commit https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 20 22:12:34 2019 +0200 patch 8.1.1362: code and data in tests can be hard to read Problem: Code and data in tests can be hard to read. Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4400)
author Bram Moolenaar <Bram@vim.org>
date Mon, 20 May 2019 22:15:06 +0200
parents 1302bc0b80db
children f38fcbf343ce
comparison
equal deleted inserted replaced
16719:27f2a2799604 16720:9c90cf08cfa8
816 " The 'errorformat' setting is different on non-Unix systems. 816 " The 'errorformat' setting is different on non-Unix systems.
817 " This test works only on Unix-like systems. 817 " This test works only on Unix-like systems.
818 return 818 return
819 endif 819 endif
820 820
821 let l = [ 821 let l =<< trim [DATA]
822 \ '"Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.', 822 "Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.
823 \ '"Xtestfile", line 6 col 19; this is an error', 823 "Xtestfile", line 6 col 19; this is an error
824 \ 'gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c', 824 gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c
825 \ 'Xtestfile:9: parse error before `asd''', 825 Xtestfile:9: parse error before `asd'
826 \ 'make: *** [vim] Error 1', 826 make: *** [vim] Error 1
827 \ 'in file "Xtestfile" linenr 10: there is an error', 827 in file "Xtestfile" linenr 10: there is an error
828 \ '', 828
829 \ '2 returned', 829 2 returned
830 \ '"Xtestfile", line 11 col 1; this is an error', 830 "Xtestfile", line 11 col 1; this is an error
831 \ '"Xtestfile", line 12 col 2; this is another error', 831 "Xtestfile", line 12 col 2; this is another error
832 \ '"Xtestfile", line 14:10; this is an error in column 10', 832 "Xtestfile", line 14:10; this is an error in column 10
833 \ '=Xtestfile=, line 15:10; this is another error, but in vcol 10 this time', 833 =Xtestfile=, line 15:10; this is another error, but in vcol 10 this time
834 \ '"Xtestfile", linenr 16: yet another problem', 834 "Xtestfile", linenr 16: yet another problem
835 \ 'Error in "Xtestfile" at line 17:', 835 Error in "Xtestfile" at line 17:
836 \ 'x should be a dot', 836 x should be a dot
837 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17', 837 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
838 \ ' ^', 838 ^
839 \ 'Error in "Xtestfile" at line 18:', 839 Error in "Xtestfile" at line 18:
840 \ 'x should be a dot', 840 x should be a dot
841 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18', 841 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
842 \ '.............^', 842 .............^
843 \ 'Error in "Xtestfile" at line 19:', 843 Error in "Xtestfile" at line 19:
844 \ 'x should be a dot', 844 x should be a dot
845 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19', 845 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
846 \ '--------------^', 846 --------------^
847 \ 'Error in "Xtestfile" at line 20:', 847 Error in "Xtestfile" at line 20:
848 \ 'x should be a dot', 848 x should be a dot
849 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20', 849 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
850 \ ' ^', 850 ^
851 \ '', 851
852 \ 'Does anyone know what is the problem and how to correction it?', 852 Does anyone know what is the problem and how to correction it?
853 \ '"Xtestfile", line 21 col 9: What is the title of the quickfix window?', 853 "Xtestfile", line 21 col 9: What is the title of the quickfix window?
854 \ '"Xtestfile", line 22 col 9: What is the title of the quickfix window?' 854 "Xtestfile", line 22 col 9: What is the title of the quickfix window?
855 \ ] 855 [DATA]
856 856
857 call writefile(l, 'Xerrorfile1') 857 call writefile(l, 'Xerrorfile1')
858 call writefile(l[:-2], 'Xerrorfile2') 858 call writefile(l[:-2], 'Xerrorfile2')
859 859
860 let m = [ 860 let m =<< trim [DATA]
861 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2', 861 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2
862 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3', 862 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3
863 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4', 863 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4
864 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 5', 864 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 5
865 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 6', 865 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 6
866 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 7', 866 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 7
867 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 8', 867 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 8
868 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 9', 868 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 9
869 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 10', 869 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 10
870 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 11', 870 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 11
871 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 12', 871 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 12
872 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 13', 872 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 13
873 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 14', 873 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 14
874 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 15', 874 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 15
875 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 16', 875 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 16
876 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17', 876 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
877 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18', 877 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
878 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19', 878 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
879 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20', 879 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
880 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21', 880 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21
881 \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22' 881 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22
882 \ ] 882 [DATA]
883 call writefile(m, 'Xtestfile') 883 call writefile(m, 'Xtestfile')
884 884
885 let save_efm = &efm 885 let save_efm = &efm
886 set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m 886 set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m
887 set efm^=%AError\ in\ \"%f\"\ at\ line\ %l:,%Z%p^,%C%m 887 set efm^=%AError\ in\ \"%f\"\ at\ line\ %l:,%Z%p^,%C%m
1090 1090
1091 let l = split(execute('clist', ''), "\n") 1091 let l = split(execute('clist', ''), "\n")
1092 call assert_equal([' 1 Xtestfile:^\VLine search text\$: '], l) 1092 call assert_equal([' 1 Xtestfile:^\VLine search text\$: '], l)
1093 1093
1094 " Test for %P, %Q and %t format specifiers 1094 " Test for %P, %Q and %t format specifiers
1095 let lines=["[Xtestfile1]", 1095 let lines =<< trim [DATA]
1096 \ "(1,17) error: ';' missing", 1096 [Xtestfile1]
1097 \ "(21,2) warning: variable 'z' not defined", 1097 (1,17) error: ';' missing
1098 \ "(67,3) error: end of file found before string ended", 1098 (21,2) warning: variable 'z' not defined
1099 \ "--", 1099 (67,3) error: end of file found before string ended
1100 \ "", 1100 --
1101 \ "[Xtestfile2]", 1101
1102 \ "--", 1102 [Xtestfile2]
1103 \ "", 1103 --
1104 \ "[Xtestfile3]", 1104
1105 \ "NEW compiler v1.1", 1105 [Xtestfile3]
1106 \ "(2,2) warning: variable 'x' not defined", 1106 NEW compiler v1.1
1107 \ "(67,3) warning: 's' already defined", 1107 (2,2) warning: variable 'x' not defined
1108 \ "--" 1108 (67,3) warning: 's' already defined
1109 \] 1109 --
1110 [DATA]
1111
1110 set efm=%+P[%f]%r,(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%+Q--%r 1112 set efm=%+P[%f]%r,(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%+Q--%r
1111 " To exercise the push/pop file functionality in quickfix, the test files 1113 " To exercise the push/pop file functionality in quickfix, the test files
1112 " need to be created. 1114 " need to be created.
1113 call writefile(['Line1'], 'Xtestfile1') 1115 call writefile(['Line1'], 'Xtestfile1')
1114 call writefile(['Line2'], 'Xtestfile2') 1116 call writefile(['Line2'], 'Xtestfile2')
1126 call delete('Xtestfile1') 1128 call delete('Xtestfile1')
1127 call delete('Xtestfile2') 1129 call delete('Xtestfile2')
1128 call delete('Xtestfile3') 1130 call delete('Xtestfile3')
1129 1131
1130 " Tests for %E, %C and %Z format specifiers 1132 " Tests for %E, %C and %Z format specifiers
1131 let lines = ["Error 275", 1133 let lines =<< trim [DATA]
1132 \ "line 42", 1134 Error 275
1133 \ "column 3", 1135 line 42
1134 \ "' ' expected after '--'" 1136 column 3
1135 \] 1137 ' ' expected after '--'
1138 [DATA]
1139
1136 set efm=%EError\ %n,%Cline\ %l,%Ccolumn\ %c,%Z%m 1140 set efm=%EError\ %n,%Cline\ %l,%Ccolumn\ %c,%Z%m
1137 cgetexpr lines 1141 cgetexpr lines
1138 let l = getqflist() 1142 let l = getqflist()
1139 call assert_equal(275, l[0].nr) 1143 call assert_equal(275, l[0].nr)
1140 call assert_equal(42, l[0].lnum) 1144 call assert_equal(42, l[0].lnum)
1141 call assert_equal(3, l[0].col) 1145 call assert_equal(3, l[0].col)
1142 call assert_equal('E', l[0].type) 1146 call assert_equal('E', l[0].type)
1143 call assert_equal("\n' ' expected after '--'", l[0].text) 1147 call assert_equal("\n' ' expected after '--'", l[0].text)
1144 1148
1145 " Test for %> 1149 " Test for %>
1146 let lines = ["Error in line 147 of foo.c:", 1150 let lines =<< trim [DATA]
1147 \"unknown variable 'i'" 1151 Error in line 147 of foo.c:
1148 \] 1152 unknown variable 'i'
1153 [DATA]
1154
1149 set efm=unknown\ variable\ %m,%E%>Error\ in\ line\ %l\ of\ %f:,%Z%m 1155 set efm=unknown\ variable\ %m,%E%>Error\ in\ line\ %l\ of\ %f:,%Z%m
1150 cgetexpr lines 1156 cgetexpr lines
1151 let l = getqflist() 1157 let l = getqflist()
1152 call assert_equal(147, l[0].lnum) 1158 call assert_equal(147, l[0].lnum)
1153 call assert_equal('E', l[0].type) 1159 call assert_equal('E', l[0].type)
1154 call assert_equal("\nunknown variable 'i'", l[0].text) 1160 call assert_equal("\nunknown variable 'i'", l[0].text)
1155 1161
1156 " Test for %A, %C and other formats 1162 " Test for %A, %C and other formats
1157 let lines = [ 1163 let lines =<< trim [DATA]
1158 \"==============================================================", 1164 ==============================================================
1159 \"FAIL: testGetTypeIdCachesResult (dbfacadeTest.DjsDBFacadeTest)", 1165 FAIL: testGetTypeIdCachesResult (dbfacadeTest.DjsDBFacadeTest)
1160 \"--------------------------------------------------------------", 1166 --------------------------------------------------------------
1161 \"Traceback (most recent call last):", 1167 Traceback (most recent call last):
1162 \' File "unittests/dbfacadeTest.py", line 89, in testFoo', 1168 File "unittests/dbfacadeTest.py", line 89, in testFoo
1163 \" self.assertEquals(34, dtid)", 1169 self.assertEquals(34, dtid)
1164 \' File "/usr/lib/python2.2/unittest.py", line 286, in', 1170 File "/usr/lib/python2.2/unittest.py", line 286, in
1165 \" failUnlessEqual", 1171 failUnlessEqual
1166 \" raise self.failureException, \\", 1172 raise self.failureException, \\
1167 \"AssertionError: 34 != 33", 1173 AssertionError: 34 != 33
1168 \"", 1174
1169 \"--------------------------------------------------------------", 1175 --------------------------------------------------------------
1170 \"Ran 27 tests in 0.063s" 1176 Ran 27 tests in 0.063s
1171 \] 1177 [DATA]
1178
1172 set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m 1179 set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
1173 cgetexpr lines 1180 cgetexpr lines
1174 let l = getqflist() 1181 let l = getqflist()
1175 call assert_equal(8, len(l)) 1182 call assert_equal(8, len(l))
1176 call assert_equal(89, l[4].lnum) 1183 call assert_equal(89, l[4].lnum)