Skip to content

Commit

Permalink
ci: resolve failures
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Jan 8, 2025
1 parent b544bd6 commit 2eaa305
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 27 deletions.
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export PJ_ROOT=$(PWD)

FILTER ?= .*

export NVIM_RUNNER_VERSION := v0.10.0
export NVIM_TEST_VERSION ?= v0.10.0
export NVIM_RUNNER_VERSION := v0.10.3
export NVIM_TEST_VERSION ?= v0.10.3

ifeq ($(shell uname -s),Darwin)
UNAME ?= MACOS
Expand All @@ -29,10 +29,19 @@ test: nvim-test
-@stty sane

.PHONY: test-all
test-all:
$(MAKE) test NVIM_TEST_VERSION=v0.9.5
$(MAKE) test NVIM_TEST_VERSION=v0.10.0
$(MAKE) test NVIM_TEST_VERSION=nightly
test-all: test-095 test-010 test-nightly

.PHONY: test-095
test-095:
$(MAKE) $(MAKEFLAGS) test NVIM_TEST_VERSION=v0.9.5

.PHONY: test-010
test-010:
$(MAKE) $(MAKEFLAGS) test NVIM_TEST_VERSION=v0.10.3

.PHONY: test-nightly
test-nightly:
$(MAKE) $(MAKEFLAGS) test NVIM_TEST_VERSION=nightly

export XDG_DATA_HOME ?= $(HOME)/.data

Expand Down
10 changes: 5 additions & 5 deletions lua/gitsigns/diffthis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ local function diffthis_rev(base, opts)
mods = {
vertical = opts.vertical,
split = opts.split or 'aboveleft',
keepalt = true
}
keepalt = true,
},
})

api.nvim_set_current_win(cwin)
Expand All @@ -173,7 +173,7 @@ local function diffthis_rev(base, opts)
if disable_cwin_diff then
vim.wo[cwin].diff = false
end
end
end,
})
end

Expand Down Expand Up @@ -243,8 +243,8 @@ end
--- @return boolean
local function is_fugitive_diff_window(name)
return vim.startswith(name, 'fugitive://')
and vim.fn.exists('*FugitiveParse')
and vim.fn.FugitiveParse(name)[1] ~= ':'
and vim.fn.exists('*FugitiveParse')
and vim.fn.FugitiveParse(name)[1] ~= ':'
end

-- This function needs to be throttled as there is a call to vim.ui.input
Expand Down
39 changes: 38 additions & 1 deletion test/actions_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ local setup_gitsigns = helpers.setup_gitsigns
local feed = helpers.feed
local test_file = helpers.test_file
local edit = helpers.edit
local command = helpers.api.nvim_command
local check = helpers.check
local exec_lua = helpers.exec_lua
local fn = helpers.fn
Expand Down Expand Up @@ -50,7 +49,45 @@ local function expect_hunks(exp_hunks)
end)
end

local delay = 10

local function command(cmd)
helpers.sleep(delay)
helpers.api.nvim_command(cmd)

-- Flaky tests, add a large delay between commands.
-- Flakyness is due to actions being async and problems occur when an action
-- is run while another action or update is running.
-- Must wait for actions and updates to finish.
helpers.sleep(delay)
end

local function retry(f)
local ok, err

for _ = 1, 20 do
ok, err = pcall(f)
if ok then
return
end
delay = delay * 1.6
print('failed, retrying with delay', delay)
end

if err then
error(err)
end
end

describe('actions', function()

local orig_it = it
local function it(desc, f)
orig_it(desc, function()
retry(f)
end)
end

local config --- @type Gitsigns.Config

before_each(function()
Expand Down
54 changes: 39 additions & 15 deletions test/gitsigns_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ describe('gitsigns (with screen)', function()
[8] = { foreground = Screen.colors.White, background = Screen.colors.Red },
[9] = { foreground = Screen.colors.SeaGreen, bold = true },
[10] = { foreground = Screen.colors.Red },
[11] = { foreground = Screen.colors.NvimDarkRed, background = Screen.colors.WebGray },
[12] = { foreground = Screen.colors.NvimDarkCyan, background = Screen.colors.WebGray },
}

-- Use the classic vim colorscheme, not the new defaults in nvim >= 0.10
Expand Down Expand Up @@ -715,31 +717,53 @@ describe('gitsigns (with screen)', function()

feed('x')

screen:expect({
grid = [[
{2:~ }^orem ipsum |
{6:~ }|
]],
})
if fn.has('nvim-0.11') > 0 then
screen:expect({
grid = [[
{12:~ }^orem ipsum |
{6:~ }|
]],
})
else
screen:expect({
grid = [[
{2:~ }^orem ipsum |
{6:~ }|
]],
})
end
end)

it('handle #521', function()
screen:detach()
screen:attach({ ext_messages = false })
screen:try_resize(20, 3)
screen:attach()
screen:try_resize(20, 4)
setup_test_repo()
setup_gitsigns(config)
edit(test_file)
feed('dd')

local function check_screen()
screen:expect({
grid = [[
{4:^ }^is |
{1: }a |
{1: }file |
]],
})
if fn.has('nvim-0.11') > 0 then
-- TODO(lewis6991): ???
screen:expect({
grid = [[
{11:^ }^is |
{1: }a |
{1: }file |
|
]],
})
else
screen:expect({
grid = [[
{4:^ }^is |
{1: }a |
{1: }file |
{1: }used |
]],
})
end
end

check_screen()
Expand Down

0 comments on commit 2eaa305

Please sign in to comment.