From 252f0fafbe43fd7c96bcd0ebf295317c8c511d9a Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 25 Sep 2023 14:56:59 +0100 Subject: [PATCH 1/3] Replace remaining uses of `<<<` operator with `.send` --- .../SwiftDriverTests/CachingBuildTests.swift | 29 ++++++++----------- .../ExplicitModuleBuildTests.swift | 17 ++++++----- Tests/SwiftDriverTests/SwiftDriverTests.swift | 10 +++---- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/Tests/SwiftDriverTests/CachingBuildTests.swift b/Tests/SwiftDriverTests/CachingBuildTests.swift index 494c2cda0..53d01b3ac 100644 --- a/Tests/SwiftDriverTests/CachingBuildTests.swift +++ b/Tests/SwiftDriverTests/CachingBuildTests.swift @@ -148,9 +148,7 @@ final class CachingBuildTests: XCTestCase { try withTemporaryDirectory { path in let main = path.appending(component: "testCachingBuildJobs.swift") try localFileSystem.writeFileContents(main) { - $0 <<< "import C;" - $0 <<< "import E;" - $0 <<< "import G;" + $0.send("import C;import E;import G;") } let casPath = path.appending(component: "cas") let swiftModuleInterfacesPath: AbsolutePath = @@ -278,9 +276,7 @@ final class CachingBuildTests: XCTestCase { try withTemporaryDirectory { path in let main = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.swift") try localFileSystem.writeFileContents(main) { - $0 <<< "import C;" - $0 <<< "import E;" - $0 <<< "import G;" + $0.send("import C;import E;import G;") } let swiftModuleInterfacesPath: AbsolutePath = @@ -427,9 +423,7 @@ final class CachingBuildTests: XCTestCase { try localFileSystem.createDirectory(moduleCachePath) let main = path.appending(component: "testCachingBuild.swift") try localFileSystem.writeFileContents(main) { - $0 <<< "import C;" - $0 <<< "import E;" - $0 <<< "import G;" + $0.send("import C;import E;import G;") } let cHeadersPath: AbsolutePath = @@ -477,17 +471,20 @@ final class CachingBuildTests: XCTestCase { let foo = path.appending(component: "foo.swift") let casPath = path.appending(component: "cas") try localFileSystem.writeFileContents(foo) { - $0 <<< "extension Profiler {" - $0 <<< " public static let count: Int = 42" - $0 <<< "}" + $0.send(""" + extension Profiler { + public static let count: Int = 42" + } + """ + ) } let fooHeader = path.appending(component: "foo.h") try localFileSystem.writeFileContents(fooHeader) { - $0 <<< "struct Profiler { void* ptr; };" + $0.send("struct Profiler { void* ptr; };") } let main = path.appending(component: "main.swift") try localFileSystem.writeFileContents(main) { - $0 <<< "import Foo" + $0.send("import Foo") } let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? [] @@ -546,9 +543,7 @@ final class CachingBuildTests: XCTestCase { try withTemporaryDirectory { path in let main = path.appending(component: "testDependencyScanning.swift") try localFileSystem.writeFileContents(main) { - $0 <<< "import C;" - $0 <<< "import E;" - $0 <<< "import G;" + $0.send("import C;import E;import G;") } let cHeadersPath: AbsolutePath = diff --git a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift index f77799d8c..9bf726f55 100644 --- a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift +++ b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift @@ -362,9 +362,7 @@ final class ExplicitModuleBuildTests: XCTestCase { try withTemporaryDirectory { path in let main = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.swift") try localFileSystem.writeFileContents(main) { - $0 <<< "import C;" - $0 <<< "import E;" - $0 <<< "import G;" + $0.send("import C;import E;import G;") } let swiftModuleInterfacesPath: AbsolutePath = @@ -1029,17 +1027,20 @@ final class ExplicitModuleBuildTests: XCTestCase { try localFileSystem.createDirectory(FooInstallPath) let foo = path.appending(component: "foo.swift") try localFileSystem.writeFileContents(foo) { - $0 <<< "extension Profiler {" - $0 <<< " public static let count: Int = 42" - $0 <<< "}" + $0.send(""" + extension Profiler { + public static let count: Int = 42" + } + """ + ) } let fooHeader = path.appending(component: "foo.h") try localFileSystem.writeFileContents(fooHeader) { - $0 <<< "struct Profiler { void* ptr; };" + $0.send("struct Profiler { void* ptr; };") } let main = path.appending(component: "main.swift") try localFileSystem.writeFileContents(main) { - $0 <<< "import Foo" + $0.send("import Foo") } let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? [] diff --git a/Tests/SwiftDriverTests/SwiftDriverTests.swift b/Tests/SwiftDriverTests/SwiftDriverTests.swift index ac29268d3..aa8c1010f 100644 --- a/Tests/SwiftDriverTests/SwiftDriverTests.swift +++ b/Tests/SwiftDriverTests/SwiftDriverTests.swift @@ -2043,8 +2043,7 @@ final class SwiftDriverTests: XCTestCase { do { // Linux shared objects (.so) are not offered to autolink-extract try withTemporaryDirectory { path in - try localFileSystem.writeFileContents( - path.appending(components: "libEmpty.so")) { $0 <<< "/* empty */" } + try localFileSystem.writeFileContents(path.appending(components: "libEmpty.so")) { $0.send("/* empty */") } var driver = try Driver(args: commonArgs + ["-emit-executable", "-target", "x86_64-unknown-linux", "libEmpty.so"], env: env) let plannedJobs = try driver.planBuild() @@ -2197,8 +2196,9 @@ final class SwiftDriverTests: XCTestCase { do { try withTemporaryDirectory { path in - try localFileSystem.writeFileContents( - path.appending(components: "wasi", "static-executable-args.lnk")) { $0 <<< "garbage" } + try localFileSystem.writeFileContents(path.appending(components: "wasi", "static-executable-args.lnk")) { + $0.send("garbage") + } // Wasm executable linking var driver = try Driver(args: commonArgs + ["-emit-executable", "-Ounchecked", "-target", "wasm32-unknown-wasi", @@ -3811,7 +3811,7 @@ final class SwiftDriverTests: XCTestCase { try withTemporaryDirectory { path in let main = path.appending(component: "Foo.swift") try localFileSystem.writeFileContents(main) { - $0 <<< "import Swift" + $0.send("import Swift") } var driver = try Driver(args: ["swiftc", "-explicit-module-build", "-target", "arm64e-apple-ios13.0-macabi", From 6b33a99d88354c0fba365a01bc5e8f8c894f49da Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 25 Sep 2023 15:32:42 +0100 Subject: [PATCH 2/3] Exactly match formatting in `testExplicitModuleBuildEndToEndWithBinaryHeaderDeps` --- Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift index 9bf726f55..80773fce9 100644 --- a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift +++ b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift @@ -1028,8 +1028,8 @@ final class ExplicitModuleBuildTests: XCTestCase { let foo = path.appending(component: "foo.swift") try localFileSystem.writeFileContents(foo) { $0.send(""" - extension Profiler { - public static let count: Int = 42" + extension Profiler {\ + public static let count: Int = 42"\ } """ ) From e96b8b947069d85657bba1700ed669f70d582c5e Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 25 Sep 2023 16:03:54 +0100 Subject: [PATCH 3/3] Match original stream usage in tests exactly --- Tests/SwiftDriverTests/CachingBuildTests.swift | 9 +++------ Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Tests/SwiftDriverTests/CachingBuildTests.swift b/Tests/SwiftDriverTests/CachingBuildTests.swift index 53d01b3ac..e55f9c457 100644 --- a/Tests/SwiftDriverTests/CachingBuildTests.swift +++ b/Tests/SwiftDriverTests/CachingBuildTests.swift @@ -471,12 +471,9 @@ final class CachingBuildTests: XCTestCase { let foo = path.appending(component: "foo.swift") let casPath = path.appending(component: "cas") try localFileSystem.writeFileContents(foo) { - $0.send(""" - extension Profiler { - public static let count: Int = 42" - } - """ - ) + $0.send("extension Profiler {") + $0.send(" public static let count: Int = 42") + $0.send("}") } let fooHeader = path.appending(component: "foo.h") try localFileSystem.writeFileContents(fooHeader) { diff --git a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift index 80773fce9..6a355c28b 100644 --- a/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift +++ b/Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift @@ -1027,12 +1027,9 @@ final class ExplicitModuleBuildTests: XCTestCase { try localFileSystem.createDirectory(FooInstallPath) let foo = path.appending(component: "foo.swift") try localFileSystem.writeFileContents(foo) { - $0.send(""" - extension Profiler {\ - public static let count: Int = 42"\ - } - """ - ) + $0.send("extension Profiler {") + $0.send(" public static let count: Int = 42") + $0.send("}") } let fooHeader = path.appending(component: "foo.h") try localFileSystem.writeFileContents(fooHeader) {