@@ -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 {
@@ -55,7 +56,10 @@ final class FileIteratorTests: XCTestCase {
55
56
// passed to the iterator. This is meant to avoid situations where a symlink could be hidden by
56
57
// shell expansion; for example, if the user writes `swift-format --no-follow-symlinks *`, if
57
58
// the current directory contains a symlink, they would probably *not* expect it to be followed.
58
- let seen = allFilesSeen ( iteratingOver: [ tmpURL ( " project/link.swift " ) ] , followSymlinks: false )
59
+ let seen = allFilesSeen (
60
+ iteratingOver: [ tmpURL ( " project/link.swift " ) , tmpURL ( " project/rellink.swift " ) ] ,
61
+ followSymlinks: false
62
+ )
59
63
XCTAssertTrue ( seen. isEmpty)
60
64
}
61
65
}
@@ -81,14 +85,22 @@ extension FileIteratorTests {
81
85
}
82
86
}
83
87
84
- /// Create a symlink between files or directories in the test's temporary space.
88
+ /// Create a absolute symlink between files or directories in the test's temporary space.
85
89
private func symlink( _ source: String , to target: String ) throws {
86
90
try FileManager . default. createSymbolicLink (
87
91
at: tmpURL ( source) ,
88
92
withDestinationURL: tmpURL ( target)
89
93
)
90
94
}
91
95
96
+ /// Create a relative symlink between files or directories in the test's temporary space.
97
+ private func symlink( _ source: String , relativeTo target: String ) throws {
98
+ try FileManager . default. createSymbolicLink (
99
+ atPath: tmpURL ( source) . path,
100
+ withDestinationPath: target
101
+ )
102
+ }
103
+
92
104
/// Computes the list of all files seen by using `FileIterator` to iterate over the given URLs.
93
105
private func allFilesSeen( iteratingOver urls: [ URL ] , followSymlinks: Bool ) -> [ String ] {
94
106
let iterator = FileIterator ( urls: urls, followSymlinks: followSymlinks)
0 commit comments