Skip to content

[android] Replace URL tests that use hardcoded /tmp #2145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

drodriguez
Copy link
Contributor

@drodriguez drodriguez commented Apr 18, 2019

In Android /tmp doesn't exist, and the temporary directory is normally
/data/local/tmp. It is not a symlink. The tests were mostly working, but
because resolvingSymlinksInPath returns a trailing slash if the
directory actually exists, in Android it was returning without the final
trailing slash in some of the cases.

The changes split the large test into smaller pieces that test one of
the behaviours of resolvingSymlinksInPath, and tries not to use the
temporarl directory by itself or suppose anything about it.

There are, however, a couple of tests that check behaviours that are
only applicable to Darwin, so those tests are only performed in Darwin
platforms.

@drodriguez drodriguez force-pushed the android-fix-url-symlink-tests branch from 3cebf23 to c49f9fa Compare April 23, 2019 00:06
@drodriguez drodriguez changed the title [android] Fix URL tests that use hardcoded /tmp [android] Replace URL tests that use hardcoded /tmp Apr 23, 2019
@drodriguez
Copy link
Contributor Author

Replaced the test implementation for smaller tests testing each of the parts of resolvingSymlinksInPath. I’m building macOS still, but the test pass in Linux and Android.

From my understanding, even in Windows, the URL path separator is still /, so I think the tests should work unchanged in Windows, but maybe the symlink test has to be disabled.

@drodriguez drodriguez force-pushed the android-fix-url-symlink-tests branch from c49f9fa to f3b0874 Compare April 23, 2019 01:12
@drodriguez
Copy link
Contributor Author

Small fix for macOS (a problem using temporary directory with unexisting paths not removing the /private part). Should be ready to review and tests.

@spevans
Copy link
Contributor

spevans commented Apr 24, 2019

@swift-ci test

@drodriguez
Copy link
Contributor Author

I’m puzzled. From reading https://ci.swift.org/view/Pull%20Request/job/swift-corelibs-foundation-PR-Linux/2672/console (which seems to be the tests for this PR), it seems to have tested the previous version (c49f9fa) instead of the last version (f3b0874).

@spevans
Copy link
Contributor

spevans commented Apr 24, 2019

@swift-ci test

@drodriguez drodriguez force-pushed the android-fix-url-symlink-tests branch from f3b0874 to 2164780 Compare May 7, 2019 19:59
@drodriguez
Copy link
Contributor Author

@swift-ci please test

@drodriguez
Copy link
Contributor Author

Has anyone any more feedback about these changes? Otherwise it would be great to merge. Thanks.

@drodriguez drodriguez force-pushed the android-fix-url-symlink-tests branch from 2164780 to 5aa745c Compare May 14, 2019 21:25
@drodriguez
Copy link
Contributor Author

Ready for review. Rebased with master and removed the conflicts with the recent changes for Windows.

@swift-ci please test

@drodriguez drodriguez requested a review from compnerd May 16, 2019 19:55
@drodriguez drodriguez force-pushed the android-fix-url-symlink-tests branch from 5aa745c to cf156ed Compare July 9, 2019 00:16
@drodriguez
Copy link
Contributor Author

Rebased on top of a more current master and check it still works on Linux and Android.

@spevans, @millenomi, @compnerd: Does someone has something to say in favor or against this PR? I would love to get it merged to improve the Android support.

@swift-ci please test Linux platform

@drodriguez drodriguez force-pushed the android-fix-url-symlink-tests branch from cf156ed to 015e4a2 Compare July 9, 2019 20:32
@drodriguez
Copy link
Contributor Author

@swift-ci please test Linux platform

In Android /tmp doesn't exist, and the temporary directory is normally
/data/local/tmp. It is not a symlink. The tests were mostly working, but
because `resolvingSymlinksInPath` returns a trailing slash if the
directory actually exists, in Android it was returning without the final
trailing slash in some of the cases.

The changes split the large test into smaller pieces that test one of
the behaviours of `resolvingSymlinksInPath`, and tries not to use the
temporarl directory by itself or suppose anything about it.

There are, however, a couple of tests that check behaviours that are
only applicable to Darwin, so those tests are only performed in Darwin
platforms.
@drodriguez drodriguez force-pushed the android-fix-url-symlink-tests branch from 015e4a2 to d5185bf Compare August 28, 2019 20:12
@drodriguez
Copy link
Contributor Author

@swift-ci please test

@drodriguez
Copy link
Contributor Author

Rebased and removed the couple of unwrapped that were in the diff. Ready for reviewing. This removes the last two failures in Android that are not caused by external libraries. Yay!

@finagolfin
Copy link
Member

Can we finally get this in? I tried it when compiling master natively on Android and it gets all the tests working, along with this small tweak:

diff --git a/TestFoundation/TestURL.swift b/TestFoundation/TestURL.swift
index 21f9ca88..e6239bde 100644
--- a/TestFoundation/TestURL.swift
+++ b/TestFoundation/TestURL.swift
@@ -324,7 +324,7 @@ class TestURL : XCTestCase {
             }
         }
 
-        #if os(Android)
+        #if os(Linux)
         FileManager.default.changeCurrentDirectoryPath("/data/local/tmp")
         #endif
 

I know everyone is on winter break now, but would be good to finally get this in next month.

@finagolfin
Copy link
Member

This pull needs to be rebased. It fixes the last remaining failing test when compiling and running TestFoundation natively on an Android host.

@drodriguez
Copy link
Contributor Author

I was waiting for some reviewer accepting the changes (/cc @millenomi, @spevans, @compnerd). I might try to rebase during the weekend, but I cannot longer work as much as before. You are free to copy this changes, rebase them, and open another if you want to take over.

@finagolfin
Copy link
Member

Did what you suggested, this is in now, can be closed.

@drodriguez drodriguez closed this Feb 14, 2020
@drodriguez drodriguez deleted the android-fix-url-symlink-tests branch February 14, 2020 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants