Skip to content

Commit 6417965

Browse files
committed
[android] Mark link test in TestFileManager as failing for Android.
Implement support for marking test as expected to fail in Android similar to what Windows has already. Use the helper function to mark the tests that were already disabled in Android (there are some others with extra checks that should be done more carefully). Additionally, mark one of the tests of TestFileManager as failing in Android. Android doesn't allow normal programs to use the link syscall, and it always fails with insuficient permissions. The test will never work. Disable the test in Android completely. Users should deal with the always failing API, since errors are always possible for other reason. Also, remove a disabled test in TestURLSession because I cannot make it fail in my setup. It might have fail before, but it not longer fails.
1 parent 6cbc4bb commit 6417965

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

TestFoundation/TestFileManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ VIDEOS=StopgapVideos
17341734
("test_contentsOfDirectoryAtPath", test_contentsOfDirectoryAtPath),
17351735
("test_subpathsOfDirectoryAtPath", test_subpathsOfDirectoryAtPath),
17361736
("test_copyItemAtPathToPath", test_copyItemAtPathToPath),
1737-
("test_linkItemAtPathToPath", test_linkItemAtPathToPath),
1737+
("test_linkItemAtPathToPath", testExpectedToFailOnAndroid(test_linkItemAtPathToPath, "Android doesn't allow hard links")),
17381738
("test_homedirectoryForUser", test_homedirectoryForUser),
17391739
("test_temporaryDirectoryForUser", test_temporaryDirectoryForUser),
17401740
("test_creatingDirectoryWithShortIntermediatePath", test_creatingDirectoryWithShortIntermediatePath),

TestFoundation/TestThread.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,10 @@ class TestThread : XCTestCase {
2525
("test_currentThread", test_currentThread),
2626
("test_threadStart", test_threadStart),
2727
("test_mainThread", test_mainThread),
28+
("test_callStackSymbols", testExpectedToFailOnAndroid(test_callStackSymbols, "Android doesn't support backtraces at the moment.")),
29+
("test_callStackReturnAddresses", testExpectedToFailOnAndroid(test_callStackReturnAddresses, "Android doesn't support backtraces at the moment.")),
2830
]
2931

30-
#if !os(Android)
31-
// Android doesn't support backtraces at the moment.
32-
tests.append(contentsOf: [
33-
("test_callStackSymbols", test_callStackSymbols),
34-
("test_callStackReturnAddresses", test_callStackReturnAddresses),
35-
])
36-
#endif
37-
3832
#if NS_FOUNDATION_ALLOWS_TESTABLE_IMPORT
3933
tests.append(contentsOf: [
4034
("test_threadName", test_threadName),

TestFoundation/TestURLSession.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,6 @@ class TestURLSession : LoopbackServerTest {
313313

314314
// This test is buggy becuase the server could respond before the task is cancelled.
315315
func test_cancelTask() {
316-
#if os(Android)
317-
XCTFail("Intermittent failures on Android")
318-
#else
319316
let urlString = "http://127.0.0.1:\(TestURLSession.serverPort)/Peru"
320317
var urlRequest = URLRequest(url: URL(string: urlString)!)
321318
urlRequest.setValue("2.0", forHTTPHeaderField: "X-Pause")
@@ -324,7 +321,6 @@ class TestURLSession : LoopbackServerTest {
324321
d.run(with: urlRequest)
325322
d.cancel()
326323
waitForExpectations(timeout: 12)
327-
#endif
328324
}
329325

330326
func test_verifyRequestHeaders() {

TestFoundation/Utilities.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,14 @@ func shouldAttemptWindowsXFailTests(_ reason: String) -> Bool {
534534
#endif
535535
}
536536

537+
func shouldAttemptAndroidXFailTests(_ reason: String) -> Bool {
538+
#if os(Android)
539+
return shouldAttemptXFailTests(reason)
540+
#else
541+
return true
542+
#endif
543+
}
544+
537545
func appendTestCaseExpectedToFail<T: XCTestCase>(_ reason: String, _ allTests: [(String, (T) -> () throws -> Void)], into array: inout [XCTestCaseEntry]) {
538546
if shouldAttemptXFailTests(reason) {
539547
array.append(testCase(allTests))
@@ -548,6 +556,10 @@ func testExpectedToFailOnWindows<T>(_ test: @escaping (T) -> () throws -> Void,
548556
testExpectedToFailWithCheck(check: shouldAttemptWindowsXFailTests(_:), test, reason)
549557
}
550558

559+
func testExpectedToFailOnAndroid<T>(_ test: @escaping (T) -> () throws -> Void, _ reason: String) -> (T) -> () throws -> Void {
560+
testExpectedToFailWithCheck(check: shouldAttemptAndroidXFailTests(_:), test, reason)
561+
}
562+
551563
func testExpectedToFailWithCheck<T>(check: (String) -> Bool, _ test: @escaping (T) -> () throws -> Void, _ reason: String) -> (T) -> () throws -> Void {
552564
if check(reason) {
553565
return test

0 commit comments

Comments
 (0)