Bug 2903430: Using relative instead of absolute paths with $() macro

This commit is contained in:
starkos 2009-12-08 20:25:35 +00:00
parent b51c75e70d
commit 6a323fc263
5 changed files with 45 additions and 33 deletions

View File

@ -8,6 +8,7 @@
- Clean action now removes MonoDevelop .pidb files correctly - Clean action now removes MonoDevelop .pidb files correctly
- Added os.executef() - Added os.executef()
- Bug 2909463: Fix Xcode handling of Obj-C++ .mm files - Bug 2909463: Fix Xcode handling of Obj-C++ .mm files
- Bug 2903430: Using relative instead of absolute paths with $() macro
------- -------

View File

@ -34,7 +34,7 @@
files files
{ {
"src/**.h", "src/**.c", "**.lua", "*.txt", "**.lua", "src/**.h", "src/**.c",
} }
excludes excludes

View File

@ -129,6 +129,12 @@
return dst return dst
end end
-- dollar macro? Can't tell what the real path is; use absolute
-- This enables paths like $(SDK_ROOT)/include to work correctly.
if dst:startswith("$") then
return dst
end
src = src .. "/" src = src .. "/"
dst = dst .. "/" dst = dst .. "/"

View File

@ -5,26 +5,27 @@
-- --
T.path = { } T.path = { }
local suite = T.path
-- --
-- path.getabsolute() tests -- path.getabsolute() tests
-- --
function T.path.getabsolute_ReturnsCorrectPath_OnMissingSubdir() function suite.getabsolute_ReturnsCorrectPath_OnMissingSubdir()
local expected = path.translate(os.getcwd(), "/") .. "/a/b/c" local expected = path.translate(os.getcwd(), "/") .. "/a/b/c"
test.isequal(expected, path.getabsolute("a/b/c")) test.isequal(expected, path.getabsolute("a/b/c"))
end end
function T.path.getabsolute_RemovesDotDots_OnWindowsAbsolute() function suite.getabsolute_RemovesDotDots_OnWindowsAbsolute()
test.isequal("c:/ProjectB/bin", path.getabsolute("c:/ProjectA/../ProjectB/bin")) test.isequal("c:/ProjectB/bin", path.getabsolute("c:/ProjectA/../ProjectB/bin"))
end end
function T.path.getabsolute_RemovesDotDots_OnPosixAbsolute() function suite.getabsolute_RemovesDotDots_OnPosixAbsolute()
test.isequal("/ProjectB/bin", path.getabsolute("/ProjectA/../ProjectB/bin")) test.isequal("/ProjectB/bin", path.getabsolute("/ProjectA/../ProjectB/bin"))
end end
function T.path.getabsolute_OnTrailingSlash() function suite.getabsolute_OnTrailingSlash()
local expected = path.translate(os.getcwd(), "/") .. "/a/b/c" local expected = path.translate(os.getcwd(), "/") .. "/a/b/c"
test.isequal(expected, path.getabsolute("a/b/c/")) test.isequal(expected, path.getabsolute("a/b/c/"))
end end
@ -34,7 +35,7 @@
-- path.getbasename() tests -- path.getbasename() tests
-- --
function T.path.getbasename_ReturnsCorrectName_OnDirAndExtension() function suite.getbasename_ReturnsCorrectName_OnDirAndExtension()
test.isequal("filename", path.getbasename("folder/filename.ext")) test.isequal("filename", path.getbasename("folder/filename.ext"))
end end
@ -43,19 +44,19 @@
-- path.getdirectory() tests -- path.getdirectory() tests
-- --
function T.path.getdirectory_ReturnsEmptyString_OnNoDirectory() function suite.getdirectory_ReturnsEmptyString_OnNoDirectory()
test.isequal(".", path.getdirectory("filename.ext")) test.isequal(".", path.getdirectory("filename.ext"))
end end
function T.path.getdirectory_ReturnsDirectory_OnSingleLevelPath() function suite.getdirectory_ReturnsDirectory_OnSingleLevelPath()
test.isequal("dir0", path.getdirectory("dir0/filename.ext")) test.isequal("dir0", path.getdirectory("dir0/filename.ext"))
end end
function T.path.getdirectory_ReturnsDirectory_OnMultiLeveLPath() function suite.getdirectory_ReturnsDirectory_OnMultiLeveLPath()
test.isequal("dir0/dir1/dir2", path.getdirectory("dir0/dir1/dir2/filename.ext")) test.isequal("dir0/dir1/dir2", path.getdirectory("dir0/dir1/dir2/filename.ext"))
end end
function T.path.getdirectory_ReturnsRootPath_OnRootPathOnly() function suite.getdirectory_ReturnsRootPath_OnRootPathOnly()
test.isequal("/", path.getdirectory("/filename.ext")) test.isequal("/", path.getdirectory("/filename.ext"))
end end
@ -65,11 +66,11 @@
-- path.getdrive() tests -- path.getdrive() tests
-- --
function T.path.getdrive_ReturnsNil_OnNotWindows() function suite.getdrive_ReturnsNil_OnNotWindows()
test.isnil(path.getdrive("/hello")) test.isnil(path.getdrive("/hello"))
end end
function T.path.getdrive_ReturnsLetter_OnWindowsAbsolute() function suite.getdrive_ReturnsLetter_OnWindowsAbsolute()
test.isequal("x", path.getdrive("x:/hello")) test.isequal("x", path.getdrive("x:/hello"))
end end
@ -79,15 +80,15 @@
-- path.getextension() tests -- path.getextension() tests
-- --
function T.path.getextension_ReturnsEmptyString_OnNoExtension() function suite.getextension_ReturnsEmptyString_OnNoExtension()
test.isequal("", path.getextension("filename")) test.isequal("", path.getextension("filename"))
end end
function T.path.getextension_ReturnsExtension() function suite.getextension_ReturnsExtension()
test.isequal(".txt", path.getextension("filename.txt")) test.isequal(".txt", path.getextension("filename.txt"))
end end
function T.path.getextension_OnMultipleDots() function suite.getextension_OnMultipleDots()
test.isequal(".txt", path.getextension("filename.mod.txt")) test.isequal(".txt", path.getextension("filename.mod.txt"))
end end
@ -96,49 +97,53 @@
-- path.getrelative() tests -- path.getrelative() tests
-- --
function T.path.getrelative_ReturnsDot_OnMatchingPaths() function suite.getrelative_ReturnsDot_OnMatchingPaths()
test.isequal(".", path.getrelative("/a/b/c", "/a/b/c")) test.isequal(".", path.getrelative("/a/b/c", "/a/b/c"))
end end
function T.path.getrelative_ReturnsDoubleDot_OnChildToParent() function suite.getrelative_ReturnsDoubleDot_OnChildToParent()
test.isequal("..", path.getrelative("/a/b/c", "/a/b")) test.isequal("..", path.getrelative("/a/b/c", "/a/b"))
end end
function T.path.getrelative_ReturnsDoubleDot_OnSiblingToSibling() function suite.getrelative_ReturnsDoubleDot_OnSiblingToSibling()
test.isequal("../d", path.getrelative("/a/b/c", "/a/b/d")) test.isequal("../d", path.getrelative("/a/b/c", "/a/b/d"))
end end
function T.path.getrelative_ReturnsChildPath_OnParentToChild() function suite.getrelative_ReturnsChildPath_OnParentToChild()
test.isequal("d", path.getrelative("/a/b/c", "/a/b/c/d")) test.isequal("d", path.getrelative("/a/b/c", "/a/b/c/d"))
end end
function T.path.getrelative_ReturnsChildPath_OnWindowsAbsolute() function suite.getrelative_ReturnsChildPath_OnWindowsAbsolute()
test.isequal("obj/debug", path.getrelative("C:/Code/Premake4", "C:/Code/Premake4/obj/debug")) test.isequal("obj/debug", path.getrelative("C:/Code/Premake4", "C:/Code/Premake4/obj/debug"))
end end
function T.path.getrelative_ReturnsAbsPath_OnDifferentDriveLetters() function suite.getrelative_ReturnsAbsPath_OnDifferentDriveLetters()
test.isequal("D:/Files", path.getrelative("C:/Code/Premake4", "D:/Files")) test.isequal("D:/Files", path.getrelative("C:/Code/Premake4", "D:/Files"))
end end
function suite.getrelative_ReturnsAbsPath_OnDollarMacro()
test.isequal("$(SDK_HOME)/include", path.getrelative("C:/Code/Premake4", "$(SDK_HOME)/include"))
end
-- --
-- path.isabsolute() tests -- path.isabsolute() tests
-- --
function T.path.isabsolute_ReturnsTrue_OnAbsolutePosixPath() function suite.isabsolute_ReturnsTrue_OnAbsolutePosixPath()
test.istrue(path.isabsolute("/a/b/c")) test.istrue(path.isabsolute("/a/b/c"))
end end
function T.path.isabsolute_ReturnsTrue_OnAbsoluteWindowsPathWithDrive() function suite.isabsolute_ReturnsTrue_OnAbsoluteWindowsPathWithDrive()
test.istrue(path.isabsolute("C:/a/b/c")) test.istrue(path.isabsolute("C:/a/b/c"))
end end
function T.path.isabsolute_ReturnsFalse_OnRelativePath() function suite.isabsolute_ReturnsFalse_OnRelativePath()
test.isfalse(path.isabsolute("a/b/c")) test.isfalse(path.isabsolute("a/b/c"))
end end
function T.path.isabsolute_ReturnsTrue_OnDollarSign() function suite.isabsolute_ReturnsTrue_OnDollarSign()
test.istrue(path.isabsolute("$(SDK_HOME)/include")) test.istrue(path.isabsolute("$(SDK_HOME)/include"))
end end
@ -147,19 +152,19 @@
-- path.join() tests -- path.join() tests
-- --
function T.path.join_OnValidParts() function suite.join_OnValidParts()
test.isequal("leading/trailing", path.join("leading", "trailing")) test.isequal("leading/trailing", path.join("leading", "trailing"))
end end
function T.path.join_OnAbsoluteUnixPath() function suite.join_OnAbsoluteUnixPath()
test.isequal("/trailing", path.join("leading", "/trailing")) test.isequal("/trailing", path.join("leading", "/trailing"))
end end
function T.path.join_OnAbsoluteWindowsPath() function suite.join_OnAbsoluteWindowsPath()
test.isequal("C:/trailing", path.join("leading", "C:/trailing")) test.isequal("C:/trailing", path.join("leading", "C:/trailing"))
end end
function T.path.join_OnCurrentDirectory() function suite.join_OnCurrentDirectory()
test.isequal("trailing", path.join(".", "trailing")) test.isequal("trailing", path.join(".", "trailing"))
end end
@ -168,7 +173,7 @@
-- path.rebase() tests -- path.rebase() tests
-- --
function T.path.rebase_WithEndingSlashOnPath() function suite.rebase_WithEndingSlashOnPath()
local cwd = os.getcwd() local cwd = os.getcwd()
test.isequal("src", path.rebase("../src/", cwd, path.getdirectory(cwd))) test.isequal("src", path.rebase("../src/", cwd, path.getdirectory(cwd)))
end end
@ -178,11 +183,11 @@
-- path.translate() tests -- path.translate() tests
-- --
function T.path.translate_ReturnsTranslatedPath_OnValidPath() function suite.translate_ReturnsTranslatedPath_OnValidPath()
test.isequal("dir/dir/file", path.translate("dir\\dir\\file", "/")) test.isequal("dir/dir/file", path.translate("dir\\dir\\file", "/"))
end end
function T.path.translate_ReturnsCorrectSeparator_OnMixedPath() function suite.translate_ReturnsCorrectSeparator_OnMixedPath()
local actual = path.translate("dir\\dir/file") local actual = path.translate("dir\\dir/file")
if (os.is("windows")) then if (os.is("windows")) then
test.isequal("dir\\dir\\file", actual) test.isequal("dir\\dir\\file", actual)