Skip to content

Commit 2e6971e

Browse files
authored
Merge pull request #2176 from drodriguez/android-file-manager-tests
[android] Enable tests for FileManager in Android.
2 parents 432d15a + c0d98e3 commit 2e6971e

File tree

3 files changed

+7
-22
lines changed

3 files changed

+7
-22
lines changed

Foundation/FileManager+POSIX.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extension FileManager {
1919
internal func _mountedVolumeURLs(includingResourceValuesForKeys propertyKeys: [URLResourceKey]?, options: VolumeEnumerationOptions = []) -> [URL]? {
2020
var urls: [URL] = []
2121

22-
#if os(Linux)
22+
#if os(Linux) || os(Android)
2323
guard let procMounts = try? String(contentsOfFile: "/proc/mounts", encoding: .utf8) else {
2424
return nil
2525
}

Foundation/FileManager.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -525,16 +525,9 @@ open class FileManager : NSObject {
525525

526526
This method replaces fileSystemAttributesAtPath:.
527527
*/
528-
#if os(Android)
529-
@available(*, unavailable, message: "Unsuppported on this platform")
530-
open func attributesOfFileSystem(forPath path: String) throws -> [FileAttributeKey : Any] {
531-
NSUnsupported()
532-
}
533-
#else
534528
open func attributesOfFileSystem(forPath path: String) throws -> [FileAttributeKey : Any] {
535529
return try _attributesOfFileSystem(forPath: path)
536530
}
537-
#endif
538531

539532
/* createSymbolicLinkAtPath:withDestination:error: returns YES if the symbolic link that point at 'destPath' was able to be created at the location specified by 'path'. If this method returns NO, the link was unable to be created and an NSError will be returned by reference in the 'error' parameter. This method does not traverse a terminal symlink.
540533

TestFoundation/TestFileManager.swift

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ class TestFileManager : XCTestCase {
348348
}
349349

350350
func test_fileSystemAttributes() {
351-
#if !os(Android)
352351
let fm = FileManager.default
353352
let path = NSTemporaryDirectory()
354353

@@ -379,7 +378,6 @@ class TestFileManager : XCTestCase {
379378
} catch {
380379
XCTFail("\(error)")
381380
}
382-
#endif
383381
}
384382

385383
func test_setFileAttributes() {
@@ -1084,7 +1082,7 @@ class TestFileManager : XCTestCase {
10841082
try testCopy()
10851083
}
10861084

1087-
#if !DEPLOYMENT_RUNTIME_OBJC // XDG tests require swift-corelibs-foundation
1085+
#if !DEPLOYMENT_RUNTIME_OBJC && !os(Android) // XDG tests require swift-corelibs-foundation
10881086

10891087
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT // These are white box tests for the internals of XDG parsing:
10901088
func test_xdgStopgapsCoverAllConstants() {
@@ -1201,16 +1199,9 @@ VIDEOS=StopgapVideos
12011199
#endif // NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
12021200

12031201
// This test below is a black box test, and does not require @testable import.
1204-
1205-
enum TestError: Error {
1206-
case notImplementedOnThisPlatform
1207-
}
1208-
1202+
1203+
#if !os(Android)
12091204
func printPathByRunningHelper(withConfiguration config: String, method: String, identifier: String) throws -> String {
1210-
#if os(Android)
1211-
throw TestError.notImplementedOnThisPlatform
1212-
#endif
1213-
12141205
let uuid = UUID().uuidString
12151206
let path = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("org.swift.Foundation.XDGTestHelper").appendingPathComponent(uuid)
12161207
try FileManager.default.createDirectory(at: path, withIntermediateDirectories: true)
@@ -1268,6 +1259,7 @@ VIDEOS=StopgapVideos
12681259
assertFetchingPath(withConfiguration: configuration, identifier: "pictures", yields: "\(prefix)/Pictures")
12691260
assertFetchingPath(withConfiguration: configuration, identifier: "videos", yields: "\(prefix)/Videos")
12701261
}
1262+
#endif // !os(Android)
12711263
#endif // !DEPLOYMENT_RUNTIME_OBJC
12721264

12731265
func test_emptyFilename() {
@@ -1565,15 +1557,15 @@ VIDEOS=StopgapVideos
15651557
("test_displayNames", test_displayNames),
15661558
]
15671559

1568-
#if !DEPLOYMENT_RUNTIME_OBJC && NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
1560+
#if !DEPLOYMENT_RUNTIME_OBJC && NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT && !os(Android)
15691561
tests.append(contentsOf: [
15701562
("test_xdgStopgapsCoverAllConstants", test_xdgStopgapsCoverAllConstants),
15711563
("test_parseXDGConfiguration", test_parseXDGConfiguration),
15721564
("test_xdgURLSelection", test_xdgURLSelection),
15731565
])
15741566
#endif
15751567

1576-
#if !DEPLOYMENT_RUNTIME_OBJC
1568+
#if !DEPLOYMENT_RUNTIME_OBJC && !os(Android)
15771569
tests.append(contentsOf: [
15781570
("test_fetchXDGPathsFromHelper", test_fetchXDGPathsFromHelper),
15791571
])

0 commit comments

Comments
 (0)