Comments (10)
The reason that some of these tests had been skipped in the past is because Foundation on Linux wasn't implemented to either behave the same way or to work at all.
For example, one is because the underlying function used for delete (isDeletableFile(atPath:)
) is (perhaps was) unimplemented:
PathKit/Tests/PathKitTests/PathKitSpec.swift
Line 272 in 870c17f
I am not sure if it is warranted that all of these should still be skipped. It could be that Swift versions since they have been implemented resolved the behaviour inconsistencies on Linux, I just hadn't tested these on Linux in a while.
I believe the only place in PathKit where the actual implementation in PathKit (not counting for how underlying APIs are implemented) is isFSCaseSensitiveAt
, which could be implemented if needed. Just hadn't been a priority for me:
Lines 193 to 197 in 870c17f
from pathkit.
For example, one is because the underlying function used for delete (isDeletableFile(atPath:)) is (perhaps was) unimplemented:
I believe the only place in PathKit where the actual implementation in PathKit (not counting for how underlying APIs are implemented) is isFSCaseSensitiveAt, which could be implemented if needed. Just hadn't been a priority for me:
I'm not sure if I understand what you mean. You mean that it could be implemented in PathKit
itself even though the usually necessary function may not be available?
(I looked it up and indeed, resourceValues(forKeys: )
is also not implemented)
from pathkit.
I'm not sure if I understand what you mean. You mean that it could be implemented in PathKit itself even though the usually necessary function may not be available?
I mean, the code for PathKit in is hitting FileManager on all platforms in the same way. So in 99% of the cases the implementation differs due to FileManager implementation in OSS Foundation vs closed Objective-C Foundation.
The one exception is the isFSCaseSensitiveAt
method.
from pathkit.
Btw, I found why these two tests fail:
Sort of.
$0.it("throws an error on failure writing data") {
#if os(Linux)
throw skip()
#else
let path = Path("/")
let data = "Hi".data(using: String.Encoding.utf8, allowLossyConversion: true)
try expect {
try path.write(data!)
}.toThrow()
#endif
}
$0.it("throws an error on failure writing a String") {
#if os(Linux)
throw skip()
#else
let path = Path("/")
try expect {
try path.write("hi")
}.toThrow()
#endif
}
They fail when you call normalize()
in PathKit.swift
. In particular, here:
public func normalize() -> Path {
return Path(NSString(string: self.path).standardizingPath)
}
It's this step the one that fails:
NSString("/").standardizingPath
I tried it in the REPL
for both /
and /.cache
and got this:
1> import Foundation
2> let leString = NSString(string: "/")
leString: Foundation.NSString = {
Foundation.NSObject = {}
_cfinfo = {
info = 1920
pad = 0
}
_storage = "/"
}
3> leString.standardizingPath
Execution interrupted. Enter code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)
Process 12343 stopped
* thread #1, name = 'repl_swift', stop reason = signal SIGILL: illegal instruction operand
frame #0: 0x00007ffff3d0902f libFoundation.so`Foundation.NSString.resolvingSymlinksInPath.getter : Swift.String + 2463
libFoundation.so`Foundation.NSString.resolvingSymlinksInPath.getter : Swift.String:
-> 0x7ffff3d0902f <+2463>: ud2
0x7ffff3d09031 <+2465>: ud2
0x7ffff3d09033 <+2467>: ud2
0x7ffff3d09035 <+2469>: ud2
Target 0: (repl_swift) stopped.
4> let leOtherString = NSString(string: "/.cache")
leOtherString: Foundation.NSString = {
Foundation.NSObject = {}
_cfinfo = {
info = 1920
pad = 0
}
_storage = "/.cache"
}
5> leOtherString.standardizingPath
$R0: String = "/.cache"
It's definitely related to that property. I'm gonna investigate further.
from pathkit.
I think this might be the problem. It would be weird, though, because all other paths seem to work just fine. And they are all NSString
s as far as I can tell.
from pathkit.
I found the bug. I'm gonna file a thing. Here it is:
-
standardizingPath
exists somewhere else. Here, in particular. I think that's the version being used here inPathKit
. -
If we check the implementation and try to run it in the
REPL
:
Welcome to Swift version 4.1 (swift-4.1-RELEASE). Type :help for assistance.
1> import Foundation
2> let leString = NSString(string: "/")
leString: Foundation.NSString = {
Foundation.NSObject = {}
_cfinfo = {
info = 1920
pad = 0
}
_storage = "/"
}
3> leString.expandingTildeInPath
$R0: String = "/"
4> let expanded = leString.expandingTildeInPath
expanded: String = "/"
5> var resolved = expanded._bridgeToObjectiveC()
6.
resolved: Foundation.NSString = {
Foundation.NSObject = {}
_cfinfo = {
info = 1920
pad = 0
}
_storage = "/"
}
6> var resolved = expanded._bridgeToObjectiveC().resolvingSymlinksInPath
resolved: String = {
_core = {
_baseAddress = <extracting data from value failed>
_countAndFlags = <extracting data from value failed>
_owner = <extracting data from value failed>
}
}
Execution interrupted. Enter code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)
Process 15285 stopped
* thread #1, name = 'repl_swift', stop reason = signal SIGILL: illegal instruction operand
frame #0: 0x00007ffff3dbeec3 libFoundation.so`Foundation.NSString.resolvingSymlinksInPath.getter : Swift.String + 2259
libFoundation.so`Foundation.NSString.resolvingSymlinksInPath.getter : Swift.String:
-> 0x7ffff3dbeec3 <+2259>: ud2
0x7ffff3dbeec5 <+2261>: ud2
0x7ffff3dbeec7 <+2263>: ud2
0x7ffff3dbeec9 <+2265>: ud2
Target 0: (repl_swift) stopped.
7>
It works fine with other paths. I'm gonna post it at the Swift JIRA.
I think both tests that use this call on /
should be passing afterwards :)
from pathkit.
Continuation: posted it to JIRA. Currently trying to compile my changes to Foundation in order to confirm my theory and make a PR.
The last 2 tests
For the last 2 tests that fail:
- conforms to SequenceType
- without options
- with options
Without options
Seems to be actually runnable and passing. I'm gonna make a PR soon if that's the case to enable it (I need to clean up my debug prints first).
Is passing. I'm gonna make a PR. Made a PR: #52
With options
It throws this error: Fatal error: Enumeration options not yet implemented is not yet implemented: file Foundation/FileManager.swift, line 637
In the current master
branch of swift-corelibs-foundation
, the NSUnimplemented
line is still there, but a little below. Therefore, this test isn't passable yet.
from pathkit.
Summary
There are 6 tests that are being skipped on non-Darwin platforms.
- Describe:
"symlinking"
, It:"can create a relative symlink in the same directory"
: fails because there's missing functionality in the Linux port. - Describe:
"file info"
, It:"can test if a path is deletable"
: fails becauseisDeletableFile(atPath path: String) -> Bool
is unimplemented. - Describe:
"writing"
, It:"throws an error on failure writing data"
: fails because of SR-7526. - Describe:
"writing"
, It:"throws an error on failure writing a String"
: fails because of SR-7526. - Describe:
"conforms to SequenceType"
, It:"without options"
: passes as of #52. - Describe:
"conforms to SequenceType"
, It:"with options"
: fails becauseFileManager.enumerator(...)
is unimplemented.
I'm gonna forward this to the Foundation team. Some of them were interested in how Open Source libraries are using the framework, so that they can prioritize what pieces will be implemented next. FileManager
and FileHandle
seem to be the most commonly used classes across the board. In fact, even SPM needs it to eventually being able to discover tests without needing the LinuxMain.swift
file.
from pathkit.
Fixed it at apple/swift-corelibs-foundation#1536
from pathkit.
Update on this list: second skipping test may be able to pass soon if all goes well for the writer of that post.
Success there would leave PathKit with only 2 skipping tests on Linux: no.1 (which is missing functionality) and no.6 (which needs another unimplemented Foundation function)
from pathkit.
Related Issues (20)
- Swift 3 support HOT 7
- PathKit wont compile with swift 3.0 snapshot DEVELOPMENT-SNAPSHOT-2016-05-03-a HOT 1
- Swift Package Manager requires Package.swift HOT 2
- Support for Carthage dropped? HOT 6
- Bump the version to 0.7.1 HOT 4
- I want to get the size of the folder, I found this method < Path.filesize >, but I find that the size of the inaccurate, where is the problem HOT 1
- Going from absolute path to relative? HOT 5
- Combining two pathes including step back lead to incorrect path
- New Tag for SPM 4.0 HOT 5
- Glob function issue HOT 4
- Future of Project HOT 3
- Support recursive glob '**' HOT 1
- Why use NSString? HOT 3
- Unable to build with Xcode 13 GM HOT 10
- Xcode 13 compiler error HOT 4
- Glob function on windows HOT 2
- PathKit method calls HOT 1
- It has problem when used in App(not SPM or Terminal)
- How to add text to the last line of a text file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pathkit.