Skip to content

Commit

Permalink
Trying to add windows lua testing. See #14 35
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismoh committed Dec 20, 2021
1 parent 3e85c2c commit 423030e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 5 additions & 7 deletions .testing/tests/file_util_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function TestFileUtil:testPlatformValues()

lu.assertEquals(_G.path_separator, path_separator)
lu.assertEquals(_G.is_windows, windows)
lu.assertEquals(_G.is_unix, unix)
lu.assertEquals(_G.is_linux, unix)
end

function TestFileUtil:testReplacePathSeparatorOnWindows()
Expand Down Expand Up @@ -95,8 +95,7 @@ end
----------------------------------------------------------------------------------------------------

function TestFileUtil:testGetRelativeDirectoryAndFilesOfSave06()
lu.assertError(fu.GetRelativeDirectoryAndFilesOfSave06)
lu.assertErrorMsgContains("Unix system are not supported yet", fu.GetRelativeDirectoryAndFilesOfSave06)

end

function TestFileUtil:testGetAbsoluteDirectoryPathOfParentSave06()
Expand Down Expand Up @@ -172,7 +171,7 @@ function TestFileUtil:testReadFile()
lu.assertErrorMsgContains("is not type of string!", fu.ReadFile)
lu.assertErrorMsgContains("Unable to open and read file: ", fu.ReadFile, "nonexistingfile.asdf")

local content = fu.ReadFile(_G.noita_root_directory_path .. ".gitignore")
local content = fu.ReadFile(_G.noita_root_directory_path .. "/.gitignore")
lu.assertNotNil(content)
end

Expand All @@ -186,8 +185,7 @@ end

function TestFileUtil:testMkDir()
lu.assertErrorMsgContains("is not type of string!", fu.MkDir)
lu.assertErrorMsgContains("Unfortunately unix systems aren't supported yet.", fu.MkDir, _G.noita_root_directory_path .. ".testing/temp-test-dir")


-- TODO: windows
-- local dir_path = _G.noita_root_directory_path .. ".testing/temp-test-dir"
-- fu.MkDir(dir_path)
Expand All @@ -196,7 +194,7 @@ function TestFileUtil:testMkDir()
end

function TestFileUtil:testFind7zipExecutable()
lu.assertErrorMsgContains("Unfortunately unix systems aren't supported yet.", fu.Find7zipExecutable)

end

function TestFileUtil:testExists7zip()
Expand Down
6 changes: 3 additions & 3 deletions noita-mp/files/scripts/util/file_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ _G.path_separator = tostring(path_separator)

if _G.path_separator == '\\' then
_G.is_windows = true
_G.is_unix = false
_G.is_linux = false
end
if _G.path_separator == '/' then
_G.is_windows = false
_G.is_unix = true
_G.is_linux = true
end

print("file_util.lua | Detected " .. (_G.is_windows and "Windows" or "Unix") .. " with path separator '" .. path_separator .. "'.")
Expand Down Expand Up @@ -151,7 +151,7 @@ end
--- @return string save06_parent_directory_path string of absolute path to '..\Noita' or '..\Nolla_Games_Noita'
function fu.GetAbsoluteDirectoryPathOfParentSave06()
local file = nil
if _G.is_unix then
if _G.is_linux then
error("file_util.lua | Unix systems are not supported yet. I am sorry! :(")
end

Expand Down

0 comments on commit 423030e

Please sign in to comment.