2008-10-31 18:38:05 +00:00
|
|
|
--
|
2009-09-29 19:27:33 +00:00
|
|
|
-- tests/base/test_path.lua
|
|
|
|
-- Automated test suite for the action list.
|
2013-01-04 15:18:47 +00:00
|
|
|
-- Copyright (c) 2008-2013 Jason Perkins and the Premake project
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
|
2013-01-03 16:11:31 +00:00
|
|
|
local suite = test.declare("path")
|
2008-10-31 18:38:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- path.getabsolute() tests
|
|
|
|
--
|
|
|
|
|
2013-01-04 15:18:47 +00:00
|
|
|
function suite.getabsolute_worksWithMissingSubdirs()
|
|
|
|
local expected = os.getcwd() .. "/a/b/c"
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal(expected, path.getabsolute("a/b/c"))
|
|
|
|
end
|
|
|
|
|
2013-01-04 15:18:47 +00:00
|
|
|
function suite.getabsolute_removesDotDots_onWindows()
|
2008-12-05 21:18:47 +00:00
|
|
|
test.isequal("c:/ProjectB/bin", path.getabsolute("c:/ProjectA/../ProjectB/bin"))
|
|
|
|
end
|
2008-10-31 18:38:05 +00:00
|
|
|
|
2013-01-04 15:18:47 +00:00
|
|
|
function suite.getabsolute_removesDotDots_OnPosix()
|
2008-12-05 21:18:47 +00:00
|
|
|
test.isequal("/ProjectB/bin", path.getabsolute("/ProjectA/../ProjectB/bin"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2013-01-04 15:18:47 +00:00
|
|
|
function suite.getabsolute_limitsDotDots_onWindows()
|
|
|
|
test.isequal("c:/ProjectB/bin", path.getabsolute("c:/ProjectA/../../ProjectB/bin"))
|
2009-05-29 19:07:35 +00:00
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2013-01-04 15:18:47 +00:00
|
|
|
function suite.getabsolute_limitsDotDots_OnPosix()
|
|
|
|
test.isequal("/ProjectB/bin", path.getabsolute("/ProjectA/../../ProjectB/bin"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_removesDot()
|
|
|
|
test.isequal("/ProjectA/ProjectB/bin", path.getabsolute("/ProjectA/./ProjectB/bin"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_removesTrailingSlash()
|
|
|
|
test.isequal("/a/b/c", path.getabsolute("/a/b/c/"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_onLeadingEnvVar()
|
2011-03-23 20:38:40 +00:00
|
|
|
test.isequal("$(HOME)/user", path.getabsolute("$(HOME)/user"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2016-01-20 19:06:38 +00:00
|
|
|
function suite.getabsolute_onLeadingEnvVar_dosStyle()
|
|
|
|
test.isequal("%HOME%/user", path.getabsolute("%HOME%/user"))
|
|
|
|
end
|
|
|
|
|
2018-07-17 21:41:22 +00:00
|
|
|
function suite.getabsolute_onServerPath()
|
|
|
|
test.isequal("//Server/Volume", path.getabsolute("//Server/Volume"))
|
|
|
|
end
|
|
|
|
|
2013-01-04 15:18:47 +00:00
|
|
|
function suite.getabsolute_onMultipleEnvVar()
|
2011-03-23 20:38:40 +00:00
|
|
|
test.isequal("$(HOME)/$(USER)", path.getabsolute("$(HOME)/$(USER)"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2013-01-04 15:18:47 +00:00
|
|
|
function suite.getabsolute_onTrailingEnvVar()
|
|
|
|
test.isequal("/home/$(USER)", path.getabsolute("/home/$(USER)"))
|
2011-03-23 20:38:40 +00:00
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2013-01-04 15:18:47 +00:00
|
|
|
function suite.getabsolute_onLeadingEnvVarQuoted()
|
2012-03-19 22:57:45 +00:00
|
|
|
test.isequal('"$(HOME)/user"', path.getabsolute('"$(HOME)/user"'))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2013-01-04 15:18:47 +00:00
|
|
|
function suite.getabsolute_normalizesPaths()
|
|
|
|
test.isequal("c:/ProjectB/bin", path.getabsolute("c:\\ProjectB\\bin"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_acceptsTables()
|
|
|
|
test.isequal({ "/a/b", "/c/d" }, path.getabsolute({ "/a/b", "/c/d" }))
|
|
|
|
end
|
|
|
|
|
2013-10-12 20:18:54 +00:00
|
|
|
function suite.getabsolute_withRelativeTo()
|
|
|
|
local relto = path.getdirectory(os.getcwd())
|
|
|
|
local expected = relto .. "/a/b/c"
|
|
|
|
test.isequal(expected, path.getabsolute("a/b/c", relto))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_withRelativeTo_withTrailingSlashes()
|
|
|
|
local relto = path.getdirectory(os.getcwd())
|
|
|
|
local expected = relto .. "/a/b/c"
|
|
|
|
test.isequal(expected, path.getabsolute("a/b/c", relto .. "/"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_acceptsTables_withRelativeTo()
|
|
|
|
local relto = path.getdirectory(os.getcwd())
|
|
|
|
test.isequal({ relto .. "/a/b", relto .. "/c/d" }, path.getabsolute({ "a/b", "c/d" }, relto))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_leavesDotDot_onShellVar()
|
|
|
|
test.isequal("$ORIGIN/../libs", path.getabsolute("$ORIGIN/../libs"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_leavesDotDot2_onShellVar()
|
|
|
|
test.isequal("$ORIGIN/../../libs", path.getabsolute("$ORIGIN/../../libs"))
|
|
|
|
end
|
|
|
|
|
2017-09-20 21:32:51 +00:00
|
|
|
--
|
|
|
|
-- path.deferred_join() tests
|
|
|
|
--
|
|
|
|
function suite.deferred_join_OnMaybeAbsolutePath()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1\a%{foo}", path.deferredjoin("p1", "%{foo}"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.deferred_join_OnValidParts()
|
|
|
|
test.isequal("p1/p2", path.deferredjoin("p1", "p2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.deferred_join_OnAbsoluteath()
|
|
|
|
test.isequal("/p2", path.deferredjoin("p1", "/p2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
--
|
|
|
|
-- path.has_deferred_join() tests
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.has_deferred_join_true()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.istrue(path.hasdeferredjoin("p1\a%{foo}"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
2018-04-30 13:40:49 +00:00
|
|
|
function suite.has_deferred_join_false()
|
2017-09-20 21:32:51 +00:00
|
|
|
test.isfalse(path.hasdeferredjoin("p1/p2"))
|
|
|
|
end
|
|
|
|
|
2020-01-05 17:45:51 +00:00
|
|
|
function suite.has_deferred_join_true_OnPipe()
|
|
|
|
test.istrue(path.hasdeferredjoin("c1 p1\a%{foo} | c2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.has_deferred_join_false_OnPipe()
|
|
|
|
test.isfalse(path.hasdeferredjoin("c1 p1/p2 | c2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.has_deferred_join_true_OnOr()
|
|
|
|
test.istrue(path.hasdeferredjoin("c1 p1\a%{foo} || c2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.has_deferred_join_false_OnOr()
|
|
|
|
test.isfalse(path.hasdeferredjoin("c1 p1/p2 || c2"))
|
|
|
|
end
|
|
|
|
|
2017-09-20 21:32:51 +00:00
|
|
|
--
|
|
|
|
-- path.resolvedeferredjoin() tests
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnNoDelimiter()
|
|
|
|
test.isequal("p1", path.resolvedeferredjoin("p1"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnValidParts()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1/p2", path.resolvedeferredjoin("p1\ap2"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnAbsoluteWindowsPath()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("C:/p2", path.resolvedeferredjoin("p1\aC:/p2"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnCurrentDirectory()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p2", path.resolvedeferredjoin(".\ap2"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnBackToBasePath()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("", path.resolvedeferredjoin("p1/p2/\a../../"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnBackToBasePathWithoutFinalSlash()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("", path.resolvedeferredjoin("p1/p2/\a../.."))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnBothUpTwoFolders()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("../../../../foo", path.resolvedeferredjoin("../../\a../../foo"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnUptwoFolders()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1/foo", path.resolvedeferredjoin("p1/p2/p3\a../../foo"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnUptoBase()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("foo", path.resolvedeferredjoin("p1/p2/p3\a../../../foo"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_ignoreLeadingDots()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1/p2/foo", path.resolvedeferredjoin("p1/p2\a././foo"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnUptoParentOfBase()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("../../p1", path.resolvedeferredjoin("p1/p2/p3/p4/p5/p6/p7/\a../../../../../../../../../p1"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_onMoreThanTwoParts()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1/p2/p3", path.resolvedeferredjoin("p1\ap2\ap3"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_removesExtraInternalSlashes()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1/p2", path.resolvedeferredjoin("p1/\ap2"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_removesTrailingSlash()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1/p2", path.resolvedeferredjoin("p1\ap2/"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_ignoresEmptyParts()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p2", path.resolvedeferredjoin("\ap2\a"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_canJoinBareSlash()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("/Users", path.resolvedeferredjoin("/\aUsers"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_keepsLeadingEnvVar()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("$(ProjectDir)/../../Bin", path.resolvedeferredjoin("$(ProjectDir)\a../../Bin"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_keepsInternalEnvVar()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("$(ProjectDir)/$(TargetName)/../../Bin", path.resolvedeferredjoin("$(ProjectDir)/$(TargetName)\a../../Bin"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_keepsComplexInternalEnvVar()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("$(ProjectDir)/myobj_$(Arch)/../../Bin", path.resolvedeferredjoin("$(ProjectDir)/myobj_$(Arch)\a../../Bin"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_keepsRecursivePattern()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1/**.lproj/../p2", path.resolvedeferredjoin("p1/**.lproj\a../p2"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_keepsVSMacros()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1/%(Filename).ext", path.resolvedeferredjoin("p1\a%(Filename).ext"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_noCombineSingleDot()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("p1/./../p2", path.resolvedeferredjoin("p1/.\a../p2"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_absolute_second_part()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("$ORIGIN", path.resolvedeferredjoin("foo/bar\a$ORIGIN"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_absolute_second_part1()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("$(FOO)/bar", path.resolvedeferredjoin("foo/bar\a$(FOO)/bar"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_absolute_second_part2()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("%ROOT%/foo", path.resolvedeferredjoin("foo/bar\a%ROOT%/foo"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_token_in_second_part()
|
2020-01-05 17:45:51 +00:00
|
|
|
test.isequal("foo/bar/%{test}/foo", path.resolvedeferredjoin("foo/bar\a%{test}/foo"))
|
2017-09-20 21:32:51 +00:00
|
|
|
end
|
|
|
|
|
2020-01-05 17:45:51 +00:00
|
|
|
function suite.resolve_deferred_join_ignoresPipe()
|
|
|
|
test.isequal("c1 p1/p2 | c2", path.resolvedeferredjoin("c1 p1/p2 | c2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnPipe()
|
|
|
|
test.isequal("c1 p1/p2 | c2", path.resolvedeferredjoin("c1 p1\ap2 | c2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_ignoresOr()
|
|
|
|
test.isequal("c1 p1/p2 || c2", path.resolvedeferredjoin("c1 p1/p2 || c2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.resolve_deferred_join_OnOr()
|
|
|
|
test.isequal("c1 p1/p2 || c2", path.resolvedeferredjoin("c1 p1\ap2 || c2"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
-- path.getbasename() tests
|
|
|
|
--
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getbasename_ReturnsCorrectName_OnDirAndExtension()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal("filename", path.getbasename("folder/filename.ext"))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- path.getdirectory() tests
|
|
|
|
--
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getdirectory_ReturnsEmptyString_OnNoDirectory()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal(".", path.getdirectory("filename.ext"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getdirectory_ReturnsDirectory_OnSingleLevelPath()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal("dir0", path.getdirectory("dir0/filename.ext"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getdirectory_ReturnsDirectory_OnMultiLeveLPath()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal("dir0/dir1/dir2", path.getdirectory("dir0/dir1/dir2/filename.ext"))
|
|
|
|
end
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getdirectory_ReturnsRootPath_OnRootPathOnly()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal("/", path.getdirectory("/filename.ext"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
|
2009-01-05 15:40:05 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- path.getdrive() tests
|
|
|
|
--
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getdrive_ReturnsNil_OnNotWindows()
|
2009-01-05 15:40:05 +00:00
|
|
|
test.isnil(path.getdrive("/hello"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getdrive_ReturnsLetter_OnWindowsAbsolute()
|
2009-01-05 15:40:05 +00:00
|
|
|
test.isequal("x", path.getdrive("x:/hello"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
-- path.getextension() tests
|
|
|
|
--
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getextension_ReturnsEmptyString_OnNoExtension()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal("", path.getextension("filename"))
|
|
|
|
end
|
2016-09-20 15:40:27 +00:00
|
|
|
|
2017-04-25 17:15:33 +00:00
|
|
|
function suite.getextension_ReturnsEmptyString_OnPathWithDotAndNoExtension()
|
2016-03-29 07:02:49 +00:00
|
|
|
test.isequal("", path.getextension("/.premake/premake"))
|
|
|
|
end
|
2008-10-31 18:38:05 +00:00
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getextension_ReturnsExtension()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal(".txt", path.getextension("filename.txt"))
|
|
|
|
end
|
2016-09-20 15:40:27 +00:00
|
|
|
|
2017-04-25 17:15:33 +00:00
|
|
|
function suite.getextension_ReturnsExtension_OnPathWithDot()
|
2016-03-29 07:02:49 +00:00
|
|
|
test.isequal(".lua", path.getextension("/.premake/premake.lua"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getextension_OnMultipleDots()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal(".txt", path.getextension("filename.mod.txt"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2011-07-12 20:55:27 +00:00
|
|
|
function suite.getextension_OnLeadingNumeric()
|
|
|
|
test.isequal(".7z", path.getextension("filename.7z"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2011-07-12 20:55:27 +00:00
|
|
|
function suite.getextension_OnUnderscore()
|
|
|
|
test.isequal(".a_c", path.getextension("filename.a_c"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2011-07-12 20:55:27 +00:00
|
|
|
function suite.getextension_OnHyphen()
|
|
|
|
test.isequal(".a-c", path.getextension("filename.a-c"))
|
|
|
|
end
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- path.getrelative() tests
|
|
|
|
--
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getrelative_ReturnsDot_OnMatchingPaths()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal(".", path.getrelative("/a/b/c", "/a/b/c"))
|
|
|
|
end
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getrelative_ReturnsDoubleDot_OnChildToParent()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal("..", path.getrelative("/a/b/c", "/a/b"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getrelative_ReturnsDoubleDot_OnSiblingToSibling()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal("../d", path.getrelative("/a/b/c", "/a/b/d"))
|
|
|
|
end
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getrelative_ReturnsChildPath_OnParentToChild()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal("d", path.getrelative("/a/b/c", "/a/b/c/d"))
|
|
|
|
end
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getrelative_ReturnsChildPath_OnWindowsAbsolute()
|
2008-12-15 15:00:35 +00:00
|
|
|
test.isequal("obj/debug", path.getrelative("C:/Code/Premake4", "C:/Code/Premake4/obj/debug"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2018-07-17 21:41:22 +00:00
|
|
|
function suite.getrelative_ReturnsChildPath_OnServerPath()
|
|
|
|
test.isequal("../Volume", path.getrelative("//Server/Shared", "//Server/Volume"))
|
|
|
|
end
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getrelative_ReturnsAbsPath_OnDifferentDriveLetters()
|
2009-01-05 15:40:05 +00:00
|
|
|
test.isequal("D:/Files", path.getrelative("C:/Code/Premake4", "D:/Files"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.getrelative_ReturnsAbsPath_OnDollarMacro()
|
|
|
|
test.isequal("$(SDK_HOME)/include", path.getrelative("C:/Code/Premake4", "$(SDK_HOME)/include"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2010-02-27 02:50:55 +00:00
|
|
|
function suite.getrelative_ReturnsAbsPath_OnRootedPath()
|
|
|
|
test.isequal("/opt/include", path.getrelative("/home/me/src/project", "/opt/include"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2018-07-17 21:41:22 +00:00
|
|
|
function suite.getrelative_ReturnsAbsPath_OnServerPath()
|
|
|
|
test.isequal("//Server/Volume", path.getrelative("C:/Files", "//Server/Volume"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getrelative_ReturnsAbsPath_OnDifferentServers()
|
|
|
|
test.isequal("//Server/Volume", path.getrelative("//Computer/Users", "//Server/Volume"))
|
|
|
|
end
|
|
|
|
|
2013-12-20 20:08:05 +00:00
|
|
|
function suite.getrelative_ignoresExtraSlashes2()
|
2013-03-06 15:06:45 +00:00
|
|
|
test.isequal("..", path.getrelative("/a//b/c","/a/b"))
|
|
|
|
end
|
|
|
|
|
2013-12-20 20:08:05 +00:00
|
|
|
function suite.getrelative_ignoresExtraSlashes3()
|
2013-03-06 15:06:45 +00:00
|
|
|
test.isequal("..", path.getrelative("/a///b/c","/a/b"))
|
|
|
|
end
|
|
|
|
|
2015-09-06 00:40:50 +00:00
|
|
|
function suite.getrelative_ignoresTrailingSlashes()
|
2017-04-25 17:15:33 +00:00
|
|
|
test.isequal("c", path.getrelative("/a/b/","/a/b/c"))
|
2015-09-06 00:40:50 +00:00
|
|
|
end
|
2013-10-22 20:32:51 +00:00
|
|
|
|
2015-09-06 00:40:50 +00:00
|
|
|
function suite.getrelative_returnsAbsPath_onContactWithFileSysRoot()
|
|
|
|
test.isequal("C:/Boost/Include", path.getrelative("C:/Code/MyApp", "C:/Boost/Include"))
|
|
|
|
end
|
2013-12-20 20:08:05 +00:00
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- path.isabsolute() tests
|
|
|
|
--
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.isabsolute_ReturnsTrue_OnAbsolutePosixPath()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.istrue(path.isabsolute("/a/b/c"))
|
|
|
|
end
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.isabsolute_ReturnsTrue_OnAbsoluteWindowsPathWithDrive()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.istrue(path.isabsolute("C:/a/b/c"))
|
|
|
|
end
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.isabsolute_ReturnsFalse_OnRelativePath()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isfalse(path.isabsolute("a/b/c"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2016-02-05 21:15:01 +00:00
|
|
|
function suite.isabsolute_ReturnsTrue_OnDollarToken()
|
2009-11-25 19:40:23 +00:00
|
|
|
test.istrue(path.isabsolute("$(SDK_HOME)/include"))
|
|
|
|
end
|
2008-10-31 18:38:05 +00:00
|
|
|
|
2016-03-07 21:35:56 +00:00
|
|
|
function suite.isabsolute_ReturnsTrue_OnDotInDollarToken()
|
|
|
|
test.istrue(path.isabsolute("$(configuration.libs)/include"))
|
|
|
|
end
|
|
|
|
|
2016-02-05 21:15:01 +00:00
|
|
|
function suite.isabsolute_ReturnsTrue_OnJustADollarSign()
|
|
|
|
test.istrue(path.isabsolute("$foo/include"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.isabsolute_ReturnsFalse_OnIncompleteDollarToken()
|
|
|
|
test.isfalse(path.isabsolute("$(foo/include"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.isabsolute_ReturnsTrue_OnEnvVar()
|
|
|
|
test.istrue(path.isabsolute("%FOO%/include"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.isabsolute_ReturnsFalse_OnEmptyEnvVar()
|
|
|
|
test.isfalse(path.isabsolute("%%/include"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.isabsolute_ReturnsFalse_OnToken()
|
|
|
|
test.isfalse(path.isabsolute("%{foo}/include"))
|
|
|
|
end
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- path.join() tests
|
|
|
|
--
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.join_OnValidParts()
|
2012-01-19 20:28:24 +00:00
|
|
|
test.isequal("p1/p2", path.join("p1", "p2"))
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.join_OnAbsoluteUnixPath()
|
2012-01-19 20:28:24 +00:00
|
|
|
test.isequal("/p2", path.join("p1", "/p2"))
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.join_OnAbsoluteWindowsPath()
|
2012-01-19 20:28:24 +00:00
|
|
|
test.isequal("C:/p2", path.join("p1", "C:/p2"))
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.join_OnCurrentDirectory()
|
2012-01-19 20:28:24 +00:00
|
|
|
test.isequal("p2", path.join(".", "p2"))
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2015-05-19 01:07:05 +00:00
|
|
|
function suite.join_OnBackToBasePath()
|
|
|
|
test.isequal("", path.join("p1/p2/", "../../"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_OnBackToBasePathWithoutFinalSlash()
|
|
|
|
test.isequal("", path.join("p1/p2/", "../.."))
|
|
|
|
end
|
|
|
|
|
2015-08-01 19:10:02 +00:00
|
|
|
function suite.join_OnBothUpTwoFolders()
|
|
|
|
test.isequal("../../../../foo", path.join("../../", "../../foo"))
|
|
|
|
end
|
|
|
|
|
2015-05-19 01:07:05 +00:00
|
|
|
function suite.join_OnUptwoFolders()
|
|
|
|
test.isequal("p1/foo", path.join("p1/p2/p3", "../../foo"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_OnUptoBase()
|
|
|
|
test.isequal("foo", path.join("p1/p2/p3", "../../../foo"))
|
|
|
|
end
|
|
|
|
|
2015-05-26 17:38:48 +00:00
|
|
|
function suite.join_ignoreLeadingDots()
|
|
|
|
test.isequal("p1/p2/foo", path.join("p1/p2", "././foo"))
|
2015-06-08 18:12:17 +00:00
|
|
|
end
|
2015-05-26 17:38:48 +00:00
|
|
|
|
2015-05-19 01:07:05 +00:00
|
|
|
function suite.join_OnUptoParentOfBase()
|
|
|
|
test.isequal("../../p1", path.join("p1/p2/p3/p4/p5/p6/p7/", "../../../../../../../../../p1"))
|
|
|
|
end
|
|
|
|
|
2011-01-18 17:25:43 +00:00
|
|
|
function suite.join_OnNilSecondPart()
|
2012-01-19 20:28:24 +00:00
|
|
|
test.isequal("p1", path.join("p1", nil))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2012-01-19 20:28:24 +00:00
|
|
|
function suite.join_onMoreThanTwoParts()
|
|
|
|
test.isequal("p1/p2/p3", path.join("p1", "p2", "p3"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_removesExtraInternalSlashes()
|
|
|
|
test.isequal("p1/p2", path.join("p1/", "p2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_removesTrailingSlash()
|
|
|
|
test.isequal("p1/p2", path.join("p1", "p2/"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_ignoresNilParts()
|
|
|
|
test.isequal("p2", path.join(nil, "p2", nil))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_ignoresEmptyParts()
|
|
|
|
test.isequal("p2", path.join("", "p2", ""))
|
2011-01-18 17:25:43 +00:00
|
|
|
end
|
|
|
|
|
2013-01-03 16:11:31 +00:00
|
|
|
function suite.join_canJoinBareSlash()
|
|
|
|
test.isequal("/Users", path.join("/", "Users"))
|
|
|
|
end
|
|
|
|
|
2015-05-20 22:15:41 +00:00
|
|
|
function suite.join_keepsLeadingEnvVar()
|
|
|
|
test.isequal("$(ProjectDir)/../../Bin", path.join("$(ProjectDir)", "../../Bin"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_keepsInternalEnvVar()
|
|
|
|
test.isequal("$(ProjectDir)/$(TargetName)/../../Bin", path.join("$(ProjectDir)/$(TargetName)", "../../Bin"))
|
|
|
|
end
|
|
|
|
|
2015-09-06 00:40:50 +00:00
|
|
|
function suite.join_keepsComplexInternalEnvVar()
|
|
|
|
test.isequal("$(ProjectDir)/myobj_$(Arch)/../../Bin", path.join("$(ProjectDir)/myobj_$(Arch)", "../../Bin"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_keepsRecursivePattern()
|
|
|
|
test.isequal("p1/**.lproj/../p2", path.join("p1/**.lproj", "../p2"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_noCombineSingleDot()
|
|
|
|
test.isequal("p1/./../p2", path.join("p1/.", "../p2"))
|
|
|
|
end
|
2015-05-20 22:15:41 +00:00
|
|
|
|
2016-02-05 21:15:01 +00:00
|
|
|
function suite.join_absolute_second_part()
|
|
|
|
test.isequal("$ORIGIN", path.join("foo/bar", "$ORIGIN"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_absolute_second_part1()
|
|
|
|
test.isequal("$(FOO)/bar", path.join("foo/bar", "$(FOO)/bar"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_absolute_second_part2()
|
|
|
|
test.isequal("%ROOT%/foo", path.join("foo/bar", "%ROOT%/foo"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.join_token_in_second_part()
|
|
|
|
test.isequal("foo/bar/%{test}/foo", path.join("foo/bar", "%{test}/foo"))
|
|
|
|
end
|
2009-09-29 19:27:33 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- path.rebase() tests
|
|
|
|
--
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.rebase_WithEndingSlashOnPath()
|
2009-09-29 19:27:33 +00:00
|
|
|
local cwd = os.getcwd()
|
|
|
|
test.isequal("src", path.rebase("../src/", cwd, path.getdirectory(cwd)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-03-29 21:25:22 +00:00
|
|
|
--
|
|
|
|
-- path.replaceextension() tests
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.getabsolute_replaceExtension()
|
|
|
|
test.isequal("/AB.foo", path.replaceextension("/AB.exe","foo"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_replaceExtensionWithDot()
|
|
|
|
test.isequal("/AB.foo", path.replaceextension("/AB.exe",".foo"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_replaceExtensionWithDotMultipleDots()
|
2017-04-25 17:15:33 +00:00
|
|
|
test.isequal("/nunit.framework.foo", path.replaceextension("/nunit.framework.dll",".foo"))
|
2015-03-29 21:25:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_replaceExtensionCompletePath()
|
2017-04-25 17:15:33 +00:00
|
|
|
test.isequal("/nunit/framework/main.foo", path.replaceextension("/nunit/framework/main.cpp",".foo"))
|
2015-03-29 21:25:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_replaceExtensionWithoutExtension()
|
2017-04-25 17:15:33 +00:00
|
|
|
test.isequal("/nunit/framework/main.foo", path.replaceextension("/nunit/framework/main",".foo"))
|
2015-03-29 21:25:22 +00:00
|
|
|
end
|
2016-09-20 15:40:27 +00:00
|
|
|
|
2017-04-25 17:15:33 +00:00
|
|
|
function suite.getabsolute_replaceExtensionWithEmptyString()
|
|
|
|
test.isequal("foo", path.replaceextension("foo.lua",""))
|
2016-03-29 16:54:33 +00:00
|
|
|
end
|
2015-03-29 21:25:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
-- path.translate() tests
|
|
|
|
--
|
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.translate_ReturnsTranslatedPath_OnValidPath()
|
2008-10-31 18:38:05 +00:00
|
|
|
test.isequal("dir/dir/file", path.translate("dir\\dir\\file", "/"))
|
|
|
|
end
|
|
|
|
|
2012-01-25 20:58:21 +00:00
|
|
|
function suite.translate_returnsCorrectSeparator_onMixedPath()
|
|
|
|
local actual = path.translate("dir\\dir/file", "/")
|
|
|
|
test.isequal("dir/dir/file", actual)
|
2008-10-31 18:38:05 +00:00
|
|
|
end
|
2010-02-27 02:00:50 +00:00
|
|
|
|
2015-10-12 12:34:56 +00:00
|
|
|
function suite.translate_ReturnsTargetOSSeparator_Windows()
|
|
|
|
_OPTIONS["os"] = "windows"
|
|
|
|
test.isequal("dir\\dir\\file", path.translate("dir/dir\\file"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.translate_ReturnsTargetOSSeparator_Linux()
|
|
|
|
_OPTIONS["os"] = "linux"
|
|
|
|
test.isequal("dir/dir/file", path.translate("dir/dir\\file"))
|
|
|
|
end
|
|
|
|
|
2010-02-27 02:00:50 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- path.wildcards tests
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.wildcards_MatchesTrailingStar()
|
|
|
|
local p = path.wildcards("**/xcode/*")
|
|
|
|
test.isequal(".*/xcode/[^/]*", p)
|
|
|
|
end
|
|
|
|
|
2010-03-08 14:57:21 +00:00
|
|
|
function suite.wildcards_MatchPlusSign()
|
|
|
|
local patt = path.wildcards("file+name.*")
|
|
|
|
local name = "file+name.c"
|
|
|
|
test.isequal(name, name:match(patt))
|
|
|
|
end
|
2012-01-20 00:14:18 +00:00
|
|
|
|
|
|
|
function suite.wildcards_escapeSpecialChars()
|
|
|
|
test.isequal("%.%-", path.wildcards(".-"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.wildcards_escapeStar()
|
|
|
|
test.isequal("vs[^/]*", path.wildcards("vs*"))
|
|
|
|
end
|
2013-01-03 16:11:31 +00:00
|
|
|
|
2012-01-20 00:14:18 +00:00
|
|
|
function suite.wildcards_escapeStarStar()
|
|
|
|
test.isequal("Images/.*%.bmp", path.wildcards("Images/**.bmp"))
|
|
|
|
end
|
2015-03-25 00:08:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- path.normalize tests
|
|
|
|
--
|
|
|
|
function suite.normalize_Test1()
|
|
|
|
local p = path.normalize("d:/game/../test")
|
|
|
|
test.isequal("d:/test", p)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.normalize_Test2()
|
|
|
|
local p = path.normalize("d:/game/../../test")
|
|
|
|
test.isequal("d:/../test", p)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.normalize_Test3()
|
|
|
|
local p = path.normalize("../../test")
|
|
|
|
test.isequal("../../test", p)
|
|
|
|
end
|
|
|
|
|
2015-04-08 22:01:43 +00:00
|
|
|
function suite.normalize_Test4()
|
|
|
|
local p = path.normalize("../../../test/*.h")
|
|
|
|
test.isequal("../../../test/*.h", p)
|
|
|
|
end
|
2016-01-20 19:06:38 +00:00
|
|
|
|
2015-08-11 22:21:23 +00:00
|
|
|
function suite.normalize_Test5()
|
|
|
|
test.isequal("test", path.normalize("./test"))
|
|
|
|
test.isequal("d:/", path.normalize("d:/"))
|
|
|
|
test.isequal("d:/", path.normalize("d:/./"))
|
|
|
|
local p = path.normalize("d:/game/..")
|
|
|
|
test.isequal("d:/", p)
|
|
|
|
end
|
2015-04-08 22:01:43 +00:00
|
|
|
|
|
|
|
function suite.normalize_trailingDots1()
|
|
|
|
local p = path.normalize("../game/test/..")
|
|
|
|
test.isequal("../game", p)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.normalize_trailingDots2()
|
|
|
|
local p = path.normalize("../game/..")
|
|
|
|
test.isequal("..", p)
|
|
|
|
end
|
|
|
|
|
2015-05-26 17:38:48 +00:00
|
|
|
function suite.normalize_singleDot()
|
2015-06-08 18:12:17 +00:00
|
|
|
local p = path.normalize("../../p1/p2/p3/p4/./a.pb.cc")
|
|
|
|
test.isequal("../../p1/p2/p3/p4/a.pb.cc", p)
|
2015-05-26 17:38:48 +00:00
|
|
|
end
|
|
|
|
|
2018-06-27 17:20:08 +00:00
|
|
|
function suite.normalize_trailingSingleDot()
|
|
|
|
local p = path.normalize("../../p1/p2/p3/p4/./.")
|
|
|
|
test.isequal("../../p1/p2/p3/p4", p)
|
|
|
|
end
|
|
|
|
|
2015-03-25 00:08:37 +00:00
|
|
|
function suite.normalize()
|
|
|
|
test.isequal("d:/ProjectB/bin", path.normalize("d:/ProjectA/../ProjectB/bin"))
|
|
|
|
test.isequal("/ProjectB/bin", path.normalize("/ProjectA/../ProjectB/bin"))
|
2015-06-08 18:12:17 +00:00
|
|
|
end
|
2016-01-20 19:06:38 +00:00
|
|
|
|
2015-08-11 22:21:23 +00:00
|
|
|
function suite.normalize_leadingWhitespaces()
|
|
|
|
test.isequal("d:/game", path.normalize("\t\n d:/game"))
|
|
|
|
end
|
2016-01-20 19:06:38 +00:00
|
|
|
|
2015-08-11 22:21:23 +00:00
|
|
|
function suite.normalize_multPath()
|
|
|
|
test.isequal("../a/b ../c/d", path.normalize("../a/b ../c/d"))
|
|
|
|
test.isequal("d:/test ../a/b", path.normalize("d:/game/../test ../a/b"))
|
|
|
|
test.isequal("d:/game/test ../a/b", path.normalize("d:/game/./test ../a/b"))
|
|
|
|
test.isequal("d:/test ../a/b", path.normalize(" d:/game/../test ../a/b"))
|
|
|
|
test.isequal("d:/game ../a/b", path.normalize(" d:/game ../a/./b"))
|
|
|
|
test.isequal("d:/game ../a/b", path.normalize("d:/game/ ../a/b"))
|
|
|
|
test.isequal("d:/game", path.normalize("d:/game/ "))
|
|
|
|
end
|
2016-09-20 15:40:27 +00:00
|
|
|
|
|
|
|
function suite.normalize_legitimateDots()
|
|
|
|
test.isequal("d:/test/test..test", path.normalize("d:/test/test..test"))
|
|
|
|
test.isequal("d:/test..test/test", path.normalize("d:/test..test/test"))
|
2018-01-07 17:21:55 +00:00
|
|
|
test.isequal("d:/test/.test", path.normalize("d:/test/.test"))
|
|
|
|
test.isequal("d:/.test", path.normalize("d:/test/../.test"))
|
|
|
|
test.isequal("d:/test", path.normalize("d:/test/.test/.."))
|
|
|
|
test.isequal("d:/test/..test", path.normalize("d:/test/..test"))
|
|
|
|
test.isequal("d:/..test", path.normalize("d:/test/../..test"))
|
|
|
|
test.isequal("d:/test", path.normalize("d:/test/..test/.."))
|
|
|
|
test.isequal("d:/test/.test", path.normalize("d:/test/..test/../.test"))
|
|
|
|
test.isequal("d:/test/..test/.test", path.normalize("d:/test/..test/test/../.test"))
|
|
|
|
test.isequal("d:/test", path.normalize("d:/test/..test/../.test/.."))
|
2016-09-20 15:40:27 +00:00
|
|
|
end
|
2018-08-12 13:17:20 +00:00
|
|
|
|
|
|
|
function suite.normalize_serverpath()
|
|
|
|
test.isequal("//myawesomeserver/test", path.normalize("//myawesomeserver/test/"))
|
|
|
|
test.isequal("//myawesomeserver/test", path.normalize("///myawesomeserver/test/"))
|
|
|
|
end
|
2018-10-11 12:21:42 +00:00
|
|
|
|
|
|
|
function suite.normalize_quotedpath()
|
|
|
|
test.isequal("\"../../test/test/\"", path.normalize("\"../../test/test/\""))
|
|
|
|
test.isequal("\"../../test/\"", path.normalize("\"../../test/../test/\""))
|
|
|
|
end
|
2018-11-04 17:01:29 +00:00
|
|
|
|
|
|
|
function suite.normalize_withTokens()
|
|
|
|
-- Premake tokens
|
|
|
|
test.isequal("%{wks.location}../../test", path.normalize("%{wks.location}../../test"))
|
|
|
|
-- Visual Studio var
|
|
|
|
test.isequal("$(SolutionDir)../../test", path.normalize("$(SolutionDir)../../test"))
|
|
|
|
-- Windows env var
|
|
|
|
test.isequal("%APPDATA%../../test", path.normalize("%APPDATA%../../test"))
|
|
|
|
-- Unix env var
|
|
|
|
test.isequal("${HOME}../../test", path.normalize("${HOME}../../test"))
|
|
|
|
|
|
|
|
-- Middle
|
|
|
|
test.isequal("../../${MYVAR}/../test", path.normalize("../../${MYVAR}/../test"))
|
|
|
|
-- End
|
|
|
|
test.isequal("../../test/${MYVAR}", path.normalize("../../test/${MYVAR}"))
|
|
|
|
end
|
2020-02-02 06:30:44 +00:00
|
|
|
|
|
|
|
function suite.normalize_quotedpath_withTokens()
|
|
|
|
-- Premake tokens
|
|
|
|
test.isequal("\"%{wks.location}../../test\"", path.normalize("\"%{wks.location}../../test\""))
|
|
|
|
-- Visual Studio var
|
|
|
|
test.isequal("\"$(SolutionDir)../../test\"", path.normalize("\"$(SolutionDir)../../test\""))
|
|
|
|
-- Windows env var
|
|
|
|
test.isequal("\"%APPDATA%../../test\"", path.normalize("\"%APPDATA%../../test\""))
|
|
|
|
-- Unix env var
|
|
|
|
test.isequal("\"${HOME}../../test\"", path.normalize("\"${HOME}../../test\""))
|
|
|
|
|
|
|
|
-- Middle
|
|
|
|
test.isequal("\"../../${MYVAR}/../test\"", path.normalize("\"../../${MYVAR}/../test\""))
|
|
|
|
-- End
|
|
|
|
test.isequal("\"../../test/${MYVAR}\"", path.normalize("\"../../test/${MYVAR}\""))
|
|
|
|
end
|