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
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2013-12-20 20:08:05 +00:00
|
|
|
function suite.getrelative_ignoresTrailingSlashes()
|
2013-10-22 20:32:51 +00:00
|
|
|
test.isequal("c", path.getrelative("/a/b/","/a/b/c"))
|
|
|
|
end
|
|
|
|
|
2013-12-20 20:08:05 +00:00
|
|
|
function suite.getrelative_returnsAbsPath_onContactWithFileSysRoot()
|
|
|
|
test.isequal("C:/Boost/Include", path.getrelative("C:/Code/MyApp", "C:/Boost/Include"))
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
2009-12-08 20:25:35 +00:00
|
|
|
function suite.isabsolute_ReturnsTrue_OnDollarSign()
|
2009-11-25 19:40:23 +00:00
|
|
|
test.istrue(path.isabsolute("$(SDK_HOME)/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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
test.isequal("/nunit.framework.foo", path.replaceextension("/nunit.framework.dll",".foo"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_replaceExtensionCompletePath()
|
|
|
|
test.isequal("/nunit/framework/main.foo", path.replaceextension("/nunit/framework/main.cpp",".foo"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.getabsolute_replaceExtensionWithoutExtension()
|
|
|
|
test.isequal("/nunit/framework/main.foo", path.replaceextension("/nunit/framework/main",".foo"))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- 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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
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
|