File tree Expand file tree Collapse file tree 3 files changed +81
-0
lines changed
Sources/SystemCompatibilityAdaptors
Tests/SystemCompatibilityAdaptorTests Expand file tree Collapse file tree 3 files changed +81
-0
lines changed Original file line number Diff line number Diff line change @@ -135,12 +135,27 @@ let package = Package(
135135 exclude: filesToExclude,
136136 cSettings: cSettings,
137137 swiftSettings: swiftSettings) ,
138+ . target(
139+ name: " SystemCompatibilityAdaptors " ,
140+ dependencies: [ " SystemPackage " ] ,
141+ path: " Sources/SystemCompatibilityAdaptors " ,
142+ exclude: [ ] ,
143+ cSettings: cSettings,
144+ swiftSettings: swiftSettings
145+ ) ,
138146 . testTarget(
139147 name: " SystemTests " ,
140148 dependencies: [ " SystemPackage " ] ,
141149 exclude: testsToExclude,
142150 cSettings: cSettings,
143151 swiftSettings: swiftSettings) ,
152+ . testTarget(
153+ name: " SystemCompatibilityAdaptorTests " ,
154+ dependencies: [ " SystemCompatibilityAdaptors " , " SystemPackage " ] ,
155+ exclude: [ ] ,
156+ cSettings: cSettings,
157+ swiftSettings: swiftSettings
158+ ) ,
144159 ] ,
145160 swiftLanguageVersions: [ . v5]
146161)
Original file line number Diff line number Diff line change 1+ #if canImport(System) && canImport(SystemPackage)
2+ import System
3+ import SystemPackage
4+
5+ @available ( System 0 . 0 . 2 , * )
6+ extension SystemPackage . FilePath {
7+ @available ( System 0 . 0 . 2 , * )
8+ public init ( converting path: System . FilePath ) {
9+ self = path. withPlatformString ( Self . init ( platformString: ) )
10+ }
11+ }
12+
13+ @available ( System 0 . 0 . 2 , * )
14+ extension System . FilePath {
15+ @available ( System 0 . 0 . 2 , * )
16+ public init ( converting path: SystemPackage . FilePath ) {
17+ self = path. withPlatformString ( Self . init ( platformString: ) )
18+ }
19+ }
20+
21+ @available ( System 0 . 0 . 1 , * )
22+ extension SystemPackage . FileDescriptor {
23+ @available ( System 0 . 0 . 1 , * )
24+ public init ( converting descriptor: System . FileDescriptor ) {
25+ self . init ( rawValue: descriptor. rawValue)
26+ }
27+ }
28+
29+ @available ( System 0 . 0 . 1 , * )
30+ extension System . FileDescriptor {
31+ @available ( System 0 . 0 . 1 , * )
32+ public init ( converting descriptor: SystemPackage . FileDescriptor ) {
33+ self . init ( rawValue: descriptor. rawValue)
34+ }
35+ }
36+ #endif // canImport(System) && canImport(SystemPackage)
Original file line number Diff line number Diff line change 1+ #if canImport(System) && canImport(SystemPackage)
2+
3+ import XCTest
4+
5+ import SystemPackage
6+ import System
7+
8+ import SystemCompatibilityAdaptors
9+
10+ final class SystemCompatibilityAdaptorTests : XCTestCase {
11+
12+ func testFilePathAdaptor( ) {
13+ let fp = SystemPackage . FilePath ( " /bar " )
14+
15+ let sfp = System . FilePath ( converting: fp)
16+
17+ // If we had access to the underlying array as API, this would look less silly
18+ XCTAssertEqual ( fp, SystemPackage . FilePath ( converting: sfp) )
19+ }
20+
21+ func testFileDescriptorAdaptor( ) throws {
22+ let fd = try SystemPackage . FileDescriptor. standardInput. duplicate ( )
23+
24+ let sfd : System . FileDescriptor = System . FileDescriptor ( converting: fd)
25+
26+ print ( fd. rawValue)
27+ XCTAssertEqual ( fd. rawValue, sfd. rawValue)
28+ }
29+ }
30+ #endif // canImport(System) && canImport(SystemPackage)
You can’t perform that action at this time.
0 commit comments