diff options
author | starkos <none@none> | 2009-12-08 23:25:35 +0300 |
---|---|---|
committer | starkos <none@none> | 2009-12-08 23:25:35 +0300 |
commit | 260053298ed9e5cbc62cd8f9b1ae555f9c3ecc79 (patch) | |
tree | c8dd3d163b93931d2c7bcc2ffd8e6246f703956e /tests/base | |
parent | 0c0ded1df53fb51c03bd932ff1a6db9faa289a31 (diff) |
Bug 2903430: Using relative instead of absolute paths with $() macro
Diffstat (limited to 'tests/base')
-rw-r--r-- | tests/base/test_path.lua | 67 |
1 files changed, 36 insertions, 31 deletions
diff --git a/tests/base/test_path.lua b/tests/base/test_path.lua index 75edc7f..fc592cf 100644 --- a/tests/base/test_path.lua +++ b/tests/base/test_path.lua @@ -5,26 +5,27 @@ -- T.path = { } + local suite = T.path -- -- path.getabsolute() tests -- - function T.path.getabsolute_ReturnsCorrectPath_OnMissingSubdir() + function suite.getabsolute_ReturnsCorrectPath_OnMissingSubdir() local expected = path.translate(os.getcwd(), "/") .. "/a/b/c" test.isequal(expected, path.getabsolute("a/b/c")) end - function T.path.getabsolute_RemovesDotDots_OnWindowsAbsolute() + function suite.getabsolute_RemovesDotDots_OnWindowsAbsolute() test.isequal("c:/ProjectB/bin", path.getabsolute("c:/ProjectA/../ProjectB/bin")) end - function T.path.getabsolute_RemovesDotDots_OnPosixAbsolute() + function suite.getabsolute_RemovesDotDots_OnPosixAbsolute() test.isequal("/ProjectB/bin", path.getabsolute("/ProjectA/../ProjectB/bin")) end - function T.path.getabsolute_OnTrailingSlash() + function suite.getabsolute_OnTrailingSlash() local expected = path.translate(os.getcwd(), "/") .. "/a/b/c" test.isequal(expected, path.getabsolute("a/b/c/")) end @@ -34,7 +35,7 @@ -- path.getbasename() tests -- - function T.path.getbasename_ReturnsCorrectName_OnDirAndExtension() + function suite.getbasename_ReturnsCorrectName_OnDirAndExtension() test.isequal("filename", path.getbasename("folder/filename.ext")) end @@ -43,19 +44,19 @@ -- path.getdirectory() tests -- - function T.path.getdirectory_ReturnsEmptyString_OnNoDirectory() + function suite.getdirectory_ReturnsEmptyString_OnNoDirectory() test.isequal(".", path.getdirectory("filename.ext")) end - function T.path.getdirectory_ReturnsDirectory_OnSingleLevelPath() + function suite.getdirectory_ReturnsDirectory_OnSingleLevelPath() test.isequal("dir0", path.getdirectory("dir0/filename.ext")) end - function T.path.getdirectory_ReturnsDirectory_OnMultiLeveLPath() + function suite.getdirectory_ReturnsDirectory_OnMultiLeveLPath() test.isequal("dir0/dir1/dir2", path.getdirectory("dir0/dir1/dir2/filename.ext")) end - function T.path.getdirectory_ReturnsRootPath_OnRootPathOnly() + function suite.getdirectory_ReturnsRootPath_OnRootPathOnly() test.isequal("/", path.getdirectory("/filename.ext")) end @@ -65,11 +66,11 @@ -- path.getdrive() tests -- - function T.path.getdrive_ReturnsNil_OnNotWindows() + function suite.getdrive_ReturnsNil_OnNotWindows() test.isnil(path.getdrive("/hello")) end - function T.path.getdrive_ReturnsLetter_OnWindowsAbsolute() + function suite.getdrive_ReturnsLetter_OnWindowsAbsolute() test.isequal("x", path.getdrive("x:/hello")) end @@ -79,15 +80,15 @@ -- path.getextension() tests -- - function T.path.getextension_ReturnsEmptyString_OnNoExtension() + function suite.getextension_ReturnsEmptyString_OnNoExtension() test.isequal("", path.getextension("filename")) end - function T.path.getextension_ReturnsExtension() + function suite.getextension_ReturnsExtension() test.isequal(".txt", path.getextension("filename.txt")) end - function T.path.getextension_OnMultipleDots() + function suite.getextension_OnMultipleDots() test.isequal(".txt", path.getextension("filename.mod.txt")) end @@ -96,49 +97,53 @@ -- path.getrelative() tests -- - function T.path.getrelative_ReturnsDot_OnMatchingPaths() + function suite.getrelative_ReturnsDot_OnMatchingPaths() test.isequal(".", path.getrelative("/a/b/c", "/a/b/c")) end - function T.path.getrelative_ReturnsDoubleDot_OnChildToParent() + function suite.getrelative_ReturnsDoubleDot_OnChildToParent() test.isequal("..", path.getrelative("/a/b/c", "/a/b")) end - function T.path.getrelative_ReturnsDoubleDot_OnSiblingToSibling() + function suite.getrelative_ReturnsDoubleDot_OnSiblingToSibling() test.isequal("../d", path.getrelative("/a/b/c", "/a/b/d")) end - function T.path.getrelative_ReturnsChildPath_OnParentToChild() + function suite.getrelative_ReturnsChildPath_OnParentToChild() test.isequal("d", path.getrelative("/a/b/c", "/a/b/c/d")) 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")) end - function T.path.getrelative_ReturnsAbsPath_OnDifferentDriveLetters() + function suite.getrelative_ReturnsAbsPath_OnDifferentDriveLetters() test.isequal("D:/Files", path.getrelative("C:/Code/Premake4", "D:/Files")) end + function suite.getrelative_ReturnsAbsPath_OnDollarMacro() + test.isequal("$(SDK_HOME)/include", path.getrelative("C:/Code/Premake4", "$(SDK_HOME)/include")) + end + -- -- path.isabsolute() tests -- - function T.path.isabsolute_ReturnsTrue_OnAbsolutePosixPath() + function suite.isabsolute_ReturnsTrue_OnAbsolutePosixPath() test.istrue(path.isabsolute("/a/b/c")) end - function T.path.isabsolute_ReturnsTrue_OnAbsoluteWindowsPathWithDrive() + function suite.isabsolute_ReturnsTrue_OnAbsoluteWindowsPathWithDrive() test.istrue(path.isabsolute("C:/a/b/c")) end - function T.path.isabsolute_ReturnsFalse_OnRelativePath() + function suite.isabsolute_ReturnsFalse_OnRelativePath() test.isfalse(path.isabsolute("a/b/c")) end - function T.path.isabsolute_ReturnsTrue_OnDollarSign() + function suite.isabsolute_ReturnsTrue_OnDollarSign() test.istrue(path.isabsolute("$(SDK_HOME)/include")) end @@ -147,19 +152,19 @@ -- path.join() tests -- - function T.path.join_OnValidParts() + function suite.join_OnValidParts() test.isequal("leading/trailing", path.join("leading", "trailing")) end - function T.path.join_OnAbsoluteUnixPath() + function suite.join_OnAbsoluteUnixPath() test.isequal("/trailing", path.join("leading", "/trailing")) end - function T.path.join_OnAbsoluteWindowsPath() + function suite.join_OnAbsoluteWindowsPath() test.isequal("C:/trailing", path.join("leading", "C:/trailing")) end - function T.path.join_OnCurrentDirectory() + function suite.join_OnCurrentDirectory() test.isequal("trailing", path.join(".", "trailing")) end @@ -168,7 +173,7 @@ -- path.rebase() tests -- - function T.path.rebase_WithEndingSlashOnPath() + function suite.rebase_WithEndingSlashOnPath() local cwd = os.getcwd() test.isequal("src", path.rebase("../src/", cwd, path.getdirectory(cwd))) end @@ -178,11 +183,11 @@ -- path.translate() tests -- - function T.path.translate_ReturnsTranslatedPath_OnValidPath() + function suite.translate_ReturnsTranslatedPath_OnValidPath() test.isequal("dir/dir/file", path.translate("dir\\dir\\file", "/")) end - function T.path.translate_ReturnsCorrectSeparator_OnMixedPath() + function suite.translate_ReturnsCorrectSeparator_OnMixedPath() local actual = path.translate("dir\\dir/file") if (os.is("windows")) then test.isequal("dir\\dir\\file", actual) |