@@ -18,6 +18,7 @@ final class FileIteratorTests: XCTestCase {
18
18
try touch ( " project/.hidden.swift " )
19
19
try touch ( " project/.build/generated.swift " )
20
20
try symlink ( " project/link.swift " , to: " project/.hidden.swift " )
21
+ try symlink ( " project/rellink.swift " , relativeTo: " .hidden.swift " )
21
22
}
22
23
23
24
override func tearDownWithError( ) throws {
@@ -64,7 +65,10 @@ final class FileIteratorTests: XCTestCase {
64
65
// passed to the iterator. This is meant to avoid situations where a symlink could be hidden by
65
66
// shell expansion; for example, if the user writes `swift-format --no-follow-symlinks *`, if
66
67
// the current directory contains a symlink, they would probably *not* expect it to be followed.
67
- let seen = allFilesSeen ( iteratingOver: [ tmpURL ( " project/link.swift " ) ] , followSymlinks: false )
68
+ let seen = allFilesSeen (
69
+ iteratingOver: [ tmpURL ( " project/link.swift " ) , tmpURL ( " project/rellink.swift " ) ] ,
70
+ followSymlinks: false
71
+ )
68
72
XCTAssertTrue ( seen. isEmpty)
69
73
}
70
74
}
@@ -90,14 +94,22 @@ extension FileIteratorTests {
90
94
}
91
95
}
92
96
93
- /// Create a symlink between files or directories in the test's temporary space.
97
+ /// Create a absolute symlink between files or directories in the test's temporary space.
94
98
private func symlink( _ source: String , to target: String ) throws {
95
99
try FileManager . default. createSymbolicLink (
96
100
at: tmpURL ( source) ,
97
101
withDestinationURL: tmpURL ( target)
98
102
)
99
103
}
100
104
105
+ /// Create a relative symlink between files or directories in the test's temporary space.
106
+ private func symlink( _ source: String , relativeTo target: String ) throws {
107
+ try FileManager . default. createSymbolicLink (
108
+ atPath: tmpURL ( source) . path,
109
+ withDestinationPath: target
110
+ )
111
+ }
112
+
101
113
/// Computes the list of all files seen by using `FileIterator` to iterate over the given URLs.
102
114
private func allFilesSeen( iteratingOver urls: [ URL ] , followSymlinks: Bool ) -> [ String ] {
103
115
let iterator = FileIterator ( urls: urls, followSymlinks: followSymlinks)
0 commit comments