Update 2024-12-15 14:45 OpenBSD/amd64-t14
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
[run]
|
||||
plugins = covimerage
|
||||
data_file = .coverage_covimerage
|
||||
2
.vim/pack/plugins/start/vim-conflict-marker/test/.gitignore
vendored
Normal file
2
.vim/pack/plugins/start/vim-conflict-marker/test/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/profile.txt
|
||||
/.coverage_covimerage
|
||||
18
.vim/pack/plugins/start/vim-conflict-marker/test/.themisrc
Normal file
18
.vim/pack/plugins/start/vim-conflict-marker/test/.themisrc
Normal file
@@ -0,0 +1,18 @@
|
||||
let g:repo_root = fnamemodify(expand('<sfile>'), ':h:h')
|
||||
|
||||
call themis#option('exclude', g:repo_root . '/test/profile.txt')
|
||||
call themis#option('exclude', g:repo_root . '/test/README.md')
|
||||
call themis#option('exclude', g:repo_root . '/test/.coveragerc')
|
||||
call themis#option('exclude', g:repo_root . '/test/.gitignore')
|
||||
call themis#helper('command').with(themis#helper('assert'))
|
||||
|
||||
if $PROFILE_LOG !=# ''
|
||||
execute 'profile' 'start' $PROFILE_LOG
|
||||
execute 'profile!' 'file' g:repo_root . '/autoload/conflict_marker.vim'
|
||||
execute 'profile!' 'file' g:repo_root . '/autoload/conflict_marker/detect.vim'
|
||||
execute 'profile!' 'file' g:repo_root . '/plugin/conflict_marker.vim'
|
||||
endif
|
||||
|
||||
call themis#option('runtimepath', expand(g:repo_root))
|
||||
|
||||
syntax on
|
||||
59
.vim/pack/plugins/start/vim-conflict-marker/test/README.md
Normal file
59
.vim/pack/plugins/start/vim-conflict-marker/test/README.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# Prerequisites
|
||||
|
||||
[Python](https://www.python.org/) is requried to take code coverage.
|
||||
|
||||
# How to run unit tests
|
||||
|
||||
This repository uses [vim-themis](https://github.com/thinca/vim-themis) to run unit tests.
|
||||
|
||||
Clone vim-themis in your local
|
||||
|
||||
```sh
|
||||
git clone https://github.com/thinca/vim-themis.git
|
||||
```
|
||||
|
||||
Run `vim-flavor` command via `bundle exec`:
|
||||
Execute `themis` command to run all unit tests
|
||||
|
||||
```sh
|
||||
cd /path/to/conflict-marker.vim/test
|
||||
/path/to/vim-themis/bin/themis *.vimspec
|
||||
```
|
||||
|
||||
It runs all unit tests and outputs the results in terminal.
|
||||
|
||||
# How to take code coverage
|
||||
|
||||
This repository uses [covimerage](https://github.com/Vimjas/covimerage) to take code coverage.
|
||||
|
||||
Install covimerage in `./venv` directory.
|
||||
|
||||
```sh
|
||||
python -m venv venv
|
||||
source ./venv/bin/activate
|
||||
pip install covimerage
|
||||
covimerage --version
|
||||
```
|
||||
|
||||
Run unit tests enabling profiling by setting `PROFILE_LOG` environment variable.
|
||||
|
||||
```sh
|
||||
cd /path/to/conflict-marker.vim/test
|
||||
PROFILE_LOG=profile.txt /path/to/vim-themis/bin/themis *.vimspec
|
||||
```
|
||||
|
||||
It saves profiling results to `profile.txt`. Extract code coverage data from it using `covimerage`.
|
||||
|
||||
```sh
|
||||
covimerage write_coverage profile.txt
|
||||
```
|
||||
|
||||
Output code coverage results with `coverage` command which is part of standard Python toolchain.
|
||||
|
||||
```sh
|
||||
# Show code coverage results in terminal
|
||||
coverage report
|
||||
|
||||
# Output coverage data to XML file
|
||||
coverage xml
|
||||
```
|
||||
@@ -0,0 +1,76 @@
|
||||
Describe Default settings
|
||||
It provides variables to customize
|
||||
Assert Exists('g:loaded_conflict_marker')
|
||||
Assert Equals(g:conflict_marker_highlight_group, 'Error')
|
||||
Assert Equals(g:conflict_marker_begin, '^<<<<<<<\+')
|
||||
Assert Equals(g:conflict_marker_common_ancestors, '^|||||||\+')
|
||||
Assert Equals(g:conflict_marker_separator, '^=======\+$')
|
||||
Assert Equals(g:conflict_marker_end, '^>>>>>>>\+')
|
||||
Assert Equals(g:conflict_marker_enable_mappings, 1)
|
||||
Assert Equals(g:conflict_marker_enable_hooks, 1)
|
||||
Assert Equals(g:conflict_marker_enable_highlight, 1)
|
||||
Assert Equals(g:conflict_marker_enable_matchit, 1)
|
||||
End
|
||||
|
||||
It provides commands
|
||||
Assert Exists(':ConflictMarkerThemselves')
|
||||
Assert Exists(':ConflictMarkerOurselves')
|
||||
Assert Exists(':ConflictMarkerBoth')
|
||||
Assert Exists(':ConflictMarkerNone')
|
||||
Assert Exists(':ConflictMarkerNextHunk')
|
||||
Assert Exists(':ConflictMarkerPrevHunk')
|
||||
End
|
||||
|
||||
It provides <Plug> mappings
|
||||
Assert NotEmpty(mapcheck('<Plug>(conflict-marker-themselves)', 'n'))
|
||||
Assert NotEmpty(mapcheck('<Plug>(conflict-marker-ourselves)', 'n'))
|
||||
Assert NotEmpty(mapcheck('<Plug>(conflict-marker-both)', 'n'))
|
||||
Assert NotEmpty(mapcheck('<Plug>(conflict-marker-both-rev)', 'n'))
|
||||
Assert NotEmpty(mapcheck('<Plug>(conflict-marker-none)', 'n'))
|
||||
Assert NotEmpty(mapcheck('<Plug>(conflict-marker-next-hunk)', 'n'))
|
||||
Assert NotEmpty(mapcheck('<Plug>(conflict-marker-prev-hunk)', 'n'))
|
||||
End
|
||||
|
||||
Context with text buffer
|
||||
Before
|
||||
new
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It provides user mappings unless g:conflict_marker_enable_mappings is 0
|
||||
let lines = [
|
||||
\ "<<<<<<< HEAD",
|
||||
\ "ourselves1",
|
||||
\ "=======",
|
||||
\ "themselves1",
|
||||
\ ">>>>>>> 8374eabc232",
|
||||
\ ]
|
||||
|
||||
for l in range(1, len(lines))
|
||||
call setline(l, lines[l-1])
|
||||
endfor
|
||||
doautocmd BufReadPost
|
||||
|
||||
Assert NotEmpty(mapcheck(']x', 'n'))
|
||||
Assert NotEmpty(mapcheck('[x', 'n'))
|
||||
Assert NotEmpty(mapcheck('ct', 'n'))
|
||||
Assert NotEmpty(mapcheck('co', 'n'))
|
||||
Assert NotEmpty(mapcheck('cn', 'n'))
|
||||
Assert NotEmpty(mapcheck('cb', 'n'))
|
||||
Assert NotEmpty(mapcheck('cB', 'n'))
|
||||
End
|
||||
|
||||
It does not provide user mappings until hunk is found
|
||||
Assert Falsy(mapcheck(']x', 'n'))
|
||||
Assert Falsy(mapcheck('[x', 'n'))
|
||||
Assert Falsy(mapcheck('ct', 'n'))
|
||||
Assert Falsy(mapcheck('co', 'n'))
|
||||
Assert Falsy(mapcheck('cn', 'n'))
|
||||
Assert Falsy(mapcheck('cb', 'n'))
|
||||
Assert Falsy(mapcheck('cB', 'n'))
|
||||
End
|
||||
End
|
||||
End
|
||||
@@ -0,0 +1,53 @@
|
||||
let s:lines = [
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves1',
|
||||
\ '=======',
|
||||
\ 'themselves1',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ ]
|
||||
|
||||
lockvar s:lines
|
||||
|
||||
Describe g:conflict_marker_hooks
|
||||
Before
|
||||
new
|
||||
for l in range(1, len(s:lines))
|
||||
call setline(l, s:lines[l-1])
|
||||
endfor
|
||||
End
|
||||
|
||||
After
|
||||
unlet! g:conflict_marker_hooks
|
||||
close!
|
||||
End
|
||||
|
||||
It does nothing if does not have on_detected hook
|
||||
let g:conflict_marker_hooks = {}
|
||||
" Check exception is not thrown
|
||||
doautocmd BufReadPost
|
||||
End
|
||||
|
||||
It executes on_detected hook specified by string
|
||||
let g:test_hooked = 0
|
||||
function! TestHook()
|
||||
let g:test_hooked = 1
|
||||
endfunction
|
||||
let g:conflict_marker_hooks = {'on_detected' : 'TestHook'}
|
||||
|
||||
doautocmd BufReadPost
|
||||
Assert g:test_hooked
|
||||
unlet g:test_hooked
|
||||
End
|
||||
|
||||
It executes on_detected hook specified by funcref
|
||||
let g:test_hooked = 0
|
||||
let g:conflict_marker_hooks = {}
|
||||
function! g:conflict_marker_hooks.on_detected()
|
||||
let g:test_hooked = 1
|
||||
endfunction
|
||||
|
||||
doautocmd BufReadPost
|
||||
Assert g:test_hooked
|
||||
unlet g:test_hooked
|
||||
End
|
||||
End
|
||||
@@ -0,0 +1,279 @@
|
||||
let s:lines = [
|
||||
\ '',
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves1',
|
||||
\ '=======',
|
||||
\ 'themselves1',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ '',
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves2',
|
||||
\ '=======',
|
||||
\ 'themselves2',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ '',
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves3',
|
||||
\ '=======',
|
||||
\ 'themselves3',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ ]
|
||||
|
||||
lockvar s:lines
|
||||
|
||||
let s:lines_diff3 = [
|
||||
\ '',
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves1',
|
||||
\ '|||||||',
|
||||
\ 'base1',
|
||||
\ '=======',
|
||||
\ 'themselves1',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ '',
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves2',
|
||||
\ '|||||||',
|
||||
\ 'base2',
|
||||
\ '=======',
|
||||
\ 'themselves2',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ '',
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves3',
|
||||
\ '|||||||',
|
||||
\ 'base3',
|
||||
\ '=======',
|
||||
\ 'themselves3',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ ]
|
||||
|
||||
lockvar s:lines_diff3
|
||||
|
||||
let s:lines_long_markers = [
|
||||
\ '',
|
||||
\ '<<<<<<<<<<<<<< HEAD',
|
||||
\ 'ourselves1',
|
||||
\ '==============',
|
||||
\ 'themselves1',
|
||||
\ '>>>>>>>>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ '',
|
||||
\ '<<<<<<<< HEAD',
|
||||
\ 'ourselves2',
|
||||
\ '========',
|
||||
\ 'themselves2',
|
||||
\ '>>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ ]
|
||||
|
||||
lockvar s:lines_long_markers
|
||||
|
||||
function! s:setup(lines) abort
|
||||
new
|
||||
for l in range(1, len(a:lines))
|
||||
call setline(l, a:lines[l-1])
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
Describe :ConflictMarkerNextHunk
|
||||
Context applying to diff2
|
||||
Before
|
||||
call s:setup(s:lines)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It moves cursor to next hunk
|
||||
normal! gg
|
||||
for l in [2, 9, 16]
|
||||
ConflictMarkerNextHunk
|
||||
Assert Equals(line('.'), l)
|
||||
endfor
|
||||
End
|
||||
|
||||
It doesn't move cursor at the end of buffer
|
||||
normal! G
|
||||
ConflictMarkerNextHunk
|
||||
Assert Equals(line('.'), line('$'))
|
||||
End
|
||||
|
||||
It doesn't accept at cursor
|
||||
normal! ggj
|
||||
ConflictMarkerNextHunk
|
||||
Assert Equals(line('.'), 9)
|
||||
End
|
||||
|
||||
It accepts position at cursor with bang
|
||||
normal! ggj
|
||||
ConflictMarkerNextHunk!
|
||||
Assert Equals(line('.'), 2)
|
||||
End
|
||||
End
|
||||
|
||||
Context applying to diff3
|
||||
Before
|
||||
call s:setup(s:lines_diff3)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It moves cursor to next hunk
|
||||
normal! gg
|
||||
for l in [2, 11, 20]
|
||||
ConflictMarkerNextHunk
|
||||
Assert Equals(line('.'), l)
|
||||
endfor
|
||||
End
|
||||
|
||||
It doesn't move cursor at the end of buffer
|
||||
normal! G
|
||||
ConflictMarkerNextHunk
|
||||
Assert Equals(line('.'), line('$'))
|
||||
End
|
||||
|
||||
It doesn't accept at cursor
|
||||
normal! ggj
|
||||
ConflictMarkerNextHunk
|
||||
Assert Equals(line('.'), 11)
|
||||
End
|
||||
|
||||
It accepts position at cursor with bang
|
||||
normal! ggj
|
||||
ConflictMarkerNextHunk!
|
||||
Assert Equals(line('.'), 2)
|
||||
End
|
||||
End
|
||||
|
||||
Context markers with more than 7 characters
|
||||
Before
|
||||
call s:setup(s:lines_long_markers)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It moves cursor to next hunk
|
||||
normal! gg
|
||||
for l in [2, 9]
|
||||
ConflictMarkerNextHunk
|
||||
Assert Equals(line('.'), l)
|
||||
endfor
|
||||
End
|
||||
|
||||
It accepts position at cursor with bang
|
||||
normal! ggj
|
||||
ConflictMarkerNextHunk!
|
||||
Assert Equals(line('.'), 2)
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
Describe :ConflictMarkerPrevHunk
|
||||
Context applying to diff2
|
||||
Before
|
||||
call s:setup(s:lines)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It moves cursor to previous hunk
|
||||
normal! G
|
||||
for l in [16, 9, 2]
|
||||
ConflictMarkerPrevHunk
|
||||
Assert Equals(line('.'), l)
|
||||
endfor
|
||||
End
|
||||
|
||||
It doesn't move cursor at the top of buffer
|
||||
normal! gg
|
||||
ConflictMarkerPrevHunk
|
||||
Assert Equals(line('.'), 1)
|
||||
End
|
||||
|
||||
It doesn't accept at cursor
|
||||
normal! Gk
|
||||
ConflictMarkerPrevHunk
|
||||
Assert Equals(line('.'), 9)
|
||||
End
|
||||
|
||||
It accepts position at cursor with bang
|
||||
normal! Gk
|
||||
ConflictMarkerPrevHunk!
|
||||
Assert Equals(line('.'), 16)
|
||||
End
|
||||
End
|
||||
|
||||
Context applying to diff3
|
||||
Before
|
||||
call s:setup(s:lines_diff3)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It moves cursor to previous hunk
|
||||
normal! G
|
||||
for l in [20, 11, 2]
|
||||
ConflictMarkerPrevHunk
|
||||
Assert Equals(line('.'), l)
|
||||
endfor
|
||||
End
|
||||
|
||||
It doesn't move cursor at the top of buffer
|
||||
normal! gg
|
||||
ConflictMarkerPrevHunk
|
||||
Assert Equals(line('.'), 1)
|
||||
End
|
||||
|
||||
It doesn't accept at cursor
|
||||
normal! Gk
|
||||
ConflictMarkerPrevHunk
|
||||
Assert Equals(line('.'), 11)
|
||||
End
|
||||
|
||||
It accepts position at cursor with bang
|
||||
normal! Gk
|
||||
ConflictMarkerPrevHunk!
|
||||
Assert Equals(line('.'), 20)
|
||||
End
|
||||
End
|
||||
|
||||
Context markers with more than 7 characters
|
||||
Before
|
||||
call s:setup(s:lines_long_markers)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It moves cursor to previous hunk
|
||||
normal! G
|
||||
for l in [9, 2]
|
||||
ConflictMarkerPrevHunk
|
||||
Assert Equals(line('.'), l)
|
||||
endfor
|
||||
End
|
||||
|
||||
It accepts position at cursor with bang
|
||||
normal! Gk
|
||||
ConflictMarkerPrevHunk!
|
||||
Assert Equals(line('.'), 9)
|
||||
End
|
||||
End
|
||||
End
|
||||
@@ -0,0 +1,78 @@
|
||||
let s:lines = [
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves1',
|
||||
\ '=======',
|
||||
\ 'themselves1',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ ]
|
||||
|
||||
lockvar s:lines
|
||||
|
||||
let s:lines_diff3 = [
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves1',
|
||||
\ '||||||| merged common ancestors',
|
||||
\ 'common ancestors1',
|
||||
\ '=======',
|
||||
\ 'themselves1',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ ]
|
||||
|
||||
lockvar s:lines_diff3
|
||||
|
||||
Describe matchit
|
||||
Before
|
||||
new
|
||||
for l in range(1, len(s:lines))
|
||||
call setline(l, s:lines[l-1])
|
||||
endfor
|
||||
doautocmd BufReadPost
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It defines b:match_words
|
||||
Assert Exists('b:match_words')
|
||||
Assert Equals(b:match_words, '^<<<<<<<\+:^|||||||\+:^=======\+$:^>>>>>>>\+')
|
||||
End
|
||||
|
||||
It jumps jumps between delimiters in a conflict marker
|
||||
normal! gg
|
||||
normal %
|
||||
Assert Equals(line('.'), 3)
|
||||
normal %
|
||||
Assert Equals(line('.'), 5)
|
||||
normal %
|
||||
Assert Equals(line('.'), 1)
|
||||
normal %
|
||||
Assert Equals(line('.'), 3)
|
||||
End
|
||||
End
|
||||
|
||||
Describe matchit with diff3
|
||||
Before
|
||||
new
|
||||
for l in range(1, len(s:lines_diff3))
|
||||
call setline(l, s:lines_diff3[l-1])
|
||||
endfor
|
||||
doautocmd BufReadPost
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It jumps between delimiters in a conflict marker
|
||||
normal! gg
|
||||
normal %
|
||||
Assert Equals(line('.'), 3)
|
||||
normal %
|
||||
Assert Equals(line('.'), 5)
|
||||
normal %
|
||||
Assert Equals(line('.'), 7)
|
||||
normal %
|
||||
Assert Equals(line('.'), 1)
|
||||
End
|
||||
End
|
||||
@@ -0,0 +1,203 @@
|
||||
let g:lines_diff2 = [
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves',
|
||||
\ '=======',
|
||||
\ 'themselves',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ ]
|
||||
|
||||
lockvar g:lines_diff2
|
||||
|
||||
let g:lines_diff3 = [
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves',
|
||||
\ '||||||| base',
|
||||
\ 'ancestors',
|
||||
\ '=======',
|
||||
\ 'themselves',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ ]
|
||||
|
||||
lockvar g:lines_diff3
|
||||
|
||||
function! s:load(lines)
|
||||
new
|
||||
for l in range(1, len(a:lines))
|
||||
call setline(l, a:lines[l-1])
|
||||
endfor
|
||||
doautocmd BufReadPost
|
||||
endfunction
|
||||
|
||||
Describe :ConflictMarkerThemselves
|
||||
Context applying to diff2
|
||||
Before
|
||||
call s:load(g:lines_diff2)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It resolves a conflict with themselves strategy
|
||||
ConflictMarkerThemselves
|
||||
Assert Equals(getline(1, '$'), ['themselves', ''])
|
||||
End
|
||||
|
||||
It makes no change out of marker
|
||||
normal! G
|
||||
ConflictMarkerThemselves
|
||||
Assert Equals(getline(1, '$'), g:lines_diff2)
|
||||
End
|
||||
End
|
||||
|
||||
Context applying to diff3
|
||||
Before
|
||||
call s:load(g:lines_diff3)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It resolves a conflict with themselves strategy
|
||||
ConflictMarkerThemselves
|
||||
Assert Equals(getline(1, '$'), ['themselves', ''])
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
Describe :ConflictMarkerOurselves
|
||||
Context applying to diff2
|
||||
Before
|
||||
call s:load(g:lines_diff2)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It resolves a conflict with ourselves strategy
|
||||
ConflictMarkerOurselves
|
||||
Assert Equals(getline(1, '$'), ['ourselves', ''])
|
||||
End
|
||||
|
||||
It makes no change out of marker
|
||||
normal! G
|
||||
ConflictMarkerOurselves
|
||||
Assert Equals(getline(1, '$'), g:lines_diff2)
|
||||
End
|
||||
End
|
||||
|
||||
Context applying to diff3
|
||||
Before
|
||||
call s:load(g:lines_diff3)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It resolves a conflict with ourselves strategy
|
||||
ConflictMarkerOurselves
|
||||
Assert Equals(getline(1, '$'), ['ourselves', ''])
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
Describe :ConflictMarkerNone
|
||||
Context applying to diff2
|
||||
Before
|
||||
call s:load(g:lines_diff2)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It resolves a conflict by removing both modifications
|
||||
ConflictMarkerNone
|
||||
Assert Equals(getline(1, '$'), [''])
|
||||
End
|
||||
|
||||
It makes no change out of marker
|
||||
normal! G
|
||||
ConflictMarkerNone
|
||||
Assert Equals(getline(1, '$'), g:lines_diff2)
|
||||
End
|
||||
End
|
||||
|
||||
Context applying to diff3
|
||||
Before
|
||||
call s:load(g:lines_diff3)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It resolves a conflict by removing both modifications
|
||||
ConflictMarkerNone
|
||||
Assert Equals(getline(1, '$'), [''])
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
Describe :ConflictMarkerBoth
|
||||
Context applying to diff2
|
||||
Before
|
||||
call s:load(g:lines_diff2)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It resolves a conflict by keeping theirs and ours
|
||||
ConflictMarkerBoth
|
||||
Assert Equals(getline(1, '$'), ['ourselves', 'themselves', ''])
|
||||
End
|
||||
|
||||
It makes no change out of marker
|
||||
normal! G
|
||||
ConflictMarkerBoth
|
||||
Assert Equals(getline(1, '$'), g:lines_diff2)
|
||||
End
|
||||
|
||||
Context with bang
|
||||
It resolves a conflict by keeping theirs and ours in reverse order
|
||||
ConflictMarkerBoth!
|
||||
Assert Equals(getline(1, '$'), ['themselves', 'ourselves', ''])
|
||||
End
|
||||
|
||||
It makes no change out of marker
|
||||
normal! G
|
||||
ConflictMarkerBoth!
|
||||
Assert Equals(getline(1, '$'), g:lines_diff2)
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
Context applying to diff3
|
||||
Before
|
||||
call s:load(g:lines_diff3)
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It resolves a conflict by keeping theirs and ours
|
||||
ConflictMarkerBoth
|
||||
Assert Equals(getline(1, '$'), ['ourselves', 'themselves', ''])
|
||||
End
|
||||
|
||||
Context with bang
|
||||
It resolves a conflict by keeping theirs and ours in reverse order with bang
|
||||
ConflictMarkerBoth!
|
||||
Assert Equals(getline(1, '$'), ['themselves', 'ourselves', ''])
|
||||
End
|
||||
End
|
||||
End
|
||||
End
|
||||
@@ -0,0 +1,82 @@
|
||||
let s:lines = [
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves1',
|
||||
\ '=======',
|
||||
\ 'themselves1',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ '',
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves2',
|
||||
\ '=======',
|
||||
\ 'themselves2',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ '',
|
||||
\ '',
|
||||
\ '<<<<<<< HEAD',
|
||||
\ 'ourselves3',
|
||||
\ '=======',
|
||||
\ 'themselves3',
|
||||
\ '>>>>>>> 8374eabc232',
|
||||
\ ]
|
||||
lockvar s:lines
|
||||
|
||||
function! GetHighlight(line, col)
|
||||
return synIDattr(synID(a:line,a:col,1),'name')
|
||||
endfunction
|
||||
|
||||
Describe Conflict marker
|
||||
Before
|
||||
new
|
||||
for l in range(1, len(s:lines))
|
||||
call setline(l, s:lines[l-1])
|
||||
endfor
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
End
|
||||
|
||||
It is highlighted
|
||||
doautocmd BufReadPost
|
||||
for l in [1, 8, 15]
|
||||
Assert Equals(GetHighlight(l, 1), 'ConflictMarkerBegin')
|
||||
Assert Equals(GetHighlight(l+1, 2), 'ConflictMarkerOurs')
|
||||
Assert Equals(GetHighlight(l+2, 3), 'ConflictMarkerSeparator')
|
||||
Assert Equals(GetHighlight(l+3, 4), 'ConflictMarkerTheirs')
|
||||
Assert Equals(GetHighlight(l+4, 5), 'ConflictMarkerEnd')
|
||||
endfor
|
||||
End
|
||||
|
||||
It is not highlighted if no marker is detected at BufReadPost
|
||||
for l in [1, 8, 15]
|
||||
Assert NotEquals(GetHighlight(l, 1), 'ConflictMarkerBegin')
|
||||
Assert NotEquals(GetHighlight(l+1, 2), 'ConflictMarkerOurs')
|
||||
Assert NotEquals(GetHighlight(l+2, 3), 'ConflictMarkerSeparator')
|
||||
Assert NotEquals(GetHighlight(l+3, 4), 'ConflictMarkerTheirs')
|
||||
Assert NotEquals(GetHighlight(l+4, 5), 'ConflictMarkerEnd')
|
||||
endfor
|
||||
End
|
||||
|
||||
Describe g:conflict_marker_enable_detect
|
||||
Before
|
||||
let saved = g:conflict_marker_enable_detect
|
||||
End
|
||||
|
||||
After
|
||||
let g:conflict_marker_enable_detect = saved
|
||||
End
|
||||
|
||||
It disables detection when 0 is set (#18)
|
||||
let g:conflict_marker_enable_detect = 0
|
||||
doautocmd BufReadPost
|
||||
for l in [1, 8, 15]
|
||||
Assert NotEquals(GetHighlight(l, 1), 'ConflictMarkerBegin')
|
||||
Assert NotEquals(GetHighlight(l+1, 2), 'ConflictMarkerOurs')
|
||||
Assert NotEquals(GetHighlight(l+2, 3), 'ConflictMarkerSeparator')
|
||||
Assert NotEquals(GetHighlight(l+3, 4), 'ConflictMarkerTheirs')
|
||||
Assert NotEquals(GetHighlight(l+4, 5), 'ConflictMarkerEnd')
|
||||
endfor
|
||||
End
|
||||
End
|
||||
End
|
||||
Reference in New Issue
Block a user