@@ -18,6 +18,7 @@ final class FileIteratorTests: XCTestCase {
1818 try touch ( " project/.hidden.swift " )
1919 try touch ( " project/.build/generated.swift " )
2020 try symlink ( " project/link.swift " , to: " project/.hidden.swift " )
21+ try symlink ( " project/rellink.swift " , relativeTo: " .hidden.swift " )
2122 }
2223
2324 override func tearDownWithError( ) throws {
@@ -64,7 +65,10 @@ final class FileIteratorTests: XCTestCase {
6465 // passed to the iterator. This is meant to avoid situations where a symlink could be hidden by
6566 // shell expansion; for example, if the user writes `swift-format --no-follow-symlinks *`, if
6667 // 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+ )
6872 XCTAssertTrue ( seen. isEmpty)
6973 }
7074}
@@ -90,14 +94,22 @@ extension FileIteratorTests {
9094 }
9195 }
9296
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.
9498 private func symlink( _ source: String , to target: String ) throws {
9599 try FileManager . default. createSymbolicLink (
96100 at: tmpURL ( source) ,
97101 withDestinationURL: tmpURL ( target)
98102 )
99103 }
100104
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+
101113 /// Computes the list of all files seen by using `FileIterator` to iterate over the given URLs.
102114 private func allFilesSeen( iteratingOver urls: [ URL ] , followSymlinks: Bool ) -> [ String ] {
103115 let iterator = FileIterator ( urls: urls, followSymlinks: followSymlinks)
0 commit comments