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 eec1461
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 15 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,25 @@ jobs:
run: |
export PATH="${PWD}/build/:${PATH}"
make test
windows:
name: Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

- name: Prepare
run: |
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
curl -sL https://github.com/neovim/neovim/releases/download/nightly/nvim-win64.zip --output nvim-win64.zip
unzip nvim-win64.zip
unzip fd.zip
rm nvim-win64.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
12 changes: 6 additions & 6 deletions tests/plenary/path_spec.lua
Original file line number Diff line number Diff line change
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

0 comments on commit eec1461

Please sign in to comment.