More coverage

Though I can hardly test these functions, at least we can verify they run
without crashing etc.
This commit is contained in:
Max Howell
2019-02-01 10:00:15 -05:00
parent 74074c634f
commit 7f5340bc19
3 changed files with 57 additions and 33 deletions

View File

@@ -11,30 +11,12 @@ public extension Bundle {
/// Returns the path for the shared-frameworks directory in this bundle.
var sharedFrameworks: Path {
var `default`: Path {
#if os(macOS)
return path.join("Contents/Frameworks")
#elseif os(Linux)
return path.join("lib")
#else
return path.join("Frameworks")
#endif
}
return sharedFrameworksPath.flatMap(Path.init) ?? `default`
return sharedFrameworksPath.flatMap(Path.init) ?? defaultSharedFrameworksPath
}
/// Returns the path for the resources directory in this bundle.
var resources: Path {
var `default`: Path {
#if os(macOS)
return path.join("Contents/Resources")
#elseif os(Linux)
return path.join("share")
#else
return path
#endif
}
return resourcePath.flatMap(Path.init) ?? `default`
return resourcePath.flatMap(Path.init) ?? defaultResourcesPath
}
/// Returns the path for this bundle.
@@ -107,3 +89,25 @@ public extension FileHandle {
try self.init(forUpdating: path.url)
}
}
internal extension Bundle {
var defaultSharedFrameworksPath: Path {
#if os(macOS)
return path.join("Contents/Frameworks")
#elseif os(Linux)
return path.join("lib")
#else
return path.join("Frameworks")
#endif
}
var defaultResourcesPath: Path {
#if os(macOS)
return path.join("Contents/Resources")
#elseif os(Linux)
return path.join("share")
#else
return path
#endif
}
}