Skip to content

Commit

Permalink
Windows compat fixes for fs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeterv committed Apr 15, 2016
1 parent b5b01d1 commit ebb41b5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions spec/fs_spec.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local fs = require "luacheck.fs"
local P = fs.normalize

describe("fs", function()
describe("is_dir", function()
Expand Down Expand Up @@ -32,10 +33,10 @@ describe("fs", function()
describe("extract_files", function()
it("returns sorted list of files in a directory matching pattern", function()
assert.same({
"spec/folder/folder1/fail",
"spec/folder/folder1/file",
"spec/folder/foo"
}, fs.extract_files("spec/folder", "^f"))
P"spec/folder/folder1/fail",
P"spec/folder/folder1/file",
P"spec/folder/foo"
}, fs.extract_files(P"spec/folder", "^f"))
end)
end)

Expand All @@ -53,20 +54,20 @@ describe("fs", function()
it("returns absolute path to current directory", function()
local current_dir = fs.current_dir()
assert.string(current_dir)
assert.equal("/", current_dir:sub(1, 1))
assert.not_equal("", (fs.split_base(current_dir)))
assert.is_true(fs.is_file(current_dir .. "spec/folder/foo"))
end)
end)

describe("find_file", function()
it("finds file in a directory", function()
local path = fs.current_dir() .. "spec/folder"
local path = fs.current_dir() .. P"spec/folder"
assert.equal(path, fs.find_file(path, "foo"))
end)

it("finds file in a parent directory", function()
local path = fs.current_dir() .. "spec/folder"
assert.equal(path, fs.find_file(path .. "/folder1", "foo"))
local path = fs.current_dir() .. P"spec/folder"
assert.equal(path, fs.find_file(path .. P"/folder1", "foo"))
end)

it("returns nil if can't find file", function()
Expand Down

0 comments on commit ebb41b5

Please sign in to comment.