Mercurial > vim
comparison src/testdir/test_diffmode.vim @ 24661:f51ea1b6d512 v8.2.2869
patch 8.2.2869: using unified diff is not tested
Commit: https://github.com/vim/vim/commit/485b62710004431a16feb4eb861365d082304a08
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 18 19:19:03 2021 +0200
patch 8.2.2869: using unified diff is not tested
Problem: Using unified diff is not tested.
Solution: Test all cases also with unified diff. (issue https://github.com/vim/vim/issues/8197)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 18 May 2021 19:30:03 +0200 |
parents | e313b6ee2d9c |
children | 05c199ea8295 |
comparison
equal
deleted
inserted
replaced
24660:36e76c23f8a5 | 24661:f51ea1b6d512 |
---|---|
622 | 622 |
623 func Test_diffexpr() | 623 func Test_diffexpr() |
624 CheckExecutable diff | 624 CheckExecutable diff |
625 | 625 |
626 func DiffExpr() | 626 func DiffExpr() |
627 " Prepent some text to check diff type detection | 627 " Prepend some text to check diff type detection |
628 call writefile(['warning', ' message'], v:fname_out) | 628 call writefile(['warning', ' message'], v:fname_out) |
629 silent exe '!diff ' . v:fname_in . ' ' . v:fname_new . '>>' . v:fname_out | 629 silent exe '!diff ' . v:fname_in . ' ' . v:fname_new . '>>' . v:fname_out |
630 endfunc | 630 endfunc |
631 set diffexpr=DiffExpr() | 631 set diffexpr=DiffExpr() |
632 set diffopt=foldcolumn:0 | 632 set diffopt=foldcolumn:0 |
787 func VerifyBoth(buf, dumpfile, extra) | 787 func VerifyBoth(buf, dumpfile, extra) |
788 " trailing : for leaving the cursor on the command line | 788 " trailing : for leaving the cursor on the command line |
789 for cmd in [":set diffopt=filler" . a:extra . "\<CR>:", ":set diffopt+=internal\<CR>:"] | 789 for cmd in [":set diffopt=filler" . a:extra . "\<CR>:", ":set diffopt+=internal\<CR>:"] |
790 call term_sendkeys(a:buf, cmd) | 790 call term_sendkeys(a:buf, cmd) |
791 if VerifyScreenDump(a:buf, a:dumpfile, {}, cmd =~ 'internal' ? 'internal' : 'external') | 791 if VerifyScreenDump(a:buf, a:dumpfile, {}, cmd =~ 'internal' ? 'internal' : 'external') |
792 break " don't let the next iteration overwrite the "failed" file. | 792 " don't let the next iteration overwrite the "failed" file. |
793 return | |
793 endif | 794 endif |
794 endfor | 795 endfor |
796 | |
797 " also test unified diff | |
798 call term_sendkeys(a:buf, ":call SetupUnified()\<CR>:") | |
799 call VerifyScreenDump(a:buf, a:dumpfile, {}, 'unified') | |
800 call term_sendkeys(a:buf, ":call StopUnified()\<CR>:") | |
795 endfunc | 801 endfunc |
796 | 802 |
797 " Verify a screendump with the internal diff only. | 803 " Verify a screendump with the internal diff only. |
798 func VerifyInternal(buf, dumpfile, extra) | 804 func VerifyInternal(buf, dumpfile, extra) |
799 call term_sendkeys(a:buf, ":diffupdate!\<CR>") | 805 call term_sendkeys(a:buf, ":diffupdate!\<CR>") |
805 | 811 |
806 func Test_diff_screen() | 812 func Test_diff_screen() |
807 CheckScreendump | 813 CheckScreendump |
808 CheckFeature menu | 814 CheckFeature menu |
809 | 815 |
816 let lines =<< trim END | |
817 func UnifiedDiffExpr() | |
818 " Prepend some text to check diff type detection | |
819 call writefile(['warning', ' message'], v:fname_out) | |
820 silent exe '!diff -u ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out | |
821 endfunc | |
822 func SetupUnified() | |
823 set diffexpr=UnifiedDiffExpr() | |
824 endfunc | |
825 func StopUnified() | |
826 set diffexpr= | |
827 endfunc | |
828 END | |
829 call writefile(lines, 'XdiffSetup') | |
830 | |
810 " clean up already existing swap files, just in case | 831 " clean up already existing swap files, just in case |
811 call delete('.Xfile1.swp') | 832 call delete('.Xfile1.swp') |
812 call delete('.Xfile2.swp') | 833 call delete('.Xfile2.swp') |
813 | 834 |
814 " Test 1: Add a line in beginning of file 2 | 835 " Test 1: Add a line in beginning of file 2 |
815 call WriteDiffFiles(0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) | 836 call WriteDiffFiles(0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) |
816 let buf = RunVimInTerminal('-d Xfile1 Xfile2', {}) | 837 let buf = RunVimInTerminal('-d -S XdiffSetup Xfile1 Xfile2', {}) |
817 " Set autoread mode, so that Vim won't complain once we re-write the test | 838 " Set autoread mode, so that Vim won't complain once we re-write the test |
818 " files | 839 " files |
819 call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w") | 840 call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w") |
820 | 841 |
821 call VerifyBoth(buf, 'Test_diff_01', '') | 842 call VerifyBoth(buf, 'Test_diff_01', '') |
931 | 952 |
932 " clean up | 953 " clean up |
933 call StopVimInTerminal(buf) | 954 call StopVimInTerminal(buf) |
934 call delete('Xfile1') | 955 call delete('Xfile1') |
935 call delete('Xfile2') | 956 call delete('Xfile2') |
957 call delete('XdiffSetup') | |
936 endfunc | 958 endfunc |
937 | 959 |
938 func Test_diff_with_cursorline() | 960 func Test_diff_with_cursorline() |
939 CheckScreendump | 961 CheckScreendump |
940 | 962 |