Skip to content

Commit

Permalink
Windows ci attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
Conni2461 committed Feb 22, 2021
1 parent 9b4216d commit c1997cd
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 134 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
mkdir -p _neovim
curl -sL ${{ matrix.url }} | tar xzf - --strip-components=1 -C "${PWD}/_neovim"
}
git clone --depth 1 https://github.com/neovim/neovim
- name: Run tests
run: |
Expand Down Expand Up @@ -69,3 +68,27 @@ jobs:
run: |
export PATH="${PWD}/build/:${PATH}"
make test
windows:
name: Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

# TODO(conni2461): Cache
- name: Prepare
run: |
curl -sL https://github.com/neovim/neovim/releases/download/nightly/nvim-win64.zip --output nvim-win64.zip
unzip nvim-win64.zip
rm nvim-win64.zip
curl -sL https://github.com/sharkdp/fd/releases/download/v8.2.1/fd-v8.2.1-x86_64-pc-windows-msvc.zip --output fd.zip
unzip fd.zip
rm fd.zip
- name: Run tests
run: |
$env:Path += ";Neovim/bin/;Fd/"
nvim --version
# nvim --headless --noplugin -u scripts/minimal.vim -c "PlenaryBustedFile tests/plenary/simple_busted_spec.lua"
make test
4 changes: 2 additions & 2 deletions lua/plenary/scandir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ end
local process_item = function(opts, name, typ, current_dir, next_dir, bp, data, giti, msp)
if opts.hidden or name:sub(1, 1) ~= '.' then
if typ == 'directory' then
local entry = current_dir .. '/' .. name
local entry = current_dir .. os_sep .. name
if opts.depth then
table.insert(next_dir, handle_depth(bp, entry, opts.depth))
else
Expand All @@ -85,7 +85,7 @@ local process_item = function(opts, name, typ, current_dir, next_dir, bp, data,
end
end
else
local entry = current_dir .. '/' .. name
local entry = current_dir .. os_sep .. name
if not giti or interpret_gitignore(giti, bp, entry) then
if not msp or msp(entry) then
table.insert(data, entry)
Expand Down
27 changes: 20 additions & 7 deletions lua/plenary/test_harness.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
local Path = require("plenary.path")
local Job = require("plenary.job")
local scan = require("plenary.scandir")

local f = require("plenary.functional")
local log = require("plenary.log")
local win_float = require("plenary.window.float")

local headless = require("plenary.nvim_meta").is_headless
local os_sep = Path.path.sep
local is_windows = os_sep == '\\'

local harness = {}

Expand All @@ -31,6 +34,11 @@ end)
function harness.test_directory_command(command)
local split_string = vim.split(command, " ")
local directory = table.remove(split_string, 1)
if is_windows then
for k, v in ipairs(split_string) do
split_string[k] = v:gsub('\\', '\\\\')
end
end

local opts = assert(loadstring('return ' .. table.concat(split_string, " ")))()

Expand Down Expand Up @@ -62,7 +70,7 @@ function harness.test_directory(directory, opts)

local paths = harness._find_files_to_run(directory)
for _, p in ipairs(paths) do
outputter(res.bufnr, "Scheduling: " .. p.filename)
outputter(res.bufnr, "Scheduling: " .. p)
end

local path_len = #paths
Expand All @@ -72,7 +80,7 @@ function harness.test_directory(directory, opts)
local args = {
'--headless',
'-c',
string.format('lua require("plenary.busted").run("%s")', p:absolute())
string.format('lua require("plenary.busted").run("%s")', p)
}

if opts.minimal_init ~= nil then
Expand All @@ -81,6 +89,12 @@ function harness.test_directory(directory, opts)
table.insert(args, '-u')
table.insert(args, opts.minimal_init)
end
-- PLEASE SOMEONE TELL ME WHY WE NEED TO DO THAT?!?
if is_windows then
for k, v in ipairs(args) do
args[k] = v:gsub('\\', '/')
end
end

return Job:new {
command = 'nvim',
Expand Down Expand Up @@ -140,12 +154,11 @@ function harness.test_directory(directory, opts)
end

function harness._find_files_to_run(directory)
local finder = Job:new {
command = 'find',
args = {directory, '-type', 'f', '-name', '*_spec.lua'},
}
if directory:sub(#directory, -1) == os_sep then
directory = directory:sub(1, -2)
end

return f.map(Path.new, finder:sync())
return scan.scan_dir(directory, { search_pattern = '.*%_spec%.lua' })
end

function harness._run_path(test_type, directory)
Expand Down
5 changes: 5 additions & 0 deletions tests/plenary/curl_spec.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
local curl = require('plenary.curl')

local os_sep = require'plenary.path'.path.sep

local eq = assert.are.same
local incl = function(p, s)
return (nil ~= string.find(s, p))
end

describe('CURL Wrapper:', function()
-- TODO(conni2461): Doesn't run on windows dunno why
if os_sep == '\\' then return end

describe('request', function() -----------------------------------------------

Expand Down
70 changes: 32 additions & 38 deletions tests/plenary/job_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ local has_all_executables = function(execs)
return true
end

local contains = function(a, b)
local found = 0
for _, v in ipairs(a) do
for _, w in ipairs(b) do
if v == w then found = found + 1 end
end
end
return found == #b
end

describe('Job', function()
describe('> cat manually >', function()
it('should split simple stdin', function()
Expand Down Expand Up @@ -106,7 +116,7 @@ describe('Job', function()

job:sync()

assert.are.same(job:result(), { 'A=100' })
assert.are.same(true, contains(job:result(), { 'A=100' }))
assert.are.same(job:result(), results)
end)

Expand All @@ -122,7 +132,7 @@ describe('Job', function()

job:sync()

assert.are.same(job:result(), { 'A=100', 'B=test' })
assert.are.same(true, contains(job:result(), { 'A=100', 'B=test' }))
assert.are.same(job:result(), results)
end)

Expand All @@ -138,7 +148,7 @@ describe('Job', function()

job:sync()

assert.are.same(job:result(), { 'A=100' })
assert.are.same(true, contains(job:result(), { 'A=100' }))
assert.are.same(job:result(), results)
end)

Expand All @@ -154,7 +164,7 @@ describe('Job', function()

job:sync()

assert.are.same(job:result(), { 'A=This is a long env var' })
assert.are.same(true, contains(job:result(), { 'A=This is a long env var' }))
assert.are.same(job:result(), results)
end)

Expand All @@ -170,7 +180,7 @@ describe('Job', function()

job:sync()

assert.are.same(job:result(), { 'A=This is a long env var' })
assert.are.same(true, contains(job:result(), { 'A=This is a long env var' }))
assert.are.same(job:result(), results)
end)

Expand All @@ -186,15 +196,7 @@ describe('Job', function()

job:sync()

local expected = { 'A=100', 'B=test' }
local found = { false, false }
for k, v in ipairs(job:result()) do
for _, w in ipairs(expected) do
if v == w then found[k] = true end
end
end

assert.are.same({ true, true }, found)
assert.are.same(true, contains(job:result(), { 'A=100', 'B=test' }))
assert.are.same(job:result(), results)
end)

Expand All @@ -210,15 +212,7 @@ describe('Job', function()

job:sync()

local expected = { 'A=100', 'B=test' }
local found = { false, false }
for k, v in ipairs(job:result()) do
for _, w in ipairs(expected) do
if v == w then found[k] = true end
end
end

assert.are.same({ true, true }, found)
assert.are.same(true, contains(job:result(), { 'A=100', 'B=test' }))
assert.are.same(job:result(), results)
end)
end)
Expand Down Expand Up @@ -304,11 +298,11 @@ describe('Job', function()
third_job:wait()
fourth_job:wait()

assert.are.same({'a=1', 'b=2', 'c=3'}, results)
assert.are.same({'a=1'}, first_job:result())
assert.are.same({'b=2'}, second_job:result())
assert.are.same(true, contains(results, { 'a=1', 'b=2', 'c=3' }))
assert.are.same(true, contains(first_job:result(), { 'a=1' }))
assert.are.same(true, contains(second_job:result(), { 'b=2' }))
assert.are.same(1, third_job.code)
assert.are.same({'c=3'}, fourth_job:result())
assert.are.same(true, contains(fourth_job:result(), { 'c=3' }))
end)

it('should only run the next job on success when using and_then_on_success', function()
Expand Down Expand Up @@ -342,9 +336,9 @@ describe('Job', function()
second_job:wait()
third_job:wait()

assert.are.same({'a=1', 'b=2'}, results)
assert.are.same({'a=1'}, first_job:result())
assert.are.same({'b=2'}, second_job:result())
assert.are.same(true, contains(results, { 'a=1', 'b=2' }))
assert.are.same(true, contains(first_job:result(), { 'a=1' }))
assert.are.same(true, contains(second_job:result(), { 'b=2' }))
assert.are.same(1, third_job.code)
assert.are.same(nil, fourth_job.handle, "Job never started")
end)
Expand Down Expand Up @@ -376,8 +370,8 @@ describe('Job', function()

assert.are.same(1, first_job.code)
assert.are.same(1, ret)
assert.are.same({'a=1'}, results)
assert.are.same({'a=1'}, second_job:result())
assert.are.same(true, contains(results, { 'a=1' }))
assert.are.same(true, contains(second_job:result(), { 'a=1' }))
assert.are.same(nil, third_job.handle, "Job never started")
end)

Expand All @@ -400,8 +394,8 @@ describe('Job', function()
first_job:sync()
second_job:wait()

assert.are.same({'a=1'}, results)
assert.are.same({'a=1'}, first_job:result())
assert.are.same(true, contains(results, { 'a=1' }))
assert.are.same(true, contains(first_job:result(), { 'a=1' }))
assert.are.same(1, second_job.code)
assert.are.same(11, code)
end)
Expand All @@ -427,8 +421,8 @@ describe('Job', function()
first_job:sync()
second_job:wait()

assert.are.same({'a=1'}, results)
assert.are.same({'a=1'}, first_job:result())
assert.are.same(true, contains(results, { 'a=1' }))
assert.are.same(true, contains(first_job:result(), { 'a=1' }))
assert.are.same(1, second_job.code)
assert.are.same(10, code)
assert.are.same(nil, third_job.handle)
Expand Down Expand Up @@ -456,8 +450,8 @@ describe('Job', function()
local _, ret = first_job:sync()
second_job:wait()

assert.are.same({'a=1'}, results)
assert.are.same({'a=1'}, second_job:result())
assert.are.same(true, contains(results, { 'a=1' }))
assert.are.same(true, contains(second_job:result(), { 'a=1' }))
assert.are.same(1, ret)
assert.are.same(1, first_job.code)
assert.are.same(1, code)
Expand Down
20 changes: 10 additions & 10 deletions tests/plenary/path_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ describe('Path', function()

describe(':normalize', function()
it('can take paths with double separators change them to single separators', function()
local orig = 'lua//plenary/path.lua'
local orig = 'lua' .. path.sep .. path.sep .. 'plenary' .. path.sep .. 'path.lua'
local final = Path:new(orig):normalize()
assert.are.same(final, 'lua/plenary/path.lua')
assert.are.same(final, 'lua' .. path.sep .. 'plenary' .. path.sep .. 'path.lua')
end)
-- this may be redundant since normalize just calls make_relative which is tested above
it('can take absolute paths with double seps'
.. 'and make them relative with single seps', function()
local orig = vim.loop.cwd() .. '/lua//plenary/path.lua'
local orig = vim.loop.cwd() .. path.sep .. 'lua' .. path.sep .. path.sep .. 'plenary' .. path.sep .. 'path.lua'
local final = Path:new(orig):normalize()
assert.are.same(final, 'lua/plenary/path.lua')
assert.are.same(final, 'lua' .. path.sep .. 'plenary' .. path.sep .. 'path.lua')
end)
end)

Expand Down Expand Up @@ -219,14 +219,14 @@ in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:]]
assert.are.same(should, data)
assert.are.same(should, data:gsub("\r", ""))
end)

it('should read the first line of file', function()
local p = Path:new('LICENSE')
local data = p:head(1)
local should = [[MIT License]]
assert.are.same(should, data)
assert.are.same(should, data:gsub("\r", ""))
end)

it('head should max read whole file', function()
Expand All @@ -253,7 +253,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.]]
assert.are.same(should, data)
assert.are.same(should, data:gsub("\r", ""))
end)

it('should read tail of file', function()
Expand All @@ -269,14 +269,14 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.]]
assert.are.same(should, data)
assert.are.same(should, data:gsub("\r", ""))
end)

it('should read the last line of file', function()
local p = Path:new('LICENSE')
local data = p:tail(1)
local should = [[SOFTWARE.]]
assert.are.same(should, data)
assert.are.same(should, data:gsub("\r", ""))
end)

it('tail should max read whole file', function()
Expand All @@ -303,7 +303,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.]]
assert.are.same(should, data)
assert.are.same(should, data:gsub("\r", ""))
end)
end)
end)
Expand Down
Loading

0 comments on commit c1997cd

Please sign in to comment.