Skip to content

Commit

Permalink
test: remove dependency on ripgrep for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronr committed Aug 3, 2024
1 parent 7a12923 commit 72731bd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/test_lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,21 @@ M.named_session_name = "mysession"
M.named_session_path = M.session_dir .. M.named_session_name .. ".vim"

function M.fileHasString(file_path, string)
return vim.fn.system('rg -c "' .. string .. '" "' .. file_path .. '"'):gsub("%s+", "") ~= ""
if vim.fn.has "win32" == 1 then
return vim.fn
.system('findstr /c:"' .. string .. '" "' .. (file_path:gsub("/", "\\")) .. '" | find /c /v ""')
:gsub("%s+", "") ~= "0"
end
return vim.fn.system('grep -c "' .. string .. '" "' .. file_path .. '"'):gsub("%s+", "") ~= "0"
end

function M.sessionHasFile(session_path, file)
return vim.fn.system('rg badd "' .. session_path .. '" | rg -c "' .. file .. '"'):gsub("%s+", "") == "1"
if vim.fn.has "win32" == 1 then
return vim.fn
.system('findstr badd "' .. (session_path:gsub("/", "\\")) .. '" | findstr /c:"' .. file .. '" | find /c /v ""')
:gsub("%s+", "") == "1"
end
return vim.fn.system('grep badd "' .. session_path .. '" | grep -c "' .. file .. '"'):gsub("%s+", "") == "1"
end

function M.assertSessionHasFile(session_path, file)
Expand Down

0 comments on commit 72731bd

Please sign in to comment.