@@ -45,4 +45,48 @@ class ResourcesTests: XCTestCase {
4545 """ )
4646 }
4747 }
48+
49+ func testMovedBinaryResources( ) {
50+ fixture ( name: " Resources/Moved " ) { prefix in
51+ var executables = [ " SwiftyResource " ]
52+
53+ // Objective-C module requires macOS
54+ #if os(macOS)
55+ executables. append ( " SeaResource " )
56+ #endif
57+
58+ // Both executables are built in one go since
59+ // adding "--target execName" will not produce a binary
60+ _ = try executeSwiftBuild ( prefix, configuration: . Release)
61+
62+ let binPath = try AbsolutePath (
63+ executeSwiftBuild ( prefix, configuration: . Release, extraArgs: [ " --show-bin-path " ] ) . stdout
64+ . trimmingCharacters ( in: . whitespacesAndNewlines)
65+ )
66+
67+ for execName in executables {
68+ try withTemporaryDirectory ( prefix: execName) { tmpDirPath in
69+ defer {
70+ // Unblock and remove the tmp dir on deinit.
71+ try ? localFileSystem. chmod ( . userWritable, path: tmpDirPath, options: [ . recursive] )
72+ try ? localFileSystem. removeFileTree ( tmpDirPath)
73+ }
74+
75+ let destBinPath = tmpDirPath. appending ( component: execName)
76+ // Copy the binary
77+ try systemQuietly ( " cp " , " -R " , " -H " ,
78+ binPath. appending ( component: execName) . pathString,
79+ destBinPath. pathString)
80+ // Copy the resources
81+ try Process . checkNonZeroExit ( args: " find " , binPath. pathString, " ( " , " -name " , " *.bundle " , " -or " , " -name " , " *.resources " , " ) " )
82+ . split ( whereSeparator: { $0. isNewline } )
83+ . filter { !$0. isEmpty }
84+ . forEach { try systemQuietly ( " cp " , " -R " , " -H " , String ( $0) , tmpDirPath. pathString) }
85+ // Run the binary
86+ let output = try Process . checkNonZeroExit ( args: destBinPath. pathString)
87+ XCTAssertTrue ( output. contains ( " foo " ) )
88+ }
89+ }
90+ }
91+ }
4892}
0 commit comments