Skip to content

Tests: use FileManager instead of cp #4872

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

Merged
merged 1 commit into from
Apr 5, 2023
Merged

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented May 4, 2022

Rather than relying on UNIX semantics of cp which is inherently
platform dependent. This is required to start experimenting with
getting the SPM test suite running on Windows.

@compnerd
Copy link
Member Author

compnerd commented May 4, 2022

@swift-ci please smoke test

@compnerd
Copy link
Member Author

compnerd commented May 5, 2022

@swift-ci please smoke test

@tomerd
Copy link
Contributor

tomerd commented May 5, 2022

+1 conceptually, need to get CI green. also can localFileSystem help?

@compnerd
Copy link
Member Author

compnerd commented May 7, 2022

Hmm, localFileSystem may be able to help. I'll take a look at that, didn't think to look at it tbh.

@compnerd
Copy link
Member Author

compnerd commented May 8, 2022

Ugh, I think that the failure here is due to the -H which follows symbolic links and I believe that the fixtures use those to share data. I need to look into the behaviour of the copy implementation in localFileSystem, otherwise, we might have to do a bit more involved change.

@tomerd
Copy link
Contributor

tomerd commented May 9, 2022

where an API exists (like in this case), we should use localFileSystem instead of FileSystem directly. this allows us to reap the benefit from that abstraction that is used all throughout the code base (not just tests) so has to work on all platforms by definition. in practice localFileSystem uses FileSystemunder the hood, but we can improve that if and when a better API comes along

@compnerd
Copy link
Member Author

@swift-ci please smoke test

@compnerd
Copy link
Member Author

The same problem remains - it wants to de-reference the symbolic links qwhen copying. I'm not sure how to address this portably. I suppose that we can just have two paths for the copying?

@tomerd
Copy link
Contributor

tomerd commented May 16, 2022

I suppose that we can just have two paths for the copying?

you mean windows/non-windows? we could do that, or would add something to Basics that abstracts it and then use it from here. your call

Rather than relying on UNIX semantics of `cp` which is inherently
platform dependent, prefer the abstractions of `LocalFileSystem.
@compnerd
Copy link
Member Author

@swift-ci please smoke test

@tomerd tomerd added the windows label Jun 2, 2022
@compnerd
Copy link
Member Author

compnerd commented Jun 6, 2022

@tomerd - any thing holding this up?

@tomerd
Copy link
Contributor

tomerd commented Jun 6, 2022

@compnerd I think this is fine if urgent, but I would prefer to see use use a FileSystem based API on all platforms, and do the platform specific work at the concrete implementation level, ie. LocalFileSystem can do the the right thing for each platform, and the call sites all use it without being aware to platform differences.

@compnerd
Copy link
Member Author

compnerd commented Jun 6, 2022

I think that the change would be significantly more complex. We would need to re-implement the functionality of -H in cp which currently doesn't exist.

@tomerd
Copy link
Contributor

tomerd commented Jun 6, 2022

@compnerd @abertelrud @neonichu what if we added a new function to FileSystem to copy directory which will take some options including (or starting with) following symlinks? feels a bit more scalable that this

@tomerd
Copy link
Contributor

tomerd commented Jun 6, 2022

@compnerd, another question: how does this even work on Windows with this patch? I think Windows has adopted symlinks on some of its FSs?

@compnerd
Copy link
Member Author

compnerd commented Jun 6, 2022

Yes, I was able to pass the Swift PM test suite with this (and the other remaining patches). The symlink support is really rather flakey and requires a lot of things (including special privileges). Since this is used for the fixtures only, git takes care of the checking out the copy and thus no symbolic links are needed. You cannot simply "copy" a symbolic link.

@compnerd
Copy link
Member Author

compnerd commented Apr 5, 2023

I think that I'm going to merge this for now. We are introducing more regressions in the SPM test suite on Windows, and in order to get stability we need to get the tests passing. This allows us to reduce the number of failures so that we can start looking at the failures and getting things into a stable state.

@compnerd compnerd merged commit 7647f77 into swiftlang:main Apr 5, 2023
@compnerd compnerd deleted the cp branch April 5, 2023 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants