mirror of
https://github.com/lewis6991/gitsigns.nvim
synced 2025-02-16 04:06:50 +00:00
test: reduce delays
This commit is contained in:
parent
e2ca739be7
commit
88be2b44d6
@ -19,6 +19,7 @@ local edit = helpers.edit
|
||||
local cleanup = helpers.cleanup
|
||||
local test_file = helpers.test_file
|
||||
local git = helpers.git
|
||||
local gitm = helpers.gitm
|
||||
local scratch = helpers.scratch
|
||||
local newfile = helpers.newfile
|
||||
local match_dag = helpers.match_dag
|
||||
@ -254,8 +255,11 @@ describe('gitsigns', function()
|
||||
else
|
||||
system("printf 'This\nis\na\nwindows\nfile\n' > "..newfile)
|
||||
end
|
||||
git{'add', newfile}
|
||||
git{"commit", "-m", "commit on main"}
|
||||
|
||||
gitm {
|
||||
{'add', newfile},
|
||||
{"commit", "-m", "commit on main"}
|
||||
}
|
||||
|
||||
edit(newfile)
|
||||
feed('gg')
|
||||
@ -337,8 +341,10 @@ describe('gitsigns', function()
|
||||
feed('oEDIT<esc>')
|
||||
command('write')
|
||||
|
||||
git{'add', test_file}
|
||||
git{"commit", "-m", "commit on main"}
|
||||
gitm {
|
||||
{'add', test_file},
|
||||
{"commit", "-m", "commit on main"}
|
||||
}
|
||||
|
||||
-- Don't setup gitsigns until the repo has two commits
|
||||
setup_gitsigns(config)
|
||||
@ -552,21 +558,25 @@ describe('gitsigns', function()
|
||||
check{ status = {head='master', added=0, changed=1, removed=0} }
|
||||
command("write")
|
||||
command("bdelete")
|
||||
git{'add', test_file}
|
||||
git{"commit", "-m", "commit on main"}
|
||||
gitm{
|
||||
{'add', test_file},
|
||||
{"commit", "-m", "commit on main"},
|
||||
|
||||
-- Create a branch, remove last commit, edit file again
|
||||
git{'checkout', '-B', 'abranch'}
|
||||
git{'reset', '--hard', 'HEAD~1'}
|
||||
-- Create a branch, remove last commit, edit file again
|
||||
{'checkout', '-B', 'abranch'},
|
||||
{'reset', '--hard', 'HEAD~1'}
|
||||
}
|
||||
edit(test_file)
|
||||
check{ status = {head='abranch', added=0, changed=0, removed=0} }
|
||||
feed('idiff')
|
||||
check{ status = {head='abranch', added=0, changed=1, removed=0} }
|
||||
command("write")
|
||||
command("bdelete")
|
||||
git{'add', test_file}
|
||||
git{"commit", "-m", "commit on branch"}
|
||||
git{"rebase", "master"}
|
||||
gitm{
|
||||
{'add', test_file},
|
||||
{"commit", "-m", "commit on branch"},
|
||||
{"rebase", "master"}
|
||||
}
|
||||
|
||||
-- test_file should have a conflict
|
||||
edit(test_file)
|
||||
@ -678,8 +688,11 @@ describe('gitsigns', function()
|
||||
local uni_filename = scratch..'/föobær'
|
||||
|
||||
write_to_file(uni_filename, {'Lorem ipsum'})
|
||||
git{"add", uni_filename}
|
||||
git{"commit", "-m", "another commit"}
|
||||
|
||||
gitm{
|
||||
{"add", uni_filename},
|
||||
{"commit", "-m", "another commit"}
|
||||
}
|
||||
|
||||
edit(uni_filename)
|
||||
|
||||
|
@ -42,10 +42,23 @@ local test_file_text = {
|
||||
'content', 'doesn\'t', 'matter,', 'it', 'just', 'needs', 'to', 'be', 'static.'
|
||||
}
|
||||
|
||||
function M.git(args)
|
||||
exec_lua("vim.loop.sleep(20)")
|
||||
--- Run a git command
|
||||
function M.gitf(args)
|
||||
system{"git", "-C", M.scratch, unpack(args)}
|
||||
exec_lua("vim.loop.sleep(20)")
|
||||
end
|
||||
|
||||
--- @param cmds string[][]
|
||||
function M.gitm(cmds)
|
||||
for _, cmd in ipairs(cmds) do
|
||||
M.gitf(cmd)
|
||||
end
|
||||
helpers.sleep(10)
|
||||
end
|
||||
|
||||
--- Run a git command and add a delay
|
||||
function M.git(args)
|
||||
M.gitf(args)
|
||||
helpers.sleep(10)
|
||||
end
|
||||
|
||||
function M.cleanup()
|
||||
@ -53,26 +66,26 @@ function M.cleanup()
|
||||
end
|
||||
|
||||
function M.setup_git()
|
||||
M.git{"init", '-b', 'master'}
|
||||
M.gitf{"init", '-b', 'master'}
|
||||
|
||||
-- Always force color to test settings don't interfere with gitsigns systems
|
||||
-- commands (addresses #23)
|
||||
M.git{'config', 'color.branch' , 'always'}
|
||||
M.git{'config', 'color.ui' , 'always'}
|
||||
M.git{'config', 'color.diff' , 'always'}
|
||||
M.git{'config', 'color.interactive', 'always'}
|
||||
M.git{'config', 'color.status' , 'always'}
|
||||
M.git{'config', 'color.grep' , 'always'}
|
||||
M.git{'config', 'color.pager' , 'true'}
|
||||
M.git{'config', 'color.decorate' , 'always'}
|
||||
M.git{'config', 'color.showbranch' , 'always'}
|
||||
M.gitf{'config', 'color.branch' , 'always'}
|
||||
M.gitf{'config', 'color.ui' , 'always'}
|
||||
M.gitf{'config', 'color.diff' , 'always'}
|
||||
M.gitf{'config', 'color.interactive', 'always'}
|
||||
M.gitf{'config', 'color.status' , 'always'}
|
||||
M.gitf{'config', 'color.grep' , 'always'}
|
||||
M.gitf{'config', 'color.pager' , 'true'}
|
||||
M.gitf{'config', 'color.decorate' , 'always'}
|
||||
M.gitf{'config', 'color.showbranch' , 'always'}
|
||||
|
||||
M.git{'config', 'merge.conflictStyle', 'merge'}
|
||||
M.gitf{'config', 'merge.conflictStyle', 'merge'}
|
||||
|
||||
M.git{'config', 'user.email', 'tester@com.com'}
|
||||
M.git{'config', 'user.name' , 'tester'}
|
||||
M.gitf{'config', 'user.email', 'tester@com.com'}
|
||||
M.gitf{'config', 'user.name' , 'tester'}
|
||||
|
||||
M.git{'config', 'init.defaultBranch', 'master'}
|
||||
M.gitf{'config', 'init.defaultBranch', 'master'}
|
||||
end
|
||||
|
||||
---@param opts? {test_file_text?: string[], no_add?: boolean}
|
||||
@ -84,9 +97,10 @@ function M.setup_test_repo(opts)
|
||||
system{"touch", M.test_file}
|
||||
M.write_to_file(M.test_file, text)
|
||||
if not (opts and opts.no_add) then
|
||||
M.git{"add", M.test_file}
|
||||
M.git{"commit", "-m", "init commit"}
|
||||
M.gitf{"add", M.test_file}
|
||||
M.gitf{"commit", "-m", "init commit"}
|
||||
end
|
||||
helpers.sleep(20)
|
||||
end
|
||||
|
||||
function M.expectf(cond, interval)
|
||||
|
Loading…
Reference in New Issue
Block a user