From db730380e90f8da130c9fcaf32e7f615975e3f21 Mon Sep 17 00:00:00 2001 From: Colin Marc Date: Mon, 27 Jan 2025 14:18:12 +0100 Subject: [PATCH 1/3] Revert "Support Rust returning `-> Result<_, String>` (#296)" This reverts commit c45a38cf8730013a6a03af2184df0831f523b1a6. --- .../ResultTests.swift | 40 +++------- .../src/generate_core/rust_string.swift | 5 +- .../codegen_tests/result_codegen_tests.rs | 76 ++----------------- crates/swift-integration-tests/src/result.rs | 9 --- 4 files changed, 18 insertions(+), 112 deletions(-) diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift index 5528acd0..058ec2e1 100644 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift +++ b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift @@ -13,30 +13,14 @@ class ResultTests: XCTestCase { rust_func_takes_result_string(.Ok("Success Message")) rust_func_takes_result_string(.Err("Error Message")) } - - /// Verify that we can return a Result from Rust -> Swift. - /// - /// The Err case evidences Swift’s `Error` protocol is implemented correctly - /// for `RustStringRef`, i.e. `extension RustStringRef: Error {}` - func testSwiftCallRustReturnsResultString() throws { - let resultOk = try! rust_func_returns_result_string(true) - XCTAssertEqual(resultOk.toString(), "Success Message") - - do { - let _ = try rust_func_returns_result_string(false) - XCTFail("The function should have returned an error.") - } catch let error as RustString { - XCTAssertEqual(error.toString(), "Error Message") - } - } - + /// Verify that we can pass a Result from Swift -> Rust func testSwiftCallRustResultOpaqueRust() throws { let reflectedOk = try! rust_func_reflect_result_opaque_rust( .Ok(ResultTestOpaqueRustType(111)) ) XCTAssertEqual(reflectedOk.val(), 111) - + do { let _ = try rust_func_reflect_result_opaque_rust( .Err(ResultTestOpaqueRustType(222)) @@ -46,7 +30,7 @@ class ResultTests: XCTestCase { XCTAssertEqual(error.val(), 222) } } - + /// Verify that we can pass a Result from Swift -> Rust func testSwiftCallRustResultOpaqueSwift() throws { rust_func_takes_result_opaque_swift( @@ -80,7 +64,7 @@ class ResultTests: XCTestCase { XCTAssertEqual(error.val(), 222) } } - + /// Verify that we can receive a Result from Rust func testResultOpaqueRustTransparentEnum() throws { XCTContext.runActivity(named: "Should return a ResultTestOpaqueRustType") { @@ -91,7 +75,7 @@ class ResultTests: XCTestCase { XCTFail() } } - + XCTContext.runActivity(named: "Should throw an error") { _ in do { @@ -111,7 +95,7 @@ class ResultTests: XCTestCase { } } } - + /// Verify that we can receive a Result from Rust func testResultTransparentEnumOpaqueRust() throws { XCTContext.runActivity(named: "Should return a ResultTestOpaqueRustType") { @@ -130,7 +114,7 @@ class ResultTests: XCTestCase { XCTFail() } } - + XCTContext.runActivity(named: "Should throw an error") { _ in do { @@ -143,7 +127,7 @@ class ResultTests: XCTestCase { } } } - + /// Verify that we can receive a Result<(), TransparentEnum> from Rust func testResultUnitTypeTransparentEnum() throws { XCTContext.runActivity(named: "Should return a Unit type") { @@ -154,7 +138,7 @@ class ResultTests: XCTestCase { XCTFail() } } - + XCTContext.runActivity(named: "Should throw an error") { _ in do { @@ -174,7 +158,7 @@ class ResultTests: XCTestCase { } } } - + /// Verify that we can receive a Result<(primitive type, OpaqueRustType, String), TransparentEnum> from Rust func testResultTupleTransparentEnum() throws { XCTContext.runActivity(named: "Should return a tuple type") { @@ -188,7 +172,7 @@ class ResultTests: XCTestCase { XCTFail() } } - + XCTContext.runActivity(named: "Should throw an error") { _ in do { @@ -265,7 +249,7 @@ class ResultTests: XCTestCase { XCTAssertEqual(UInt32(i), value.val()) } } - + /// Verify that we can use throwing initializers defined on the Rust side. func testThrowingInitializers() throws { XCTContext.runActivity(named: "Should fail") { diff --git a/crates/swift-bridge-build/src/generate_core/rust_string.swift b/crates/swift-bridge-build/src/generate_core/rust_string.swift index 11d8a55e..bc05257c 100644 --- a/crates/swift-bridge-build/src/generate_core/rust_string.swift +++ b/crates/swift-bridge-build/src/generate_core/rust_string.swift @@ -47,9 +47,6 @@ extension RustStringRef { __swift_bridge__$RustString$trim(ptr) } } -/// exercised in SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift: -/// - see `func testSwiftCallRustReturnsResultString` -extension RustStringRef: Error {} extension RustString: Vectorizable { public static func vecOfSelfNew() -> UnsafeMutableRawPointer { __swift_bridge__$Vec_RustString$new() @@ -97,4 +94,4 @@ extension RustString: Vectorizable { public static func vecOfSelfLen(vecPtr: UnsafeMutableRawPointer) -> UInt { __swift_bridge__$Vec_RustString$len(vecPtr) } -} +} \ No newline at end of file diff --git a/crates/swift-bridge-ir/src/codegen/codegen_tests/result_codegen_tests.rs b/crates/swift-bridge-ir/src/codegen/codegen_tests/result_codegen_tests.rs index 2809697e..35df26b6 100644 --- a/crates/swift-bridge-ir/src/codegen/codegen_tests/result_codegen_tests.rs +++ b/crates/swift-bridge-ir/src/codegen/codegen_tests/result_codegen_tests.rs @@ -4,7 +4,7 @@ use super::{CodegenTest, ExpectedCHeader, ExpectedRustTokens, ExpectedSwiftCode} use proc_macro2::TokenStream; use quote::quote; -/// Test code generation for Rust function that accepts a Result +/// Test code generation for Rust function that accepts and returns a Result /// where T and E are Strings. mod extern_rust_fn_result_string { use super::*; @@ -64,72 +64,6 @@ void __swift_bridge__$some_function(struct __private__ResultPtrAndPtr arg); } } -/// Test code generation for Rust function that returns a Result -/// where T and E are Strings. -mod extern_rust_fn_return_result_string { - use super::*; - - fn bridge_module_tokens() -> TokenStream { - quote! { - mod ffi { - extern "Rust" { - fn some_function() -> Result; - } - } - } - } - - fn expected_rust_tokens() -> ExpectedRustTokens { - ExpectedRustTokens::Contains(quote! { - #[export_name = "__swift_bridge__$some_function"] - pub extern "C" fn __swift_bridge__some_function( - ) -> swift_bridge::result::ResultPtrAndPtr { - match super::some_function() { - Ok(ok) => { - swift_bridge::result::ResultPtrAndPtr { - is_ok: true, - ok_or_err: swift_bridge::string::RustString(ok).box_into_raw() as *mut std::ffi::c_void - } - } - Err(err) => { - swift_bridge::result::ResultPtrAndPtr { - is_ok: false, - ok_or_err: swift_bridge::string::RustString(err).box_into_raw() as *mut std::ffi::c_void - } - } - } - } - }) - } - - fn expected_swift_code() -> ExpectedSwiftCode { - ExpectedSwiftCode::ContainsAfterTrim( - r#" -public func some_function() throws -> RustString { - try { let val = __swift_bridge__$some_function(); if val.is_ok { return RustString(ptr: val.ok_or_err!) } else { throw RustString(ptr: val.ok_or_err!) } }() -} -"#, - ) - } - - const EXPECTED_C_HEADER: ExpectedCHeader = ExpectedCHeader::ExactAfterTrim( - r#" -struct __private__ResultPtrAndPtr __swift_bridge__$some_function(void); - "#, - ); - - #[test] - fn extern_rust_fn_return_result_string() { - CodegenTest { - bridge_module: bridge_module_tokens().into(), - expected_rust_tokens: expected_rust_tokens(), - expected_swift_code: expected_swift_code(), - expected_c_header: EXPECTED_C_HEADER, - } - .test(); - } -} - /// Test code generation for Rust function that accepts a Result where T and E are /// opaque Rust types. mod extern_rust_fn_arg_result_opaque_rust { @@ -515,7 +449,7 @@ public func some_function() throws -> SomeOkType { r#" typedef enum __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum$Tag {__swift_bridge__$ResultSomeOkTypeAndSomeErrEnum$ResultOk, __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum$ResultErr} __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum$Tag; union __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum$Fields {void* ok; struct __swift_bridge__$SomeErrEnum err;}; -typedef struct __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum{__swift_bridge__$ResultSomeOkTypeAndSomeErrEnum$Tag tag; union __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum$Fields payload;} __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum; +typedef struct __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum{__swift_bridge__$ResultSomeOkTypeAndSomeErrEnum$Tag tag; union __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum$Fields payload;} __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum; "#, r#"struct __swift_bridge__$ResultSomeOkTypeAndSomeErrEnum __swift_bridge__$some_function(void)"#, ]) @@ -597,7 +531,7 @@ public func some_function() throws -> SomeOkEnum { r#" typedef enum __swift_bridge__$ResultSomeOkEnumAndSomeErrType$Tag {__swift_bridge__$ResultSomeOkEnumAndSomeErrType$ResultOk, __swift_bridge__$ResultSomeOkEnumAndSomeErrType$ResultErr} __swift_bridge__$ResultSomeOkEnumAndSomeErrType$Tag; union __swift_bridge__$ResultSomeOkEnumAndSomeErrType$Fields {struct __swift_bridge__$SomeOkEnum ok; void* err;}; -typedef struct __swift_bridge__$ResultSomeOkEnumAndSomeErrType{__swift_bridge__$ResultSomeOkEnumAndSomeErrType$Tag tag; union __swift_bridge__$ResultSomeOkEnumAndSomeErrType$Fields payload;} __swift_bridge__$ResultSomeOkEnumAndSomeErrType; +typedef struct __swift_bridge__$ResultSomeOkEnumAndSomeErrType{__swift_bridge__$ResultSomeOkEnumAndSomeErrType$Tag tag; union __swift_bridge__$ResultSomeOkEnumAndSomeErrType$Fields payload;} __swift_bridge__$ResultSomeOkEnumAndSomeErrType; "#, r#"struct __swift_bridge__$ResultSomeOkEnumAndSomeErrType __swift_bridge__$some_function(void)"#, ]) @@ -672,7 +606,7 @@ public func some_function() throws -> () { r#" typedef enum __swift_bridge__$ResultVoidAndSomeErrEnum$Tag {__swift_bridge__$ResultVoidAndSomeErrEnum$ResultOk, __swift_bridge__$ResultVoidAndSomeErrEnum$ResultErr} __swift_bridge__$ResultVoidAndSomeErrEnum$Tag; union __swift_bridge__$ResultVoidAndSomeErrEnum$Fields {struct __swift_bridge__$SomeErrEnum err;}; -typedef struct __swift_bridge__$ResultVoidAndSomeErrEnum{__swift_bridge__$ResultVoidAndSomeErrEnum$Tag tag; union __swift_bridge__$ResultVoidAndSomeErrEnum$Fields payload;} __swift_bridge__$ResultVoidAndSomeErrEnum; +typedef struct __swift_bridge__$ResultVoidAndSomeErrEnum{__swift_bridge__$ResultVoidAndSomeErrEnum$Tag tag; union __swift_bridge__$ResultVoidAndSomeErrEnum$Fields payload;} __swift_bridge__$ResultVoidAndSomeErrEnum; "#, r#"struct __swift_bridge__$ResultVoidAndSomeErrEnum __swift_bridge__$some_function(void)"#, ]) @@ -755,7 +689,7 @@ public func some_function() throws -> (Int32, UInt32) { r#" typedef enum __swift_bridge__$ResultTupleI32U32AndSomeErrEnum$Tag {__swift_bridge__$ResultTupleI32U32AndSomeErrEnum$ResultOk, __swift_bridge__$ResultTupleI32U32AndSomeErrEnum$ResultErr} __swift_bridge__$ResultTupleI32U32AndSomeErrEnum$Tag; union __swift_bridge__$ResultTupleI32U32AndSomeErrEnum$Fields {struct __swift_bridge__$tuple$I32U32 ok; struct __swift_bridge__$SomeErrEnum err;}; -typedef struct __swift_bridge__$ResultTupleI32U32AndSomeErrEnum{__swift_bridge__$ResultTupleI32U32AndSomeErrEnum$Tag tag; union __swift_bridge__$ResultTupleI32U32AndSomeErrEnum$Fields payload;} __swift_bridge__$ResultTupleI32U32AndSomeErrEnum; +typedef struct __swift_bridge__$ResultTupleI32U32AndSomeErrEnum{__swift_bridge__$ResultTupleI32U32AndSomeErrEnum$Tag tag; union __swift_bridge__$ResultTupleI32U32AndSomeErrEnum$Fields payload;} __swift_bridge__$ResultTupleI32U32AndSomeErrEnum; "#, r#"struct __swift_bridge__$ResultTupleI32U32AndSomeErrEnum __swift_bridge__$some_function(void)"#, r#"typedef struct __swift_bridge__$tuple$I32U32 { int32_t _0; uint32_t _1; } __swift_bridge__$tuple$I32U32;"#, diff --git a/crates/swift-integration-tests/src/result.rs b/crates/swift-integration-tests/src/result.rs index c1f45359..a905a048 100644 --- a/crates/swift-integration-tests/src/result.rs +++ b/crates/swift-integration-tests/src/result.rs @@ -10,8 +10,6 @@ mod ffi { ) -> Result; fn rust_func_takes_result_string(arg: Result); - fn rust_func_returns_result_string(ok: bool) -> Result; - fn rust_func_takes_result_opaque_swift( arg: Result, ); @@ -111,13 +109,6 @@ fn rust_func_takes_result_string(arg: Result) { } } -fn rust_func_returns_result_string(ok: bool) -> Result { - if !ok { - return Err("Error Message".to_string()); - } - Ok("Success Message".to_string()) -} - fn rust_func_reflect_result_opaque_rust( arg: Result, ) -> Result { From 5c3d672cb1f40b5ac0eead8adacbde835803aced Mon Sep 17 00:00:00 2001 From: Colin Marc Date: Mon, 27 Jan 2025 14:47:04 +0100 Subject: [PATCH 2/3] Add Sendable to all async return types in tests --- .../SwiftRustIntegrationTestRunner/Result.swift | 10 +++++++--- crates/swift-integration-tests/src/async_function.rs | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Result.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Result.swift index 3549fb6f..12f7f293 100644 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Result.swift +++ b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Result.swift @@ -6,23 +6,25 @@ // func swift_func_takes_callback_with_result_arg( - arg: (RustResult) -> () + arg: (RustResult) -> Void ) { arg(.Ok(CallbackTestOpaqueRustType(555))) } public class ResultTestOpaqueSwiftType { var num: UInt32 - + init(val: UInt32) { self.num = val } - + func val() -> UInt32 { self.num } } +extension AsyncRustFnReturnStruct: @unchecked Sendable {} + extension ResultTestOpaqueRustType: @unchecked Sendable {} extension ResultTestOpaqueRustType: Error {} @@ -41,5 +43,7 @@ extension ResultTransparentStruct: Error {} extension SameEnum: @unchecked Sendable {} extension SameEnum: Error {} +extension AsyncResultOkEnum: @unchecked Sendable {} + extension AsyncResultErrEnum: @unchecked Sendable {} extension AsyncResultErrEnum: Error {} diff --git a/crates/swift-integration-tests/src/async_function.rs b/crates/swift-integration-tests/src/async_function.rs index d70a778b..db429a5e 100644 --- a/crates/swift-integration-tests/src/async_function.rs +++ b/crates/swift-integration-tests/src/async_function.rs @@ -13,7 +13,8 @@ mod ffi { extern "Rust" { async fn rust_async_return_null(); async fn rust_async_reflect_u8(arg: u8) -> u8; - async fn rust_async_reflect_string(string: String) -> String; + // TODO: this is broken because RustString is not Sendable. + // async fn rust_async_reflect_string(string: String) -> String; async fn rust_async_return_struct() -> AsyncRustFnReturnStruct; async fn rust_async_func_reflect_result_opaque_rust( arg: Result, From 5aaf6548a86b224ebd39e5eead5ca15525909364 Mon Sep 17 00:00:00 2001 From: Colin Marc Date: Mon, 27 Jan 2025 00:06:52 +0100 Subject: [PATCH 3/3] Introduce a new SPM-based test harness Using the Swift Package Manager instead of xcode allows for developing on Linux and Windows, and could potentially make life easier. Fixes #306 --- Cargo.toml | 2 - .../Headers/BridgingHeader.h | 14 - .../project.pbxproj | 718 ------------------ .../contents.xcworkspacedata | 7 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../SwiftRustIntegrationTestRunner.xcscheme | 88 --- .../AccentColor.colorset/Contents.json | 11 - .../AppIcon.appiconset/Contents.json | 58 -- .../Assets.xcassets/Contents.json | 6 - .../ContentView.swift | 21 - .../Preview Assets.xcassets/Contents.json | 6 - ...wiftRustIntegrationTestRunner.entitlements | 10 - .../SwiftRustIntegrationTestRunnerApp.swift | 17 - ...RunnerSwiftRustIntegrationTestRunner.swift | 17 - .../ArgumentAttributesTest.swift | 21 - .../AsyncTests.swift | 195 ----- .../CallbackTests.swift | 17 - .../ConditionalCompilationTests.swift | 28 - .../FunctionAttributeGetTests.swift | 30 - .../FunctionAttributeIdentifiableTests.swift | 41 - .../FunctionAttributeTests.swift | 27 - .../GenericTests.rs.swift | 36 - .../OpaqueRustStructTests.swift | 134 ---- .../OpaqueSwiftStructTests.swift | 25 - .../OpaqueTypeAttributeTests.swift | 53 -- .../OptionTests.swift | 230 ------ .../PointerTests.swift | 40 - .../PrimitiveTests.swift | 34 - .../ResultTests.swift | 275 ------- .../RustFnUsesOpaqueSwiftTypeTests.swift | 25 - .../SharedEnumAttributeTests.swift | 46 -- .../SharedEnumTests.swift | 131 ---- .../SharedStructAttributeTests.swift | 38 - .../SharedStructTests.swift | 55 -- ...SingleRepresentationTypeElisionTests.swift | 29 - .../StringTests.swift | 71 -- .../SwiftFnUsesOpaqueRustTypeTests.swift | 25 - .../SwiftFnUsesOpaqueSwiftTypeTests.swift | 28 - .../TupleTests.swift | 43 -- .../VecTests.swift | 133 ---- SwiftRustIntegrationTestRunner/build-rust.sh | 28 - .../Cargo.toml | 10 - .../src/main.rs | 19 - .../.gitignore | 4 - .../Cargo.toml | 16 - .../build.rs | 13 - .../build.sh | 16 - .../src/lib.rs | 18 - .../swift-package-test-package/.gitignore | 7 - .../swift-package-test-package/Package.swift | 23 - .../swift_package_test_package.swift | 1 - .../swift_package_test_packageTests.swift | 17 - crates/swift-integration-tests/build.rs | 4 +- integration-tests/.gitignore | 1 + integration-tests/.swift-format | 10 + integration-tests/Package.swift | 26 + .../Sources}/Generated/.gitignore | 0 integration-tests/Sources/RustLib/bridge.h | 2 + .../Sources/RustLib/module.modulemap | 5 + .../Sources/SharedLib}/ASwiftStack.swift | 0 .../Sources/SharedLib}/Callbacks.swift | 0 .../SharedLib}/FunctionAttributes.swift | 0 .../Sources/SharedLib/Generated/.gitignore | 2 + .../Sources/SharedLib}/Option.swift | 0 .../Sources/SharedLib}/Pointer.swift | 0 .../Sources/SharedLib}/Primitive.swift | 0 .../Sources/SharedLib}/Result.swift | 0 .../RustFnUsesOpaqueSwiftType.swift | 5 +- .../SharedLib}/SharedEnumAttributes.swift | 0 .../Sources/SharedLib}/SharedStruct.swift | 9 +- .../SharedLib}/SharedStructAttributes.swift | 0 .../Sources/SharedLib}/String.swift | 0 .../SwiftFnUsesOpaqueRustType.swift | 0 .../SwiftFnUsesOpaqueSwiftType.swift | 0 .../Sources/SharedLib}/Tuple.swift | 0 .../Sources/SharedLib}/Vec.swift | 0 .../IntegrationTests/PrimitiveTests.swift | 28 + test-swift-rust-integration.sh | 34 +- 78 files changed, 102 insertions(+), 2989 deletions(-) delete mode 100644 SwiftRustIntegrationTestRunner/Headers/BridgingHeader.h delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.pbxproj delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/xcshareddata/xcschemes/SwiftRustIntegrationTestRunner.xcscheme delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/AccentColor.colorset/Contents.json delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/Contents.json delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/ContentView.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Preview Content/Preview Assets.xcassets/Contents.json delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.entitlements delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerApp.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerSwiftRustIntegrationTestRunner.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ArgumentAttributesTest.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/AsyncTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/CallbackTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ConditionalCompilationTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeGetTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeIdentifiableTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/GenericTests.rs.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueRustStructTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueSwiftStructTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueTypeAttributeTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OptionTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/PointerTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/PrimitiveTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/RustFnUsesOpaqueSwiftTypeTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedEnumAttributeTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedEnumTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedStructAttributeTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedStructTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SingleRepresentationTypeElisionTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/StringTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SwiftFnUsesOpaqueRustTypeTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SwiftFnUsesOpaqueSwiftTypeTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/TupleTests.swift delete mode 100644 SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/VecTests.swift delete mode 100755 SwiftRustIntegrationTestRunner/build-rust.sh delete mode 100644 SwiftRustIntegrationTestRunner/integration-test-create-swift-package/Cargo.toml delete mode 100644 SwiftRustIntegrationTestRunner/integration-test-create-swift-package/src/main.rs delete mode 100644 SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/.gitignore delete mode 100644 SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/Cargo.toml delete mode 100644 SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/build.rs delete mode 100755 SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/build.sh delete mode 100644 SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/src/lib.rs delete mode 100644 SwiftRustIntegrationTestRunner/swift-package-test-package/.gitignore delete mode 100644 SwiftRustIntegrationTestRunner/swift-package-test-package/Package.swift delete mode 100644 SwiftRustIntegrationTestRunner/swift-package-test-package/Sources/swift-package-test-package/swift_package_test_package.swift delete mode 100644 SwiftRustIntegrationTestRunner/swift-package-test-package/Tests/swift-package-test-packageTests/swift_package_test_packageTests.swift create mode 100644 integration-tests/.gitignore create mode 100644 integration-tests/.swift-format create mode 100644 integration-tests/Package.swift rename {SwiftRustIntegrationTestRunner => integration-tests/Sources}/Generated/.gitignore (100%) create mode 100644 integration-tests/Sources/RustLib/bridge.h create mode 100644 integration-tests/Sources/RustLib/module.modulemap rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/ASwiftStack.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/Callbacks.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/FunctionAttributes.swift (100%) create mode 100644 integration-tests/Sources/SharedLib/Generated/.gitignore rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/Option.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/Pointer.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/Primitive.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/Result.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/RustFnUsesOpaqueSwiftType.swift (95%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/SharedEnumAttributes.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/SharedStruct.swift (56%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/SharedStructAttributes.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/String.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/SwiftFnUsesOpaqueRustType.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/SwiftFnUsesOpaqueSwiftType.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/Tuple.swift (100%) rename {SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner => integration-tests/Sources/SharedLib}/Vec.swift (100%) create mode 100644 integration-tests/Tests/IntegrationTests/PrimitiveTests.swift diff --git a/Cargo.toml b/Cargo.toml index 9cc81052..313deeea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,8 +33,6 @@ members = [ "crates/swift-bridge-macro", "crates/swift-integration-tests", - "SwiftRustIntegrationTestRunner/integration-test-create-swift-package", - "SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture", "examples/async-functions", "examples/codegen-visualizer", diff --git a/SwiftRustIntegrationTestRunner/Headers/BridgingHeader.h b/SwiftRustIntegrationTestRunner/Headers/BridgingHeader.h deleted file mode 100644 index e4b2be51..00000000 --- a/SwiftRustIntegrationTestRunner/Headers/BridgingHeader.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// BridgingHeader.h -// SwiftRustIntegrationTestRunner -// -// Created by Frankie Nwafili on 11/14/21. -// - -#ifndef BridgingHeader_h -#define BridgingHeader_h - -#include "../Generated/SwiftBridgeCore.h" -#include "../Generated/swift-integration-tests/swift-integration-tests.h" - -#endif /* BridgingHeader_h */ diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.pbxproj b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.pbxproj deleted file mode 100644 index 07afdcc4..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.pbxproj +++ /dev/null @@ -1,718 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 55; - objects = { - -/* Begin PBXBuildFile section */ - 1745111529BE189B00B96A1A /* TupleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1745111429BE189B00B96A1A /* TupleTests.swift */; }; - 1784BE2829CE86D600AE5A4A /* Tuple.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1784BE2729CE86D600AE5A4A /* Tuple.swift */; }; - 178F1CD3298E97FB00335AA0 /* ArgumentAttributesTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 178F1CD2298E97FB00335AA0 /* ArgumentAttributesTest.swift */; }; - 2202BC0827B2DD1700D43CC4 /* SharedEnumTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2202BC0727B2DD1700D43CC4 /* SharedEnumTests.swift */; }; - 22043293274A8FDF00BAE645 /* VecTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22043292274A8FDF00BAE645 /* VecTests.swift */; }; - 22043295274ADA7A00BAE645 /* OptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22043294274ADA7A00BAE645 /* OptionTests.swift */; }; - 22043297274B0AB000BAE645 /* Option.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22043296274B0AB000BAE645 /* Option.swift */; }; - 220432A7274C953E00BAE645 /* PointerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220432A6274C953E00BAE645 /* PointerTests.swift */; }; - 220432A9274D31DC00BAE645 /* Pointer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220432A8274D31DC00BAE645 /* Pointer.swift */; }; - 220432AF274E7BF800BAE645 /* SharedStructTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220432AE274E7BF800BAE645 /* SharedStructTests.swift */; }; - 220432EA2753092C00BAE645 /* RustFnUsesOpaqueSwiftType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220432E92753092C00BAE645 /* RustFnUsesOpaqueSwiftType.swift */; }; - 220432EC27530AFC00BAE645 /* RustFnUsesOpaqueSwiftTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220432EB27530AFC00BAE645 /* RustFnUsesOpaqueSwiftTypeTests.swift */; }; - 22046383282B4E3F00A09119 /* FunctionAttributeGetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22046382282B4E3F00A09119 /* FunctionAttributeGetTests.swift */; }; - 221E16B42786233600F94AC0 /* ConditionalCompilationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 221E16B32786233600F94AC0 /* ConditionalCompilationTests.swift */; }; - 221E16B62786F9FF00F94AC0 /* OpaqueTypeAttributeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 221E16B52786F9FF00F94AC0 /* OpaqueTypeAttributeTests.swift */; }; - 222A81E928EB5BB100D4A412 /* Primitive.swift in Sources */ = {isa = PBXBuildFile; fileRef = 222A81E828EB5BB100D4A412 /* Primitive.swift */; }; - 222A81EB28EB5DF800D4A412 /* PrimitiveTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 222A81EA28EB5DF800D4A412 /* PrimitiveTests.swift */; }; - 22553324281DB5FC008A3121 /* GenericTests.rs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22553323281DB5FC008A3121 /* GenericTests.rs.swift */; }; - 225908FC28DA0E320080C737 /* ResultTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 225908FB28DA0E320080C737 /* ResultTests.swift */; }; - 225908FE28DA0F9F0080C737 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 225908FD28DA0F9F0080C737 /* Result.swift */; }; - 226F944B27BF79B400243D86 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226F944A27BF79B400243D86 /* String.swift */; }; - 2289E82C29A879A7009D89D7 /* SingleRepresentationTypeElisionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2289E82B29A879A7009D89D7 /* SingleRepresentationTypeElisionTests.swift */; }; - 228FE5D52740DB6A00805D9E /* SwiftRustIntegrationTestRunnerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 228FE5D42740DB6A00805D9E /* SwiftRustIntegrationTestRunnerApp.swift */; }; - 228FE5D72740DB6A00805D9E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 228FE5D62740DB6A00805D9E /* ContentView.swift */; }; - 228FE5D92740DB6D00805D9E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 228FE5D82740DB6D00805D9E /* Assets.xcassets */; }; - 228FE5DC2740DB6D00805D9E /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 228FE5DB2740DB6D00805D9E /* Preview Assets.xcassets */; }; - 228FE5E72740DB6D00805D9E /* StringTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 228FE5E62740DB6D00805D9E /* StringTests.swift */; }; - 228FE6062740DCA100805D9E /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 228FE6052740DC9A00805D9E /* libresolv.tbd */; platformFilter = maccatalyst; }; - 228FE60C2740F42000805D9E /* ASwiftStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 228FE60B2740F42000805D9E /* ASwiftStack.swift */; }; - 228FE60E2740F93D00805D9E /* libswift_integration_tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 228FE6032740DC7900805D9E /* libswift_integration_tests.a */; }; - 228FE61027416C0300805D9E /* OpaqueRustStructTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 228FE60F27416C0300805D9E /* OpaqueRustStructTests.swift */; }; - 228FE61227428A8D00805D9E /* OpaqueSwiftStructTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 228FE61127428A8D00805D9E /* OpaqueSwiftStructTests.swift */; }; - 228FE64627480E1D00805D9E /* SwiftBridgeCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 228FE64427480E1C00805D9E /* SwiftBridgeCore.swift */; }; - 228FE64A274919C600805D9E /* swift-integration-tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 228FE648274919C500805D9E /* swift-integration-tests.swift */; }; - 22BC10F62799283100A0D046 /* SharedStruct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22BC10F52799283100A0D046 /* SharedStruct.swift */; }; - 22BC10F82799A3A000A0D046 /* SharedStructAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22BC10F72799A3A000A0D046 /* SharedStructAttributes.swift */; }; - 22BC4BBA294B8CCD0032B8A8 /* SharedEnumAttributeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22BC4BB9294B8CCD0032B8A8 /* SharedEnumAttributeTests.swift */; }; - 22BC4BBC294BA0EC0032B8A8 /* SharedEnumAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22BC4BBB294BA0EC0032B8A8 /* SharedEnumAttributes.swift */; }; - 22BCAAB927A2607700686A21 /* FunctionAttributeIdentifiableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22BCAAB827A2607700686A21 /* FunctionAttributeIdentifiableTests.swift */; }; - 22C0625328CE699D007A6F67 /* Callbacks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22C0625228CE699D007A6F67 /* Callbacks.swift */; }; - 22C0625528CE6C9A007A6F67 /* CallbackTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22C0625428CE6C9A007A6F67 /* CallbackTests.swift */; }; - 22C0AD51278ECA9E00A96469 /* SharedStructAttributeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22C0AD50278ECA9E00A96469 /* SharedStructAttributeTests.swift */; }; - 22D092A327B7E865009A4C2B /* AsyncTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22D092A227B7E865009A4C2B /* AsyncTests.swift */; }; - 22EE4E0928B5388000FEC83C /* SwiftFnUsesOpaqueSwiftType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22EE4E0828B5388000FEC83C /* SwiftFnUsesOpaqueSwiftType.swift */; }; - 22EE4E0B28B538A700FEC83C /* SwiftFnUsesOpaqueSwiftTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22EE4E0A28B538A700FEC83C /* SwiftFnUsesOpaqueSwiftTypeTests.swift */; }; - 22F7CF2A2A42EA7800517966 /* Vec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22F7CF292A42EA7800517966 /* Vec.swift */; }; - 22FD1C542753CB2A00F64281 /* SwiftFnUsesOpaqueRustType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22FD1C532753CB2A00F64281 /* SwiftFnUsesOpaqueRustType.swift */; }; - 22FD1C562753CB3F00F64281 /* SwiftFnUsesOpaqueRustTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22FD1C552753CB3F00F64281 /* SwiftFnUsesOpaqueRustTypeTests.swift */; }; - C926E4DE294F07AA0027E7E2 /* FunctionAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = C926E4DD294F07AA0027E7E2 /* FunctionAttributes.swift */; }; - C926E4E0294F18C50027E7E2 /* FunctionAttributeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C926E4DF294F18C50027E7E2 /* FunctionAttributeTests.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 228FE5E32740DB6D00805D9E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 228FE5C92740DB6A00805D9E /* Project object */; - proxyType = 1; - remoteGlobalIDString = 228FE5D02740DB6A00805D9E; - remoteInfo = SwiftRustIntegrationTestRunner; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 1745111429BE189B00B96A1A /* TupleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TupleTests.swift; sourceTree = ""; }; - 1784BE2729CE86D600AE5A4A /* Tuple.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tuple.swift; sourceTree = ""; }; - 178F1CD2298E97FB00335AA0 /* ArgumentAttributesTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArgumentAttributesTest.swift; sourceTree = ""; }; - 2202BC0727B2DD1700D43CC4 /* SharedEnumTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedEnumTests.swift; sourceTree = ""; }; - 22043292274A8FDF00BAE645 /* VecTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VecTests.swift; sourceTree = ""; }; - 22043294274ADA7A00BAE645 /* OptionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionTests.swift; sourceTree = ""; }; - 22043296274B0AB000BAE645 /* Option.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Option.swift; sourceTree = ""; }; - 220432A6274C953E00BAE645 /* PointerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointerTests.swift; sourceTree = ""; }; - 220432A8274D31DC00BAE645 /* Pointer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pointer.swift; sourceTree = ""; }; - 220432AE274E7BF800BAE645 /* SharedStructTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedStructTests.swift; sourceTree = ""; }; - 220432E92753092C00BAE645 /* RustFnUsesOpaqueSwiftType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RustFnUsesOpaqueSwiftType.swift; sourceTree = ""; }; - 220432EB27530AFC00BAE645 /* RustFnUsesOpaqueSwiftTypeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RustFnUsesOpaqueSwiftTypeTests.swift; sourceTree = ""; }; - 22046382282B4E3F00A09119 /* FunctionAttributeGetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FunctionAttributeGetTests.swift; sourceTree = ""; }; - 221E16B32786233600F94AC0 /* ConditionalCompilationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConditionalCompilationTests.swift; sourceTree = ""; }; - 221E16B52786F9FF00F94AC0 /* OpaqueTypeAttributeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpaqueTypeAttributeTests.swift; sourceTree = ""; }; - 222A81E828EB5BB100D4A412 /* Primitive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Primitive.swift; sourceTree = ""; }; - 222A81EA28EB5DF800D4A412 /* PrimitiveTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimitiveTests.swift; sourceTree = ""; }; - 22553323281DB5FC008A3121 /* GenericTests.rs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericTests.rs.swift; sourceTree = ""; }; - 225908FB28DA0E320080C737 /* ResultTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultTests.swift; sourceTree = ""; }; - 225908FD28DA0F9F0080C737 /* Result.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = ""; }; - 226F944A27BF79B400243D86 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; - 2289E82B29A879A7009D89D7 /* SingleRepresentationTypeElisionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleRepresentationTypeElisionTests.swift; sourceTree = ""; }; - 228FE5D12740DB6A00805D9E /* SwiftRustIntegrationTestRunner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftRustIntegrationTestRunner.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 228FE5D42740DB6A00805D9E /* SwiftRustIntegrationTestRunnerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftRustIntegrationTestRunnerApp.swift; sourceTree = ""; }; - 228FE5D62740DB6A00805D9E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; - 228FE5D82740DB6D00805D9E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 228FE5DB2740DB6D00805D9E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - 228FE5DD2740DB6D00805D9E /* SwiftRustIntegrationTestRunner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SwiftRustIntegrationTestRunner.entitlements; sourceTree = ""; }; - 228FE5E22740DB6D00805D9E /* SwiftRustIntegrationTestRunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftRustIntegrationTestRunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 228FE5E62740DB6D00805D9E /* StringTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringTests.swift; sourceTree = ""; }; - 228FE6012740DC2000805D9E /* BridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BridgingHeader.h; sourceTree = ""; }; - 228FE6032740DC7900805D9E /* libswift_integration_tests.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libswift_integration_tests.a; path = ../target/debug/libswift_integration_tests.a; sourceTree = ""; }; - 228FE6052740DC9A00805D9E /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; }; - 228FE60B2740F42000805D9E /* ASwiftStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ASwiftStack.swift; sourceTree = ""; }; - 228FE60F27416C0300805D9E /* OpaqueRustStructTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpaqueRustStructTests.swift; sourceTree = ""; }; - 228FE61127428A8D00805D9E /* OpaqueSwiftStructTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpaqueSwiftStructTests.swift; sourceTree = ""; }; - 228FE64427480E1C00805D9E /* SwiftBridgeCore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftBridgeCore.swift; sourceTree = ""; }; - 228FE6472749127400805D9E /* SwiftBridgeCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwiftBridgeCore.h; sourceTree = ""; }; - 228FE648274919C500805D9E /* swift-integration-tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "swift-integration-tests.swift"; path = "swift-integration-tests/swift-integration-tests.swift"; sourceTree = ""; }; - 228FE649274919C600805D9E /* swift-integration-tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "swift-integration-tests.h"; path = "swift-integration-tests/swift-integration-tests.h"; sourceTree = ""; }; - 22BC10F52799283100A0D046 /* SharedStruct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedStruct.swift; sourceTree = ""; }; - 22BC10F72799A3A000A0D046 /* SharedStructAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedStructAttributes.swift; sourceTree = ""; }; - 22BC4BB9294B8CCD0032B8A8 /* SharedEnumAttributeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedEnumAttributeTests.swift; sourceTree = ""; }; - 22BC4BBB294BA0EC0032B8A8 /* SharedEnumAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedEnumAttributes.swift; sourceTree = ""; }; - 22BCAAB827A2607700686A21 /* FunctionAttributeIdentifiableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FunctionAttributeIdentifiableTests.swift; sourceTree = ""; }; - 22C0625228CE699D007A6F67 /* Callbacks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Callbacks.swift; sourceTree = ""; }; - 22C0625428CE6C9A007A6F67 /* CallbackTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallbackTests.swift; sourceTree = ""; }; - 22C0AD50278ECA9E00A96469 /* SharedStructAttributeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedStructAttributeTests.swift; sourceTree = ""; }; - 22D092A227B7E865009A4C2B /* AsyncTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncTests.swift; sourceTree = ""; }; - 22EE4E0828B5388000FEC83C /* SwiftFnUsesOpaqueSwiftType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftFnUsesOpaqueSwiftType.swift; sourceTree = ""; }; - 22EE4E0A28B538A700FEC83C /* SwiftFnUsesOpaqueSwiftTypeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftFnUsesOpaqueSwiftTypeTests.swift; sourceTree = ""; }; - 22F7CF292A42EA7800517966 /* Vec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vec.swift; sourceTree = ""; }; - 22FD1C532753CB2A00F64281 /* SwiftFnUsesOpaqueRustType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftFnUsesOpaqueRustType.swift; sourceTree = ""; }; - 22FD1C552753CB3F00F64281 /* SwiftFnUsesOpaqueRustTypeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftFnUsesOpaqueRustTypeTests.swift; sourceTree = ""; }; - C926E4DD294F07AA0027E7E2 /* FunctionAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FunctionAttributes.swift; sourceTree = ""; }; - C926E4DF294F18C50027E7E2 /* FunctionAttributeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FunctionAttributeTests.swift; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 228FE5CE2740DB6A00805D9E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 228FE60E2740F93D00805D9E /* libswift_integration_tests.a in Frameworks */, - 228FE6062740DCA100805D9E /* libresolv.tbd in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 228FE5DF2740DB6D00805D9E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 228FE5C82740DB6A00805D9E = { - isa = PBXGroup; - children = ( - 228FE5FF2740DB8200805D9E /* Headers */, - 228FE6072740E26100805D9E /* Generated */, - 228FE5D32740DB6A00805D9E /* SwiftRustIntegrationTestRunner */, - 228FE5E52740DB6D00805D9E /* SwiftRustIntegrationTestRunnerTests */, - 228FE5D22740DB6A00805D9E /* Products */, - 228FE6022740DC7900805D9E /* Frameworks */, - ); - sourceTree = ""; - }; - 228FE5D22740DB6A00805D9E /* Products */ = { - isa = PBXGroup; - children = ( - 228FE5D12740DB6A00805D9E /* SwiftRustIntegrationTestRunner.app */, - 228FE5E22740DB6D00805D9E /* SwiftRustIntegrationTestRunnerTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 228FE5D32740DB6A00805D9E /* SwiftRustIntegrationTestRunner */ = { - isa = PBXGroup; - children = ( - 228FE5D82740DB6D00805D9E /* Assets.xcassets */, - 228FE60B2740F42000805D9E /* ASwiftStack.swift */, - 228FE5D62740DB6A00805D9E /* ContentView.swift */, - 22043296274B0AB000BAE645 /* Option.swift */, - 220432A8274D31DC00BAE645 /* Pointer.swift */, - 222A81E828EB5BB100D4A412 /* Primitive.swift */, - 228FE5DA2740DB6D00805D9E /* Preview Content */, - 220432E92753092C00BAE645 /* RustFnUsesOpaqueSwiftType.swift */, - 22BC10F52799283100A0D046 /* SharedStruct.swift */, - 22BC10F72799A3A000A0D046 /* SharedStructAttributes.swift */, - 226F944A27BF79B400243D86 /* String.swift */, - 22FD1C532753CB2A00F64281 /* SwiftFnUsesOpaqueRustType.swift */, - 228FE5DD2740DB6D00805D9E /* SwiftRustIntegrationTestRunner.entitlements */, - 228FE5D42740DB6A00805D9E /* SwiftRustIntegrationTestRunnerApp.swift */, - 22EE4E0828B5388000FEC83C /* SwiftFnUsesOpaqueSwiftType.swift */, - 22C0625228CE699D007A6F67 /* Callbacks.swift */, - 225908FD28DA0F9F0080C737 /* Result.swift */, - 22BC4BBB294BA0EC0032B8A8 /* SharedEnumAttributes.swift */, - C926E4DD294F07AA0027E7E2 /* FunctionAttributes.swift */, - 1784BE2729CE86D600AE5A4A /* Tuple.swift */, - 22F7CF292A42EA7800517966 /* Vec.swift */, - ); - path = SwiftRustIntegrationTestRunner; - sourceTree = ""; - }; - 228FE5DA2740DB6D00805D9E /* Preview Content */ = { - isa = PBXGroup; - children = ( - 228FE5DB2740DB6D00805D9E /* Preview Assets.xcassets */, - ); - path = "Preview Content"; - sourceTree = ""; - }; - 228FE5E52740DB6D00805D9E /* SwiftRustIntegrationTestRunnerTests */ = { - isa = PBXGroup; - children = ( - 22D092A227B7E865009A4C2B /* AsyncTests.swift */, - 221E16B32786233600F94AC0 /* ConditionalCompilationTests.swift */, - 22046382282B4E3F00A09119 /* FunctionAttributeGetTests.swift */, - 22BCAAB827A2607700686A21 /* FunctionAttributeIdentifiableTests.swift */, - 228FE60F27416C0300805D9E /* OpaqueRustStructTests.swift */, - 228FE61127428A8D00805D9E /* OpaqueSwiftStructTests.swift */, - 221E16B52786F9FF00F94AC0 /* OpaqueTypeAttributeTests.swift */, - 22043294274ADA7A00BAE645 /* OptionTests.swift */, - 225908FB28DA0E320080C737 /* ResultTests.swift */, - 220432A6274C953E00BAE645 /* PointerTests.swift */, - 222A81EA28EB5DF800D4A412 /* PrimitiveTests.swift */, - 220432EB27530AFC00BAE645 /* RustFnUsesOpaqueSwiftTypeTests.swift */, - 2202BC0727B2DD1700D43CC4 /* SharedEnumTests.swift */, - 22BC4BB9294B8CCD0032B8A8 /* SharedEnumAttributeTests.swift */, - 22C0AD50278ECA9E00A96469 /* SharedStructAttributeTests.swift */, - 220432AE274E7BF800BAE645 /* SharedStructTests.swift */, - 228FE5E62740DB6D00805D9E /* StringTests.swift */, - 22FD1C552753CB3F00F64281 /* SwiftFnUsesOpaqueRustTypeTests.swift */, - 22043292274A8FDF00BAE645 /* VecTests.swift */, - 22553323281DB5FC008A3121 /* GenericTests.rs.swift */, - 2289E82B29A879A7009D89D7 /* SingleRepresentationTypeElisionTests.swift */, - 22EE4E0A28B538A700FEC83C /* SwiftFnUsesOpaqueSwiftTypeTests.swift */, - 22C0625428CE6C9A007A6F67 /* CallbackTests.swift */, - C926E4DF294F18C50027E7E2 /* FunctionAttributeTests.swift */, - 178F1CD2298E97FB00335AA0 /* ArgumentAttributesTest.swift */, - 1745111429BE189B00B96A1A /* TupleTests.swift */, - ); - path = SwiftRustIntegrationTestRunnerTests; - sourceTree = ""; - }; - 228FE5FF2740DB8200805D9E /* Headers */ = { - isa = PBXGroup; - children = ( - 228FE6012740DC2000805D9E /* BridgingHeader.h */, - ); - path = Headers; - sourceTree = ""; - }; - 228FE6022740DC7900805D9E /* Frameworks */ = { - isa = PBXGroup; - children = ( - 228FE6052740DC9A00805D9E /* libresolv.tbd */, - 228FE6032740DC7900805D9E /* libswift_integration_tests.a */, - ); - name = Frameworks; - sourceTree = ""; - }; - 228FE6072740E26100805D9E /* Generated */ = { - isa = PBXGroup; - children = ( - 228FE649274919C600805D9E /* swift-integration-tests.h */, - 228FE648274919C500805D9E /* swift-integration-tests.swift */, - 228FE6472749127400805D9E /* SwiftBridgeCore.h */, - 228FE64427480E1C00805D9E /* SwiftBridgeCore.swift */, - ); - path = Generated; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 228FE5D02740DB6A00805D9E /* SwiftRustIntegrationTestRunner */ = { - isa = PBXNativeTarget; - buildConfigurationList = 228FE5F62740DB6D00805D9E /* Build configuration list for PBXNativeTarget "SwiftRustIntegrationTestRunner" */; - buildPhases = ( - 228FE60D2740F66400805D9E /* Run Script */, - 228FE5CD2740DB6A00805D9E /* Sources */, - 228FE5CE2740DB6A00805D9E /* Frameworks */, - 228FE5CF2740DB6A00805D9E /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = SwiftRustIntegrationTestRunner; - packageProductDependencies = ( - ); - productName = SwiftRustIntegrationTestRunner; - productReference = 228FE5D12740DB6A00805D9E /* SwiftRustIntegrationTestRunner.app */; - productType = "com.apple.product-type.application"; - }; - 228FE5E12740DB6D00805D9E /* SwiftRustIntegrationTestRunnerTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 228FE5F92740DB6D00805D9E /* Build configuration list for PBXNativeTarget "SwiftRustIntegrationTestRunnerTests" */; - buildPhases = ( - 228FE5DE2740DB6D00805D9E /* Sources */, - 228FE5DF2740DB6D00805D9E /* Frameworks */, - 228FE5E02740DB6D00805D9E /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 228FE5E42740DB6D00805D9E /* PBXTargetDependency */, - ); - name = SwiftRustIntegrationTestRunnerTests; - productName = SwiftRustIntegrationTestRunnerTests; - productReference = 228FE5E22740DB6D00805D9E /* SwiftRustIntegrationTestRunnerTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 228FE5C92740DB6A00805D9E /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1300; - LastUpgradeCheck = 1300; - TargetAttributes = { - 228FE5D02740DB6A00805D9E = { - CreatedOnToolsVersion = 13.0; - }; - 228FE5E12740DB6D00805D9E = { - CreatedOnToolsVersion = 13.0; - TestTargetID = 228FE5D02740DB6A00805D9E; - }; - }; - }; - buildConfigurationList = 228FE5CC2740DB6A00805D9E /* Build configuration list for PBXProject "SwiftRustIntegrationTestRunner" */; - compatibilityVersion = "Xcode 13.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 228FE5C82740DB6A00805D9E; - productRefGroup = 228FE5D22740DB6A00805D9E /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 228FE5D02740DB6A00805D9E /* SwiftRustIntegrationTestRunner */, - 228FE5E12740DB6D00805D9E /* SwiftRustIntegrationTestRunnerTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 228FE5CF2740DB6A00805D9E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 228FE5DC2740DB6D00805D9E /* Preview Assets.xcassets in Resources */, - 228FE5D92740DB6D00805D9E /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 228FE5E02740DB6D00805D9E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 228FE60D2740F66400805D9E /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "./build-rust.sh\n"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 228FE5CD2740DB6A00805D9E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 22BC10F62799283100A0D046 /* SharedStruct.swift in Sources */, - 1784BE2829CE86D600AE5A4A /* Tuple.swift in Sources */, - 226F944B27BF79B400243D86 /* String.swift in Sources */, - 22043297274B0AB000BAE645 /* Option.swift in Sources */, - 220432EA2753092C00BAE645 /* RustFnUsesOpaqueSwiftType.swift in Sources */, - 22BC4BBC294BA0EC0032B8A8 /* SharedEnumAttributes.swift in Sources */, - 22F7CF2A2A42EA7800517966 /* Vec.swift in Sources */, - 22FD1C542753CB2A00F64281 /* SwiftFnUsesOpaqueRustType.swift in Sources */, - 220432A9274D31DC00BAE645 /* Pointer.swift in Sources */, - 225908FE28DA0F9F0080C737 /* Result.swift in Sources */, - 228FE5D72740DB6A00805D9E /* ContentView.swift in Sources */, - 222A81E928EB5BB100D4A412 /* Primitive.swift in Sources */, - 228FE64627480E1D00805D9E /* SwiftBridgeCore.swift in Sources */, - 228FE5D52740DB6A00805D9E /* SwiftRustIntegrationTestRunnerApp.swift in Sources */, - C926E4DE294F07AA0027E7E2 /* FunctionAttributes.swift in Sources */, - 228FE64A274919C600805D9E /* swift-integration-tests.swift in Sources */, - 22C0625328CE699D007A6F67 /* Callbacks.swift in Sources */, - 22BC10F82799A3A000A0D046 /* SharedStructAttributes.swift in Sources */, - 22EE4E0928B5388000FEC83C /* SwiftFnUsesOpaqueSwiftType.swift in Sources */, - 228FE60C2740F42000805D9E /* ASwiftStack.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 228FE5DE2740DB6D00805D9E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 22043293274A8FDF00BAE645 /* VecTests.swift in Sources */, - 221E16B62786F9FF00F94AC0 /* OpaqueTypeAttributeTests.swift in Sources */, - 220432A7274C953E00BAE645 /* PointerTests.swift in Sources */, - C926E4E0294F18C50027E7E2 /* FunctionAttributeTests.swift in Sources */, - 220432AF274E7BF800BAE645 /* SharedStructTests.swift in Sources */, - 178F1CD3298E97FB00335AA0 /* ArgumentAttributesTest.swift in Sources */, - 2289E82C29A879A7009D89D7 /* SingleRepresentationTypeElisionTests.swift in Sources */, - 220432EC27530AFC00BAE645 /* RustFnUsesOpaqueSwiftTypeTests.swift in Sources */, - 222A81EB28EB5DF800D4A412 /* PrimitiveTests.swift in Sources */, - 22553324281DB5FC008A3121 /* GenericTests.rs.swift in Sources */, - 225908FC28DA0E320080C737 /* ResultTests.swift in Sources */, - 2202BC0827B2DD1700D43CC4 /* SharedEnumTests.swift in Sources */, - 22BCAAB927A2607700686A21 /* FunctionAttributeIdentifiableTests.swift in Sources */, - 22EE4E0B28B538A700FEC83C /* SwiftFnUsesOpaqueSwiftTypeTests.swift in Sources */, - 221E16B42786233600F94AC0 /* ConditionalCompilationTests.swift in Sources */, - 22043295274ADA7A00BAE645 /* OptionTests.swift in Sources */, - 22C0AD51278ECA9E00A96469 /* SharedStructAttributeTests.swift in Sources */, - 228FE5E72740DB6D00805D9E /* StringTests.swift in Sources */, - 22C0625528CE6C9A007A6F67 /* CallbackTests.swift in Sources */, - 22BC4BBA294B8CCD0032B8A8 /* SharedEnumAttributeTests.swift in Sources */, - 228FE61227428A8D00805D9E /* OpaqueSwiftStructTests.swift in Sources */, - 22FD1C562753CB3F00F64281 /* SwiftFnUsesOpaqueRustTypeTests.swift in Sources */, - 228FE61027416C0300805D9E /* OpaqueRustStructTests.swift in Sources */, - 22D092A327B7E865009A4C2B /* AsyncTests.swift in Sources */, - 1745111529BE189B00B96A1A /* TupleTests.swift in Sources */, - 22046383282B4E3F00A09119 /* FunctionAttributeGetTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 228FE5E42740DB6D00805D9E /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 228FE5D02740DB6A00805D9E /* SwiftRustIntegrationTestRunner */; - targetProxy = 228FE5E32740DB6D00805D9E /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 228FE5F42740DB6D00805D9E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 11.3; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 228FE5F52740DB6D00805D9E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 11.3; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = macosx; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - }; - name = Release; - }; - 228FE5F72740DB6D00805D9E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"SwiftRustIntegrationTestRunner/Preview Content\""; - ENABLE_PREVIEWS = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../target/debug"; - MACOSX_DEPLOYMENT_TARGET = 11.5; - MARKETING_VERSION = 1.0; - OTHER_SWIFT_FLAGS = ""; - PRODUCT_BUNDLE_IDENTIFIER = com.xcode.SwiftRustIntegrationTestRunner; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG FOO"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/Headers/BridgingHeader.h"; - SWIFT_VERSION = 5.0; - }; - name = Debug; - }; - 228FE5F82740DB6D00805D9E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_ENTITLEMENTS = SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.entitlements; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"SwiftRustIntegrationTestRunner/Preview Content\""; - ENABLE_PREVIEWS = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_NSHumanReadableCopyright = ""; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - ); - LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../target/release"; - MACOSX_DEPLOYMENT_TARGET = 11.5; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.xcode.SwiftRustIntegrationTestRunner; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/Headers/BridgingHeader.h"; - SWIFT_VERSION = 5.0; - }; - name = Release; - }; - 228FE5FA2740DB6D00805D9E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - "@loader_path/../Frameworks", - ); - LIBRARY_SEARCH_PATHS = ""; - MACOSX_DEPLOYMENT_TARGET = 11.5; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.xcode.SwiftRustIntegrationTestRunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = NO; - SWIFT_OBJC_BRIDGING_HEADER = ""; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftRustIntegrationTestRunner.app/Contents/MacOS/SwiftRustIntegrationTestRunner"; - }; - name = Debug; - }; - 228FE5FB2740DB6D00805D9E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - BUNDLE_LOADER = "$(TEST_HOST)"; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; - GENERATE_INFOPLIST_FILE = YES; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/../Frameworks", - "@loader_path/../Frameworks", - ); - LIBRARY_SEARCH_PATHS = ""; - MACOSX_DEPLOYMENT_TARGET = 11.5; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.xcode.SwiftRustIntegrationTestRunnerTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = NO; - SWIFT_OBJC_BRIDGING_HEADER = ""; - SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftRustIntegrationTestRunner.app/Contents/MacOS/SwiftRustIntegrationTestRunner"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 228FE5CC2740DB6A00805D9E /* Build configuration list for PBXProject "SwiftRustIntegrationTestRunner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 228FE5F42740DB6D00805D9E /* Debug */, - 228FE5F52740DB6D00805D9E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 228FE5F62740DB6D00805D9E /* Build configuration list for PBXNativeTarget "SwiftRustIntegrationTestRunner" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 228FE5F72740DB6D00805D9E /* Debug */, - 228FE5F82740DB6D00805D9E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 228FE5F92740DB6D00805D9E /* Build configuration list for PBXNativeTarget "SwiftRustIntegrationTestRunnerTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 228FE5FA2740DB6D00805D9E /* Debug */, - 228FE5FB2740DB6D00805D9E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 228FE5C92740DB6A00805D9E /* Project object */; -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a6..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/xcshareddata/xcschemes/SwiftRustIntegrationTestRunner.xcscheme b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/xcshareddata/xcschemes/SwiftRustIntegrationTestRunner.xcscheme deleted file mode 100644 index 461c9358..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.xcodeproj/xcshareddata/xcschemes/SwiftRustIntegrationTestRunner.xcscheme +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/AccentColor.colorset/Contents.json b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/AccentColor.colorset/Contents.json deleted file mode 100644 index eb878970..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/AccentColor.colorset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "colors" : [ - { - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/AppIcon.appiconset/Contents.json b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 3f00db43..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "images" : [ - { - "idiom" : "mac", - "scale" : "1x", - "size" : "16x16" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "16x16" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "32x32" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "32x32" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "128x128" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "128x128" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "256x256" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "256x256" - }, - { - "idiom" : "mac", - "scale" : "1x", - "size" : "512x512" - }, - { - "idiom" : "mac", - "scale" : "2x", - "size" : "512x512" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/Contents.json b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/Contents.json deleted file mode 100644 index 73c00596..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/ContentView.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/ContentView.swift deleted file mode 100644 index b58272c1..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/ContentView.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// ContentView.swift -// SwiftRustIntegrationTestRunner -// -// Created by Frankie Nwafili on 11/14/21. -// - -import SwiftUI - -struct ContentView: View { - var body: some View { - Text("Hello, world!") - .padding() - } -} - -struct ContentView_Previews: PreviewProvider { - static var previews: some View { - ContentView() - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Preview Content/Preview Assets.xcassets/Contents.json b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Preview Content/Preview Assets.xcassets/Contents.json deleted file mode 100644 index 73c00596..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Preview Content/Preview Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.entitlements b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.entitlements deleted file mode 100644 index f2ef3ae0..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner.entitlements +++ /dev/null @@ -1,10 +0,0 @@ - - - - - com.apple.security.app-sandbox - - com.apple.security.files.user-selected.read-only - - - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerApp.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerApp.swift deleted file mode 100644 index 02382a7e..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerApp.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// XcodeSwiftApp.swift -// XcodeSwift -// -// Created by Frankie Nwafili on 11/14/21. -// - -import SwiftUI - -@main -struct XcodeSwiftApp: App { - var body: some Scene { - WindowGroup { - ContentView() - } - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerSwiftRustIntegrationTestRunner.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerSwiftRustIntegrationTestRunner.swift deleted file mode 100644 index 3daac0d5..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerSwiftRustIntegrationTestRunner.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// SwiftRustIntegrationTestRunnerApp.swift -// SwiftRustIntegrationTestRunner -// -// Created by Frankie Nwafili on 11/14/21. -// - -import SwiftUI - -@main -struct SwiftRustIntegrationTestRunnerApp: App { - var body: some Scene { - WindowGroup { - ContentView() - } - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ArgumentAttributesTest.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ArgumentAttributesTest.swift deleted file mode 100644 index a3ab4065..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ArgumentAttributesTest.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// ArgumentAttributes.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Niwaka on 2023/02/04. -// - -import Foundation - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests argument attributes such as `#[swift_bridge(label = "someArg")]`. -final class ArgumentAttributesTest: XCTestCase { - - /// Verify that the `swift_bridge(label = "someArg")` attribute works. - func testArgumentLabel() throws { - XCTAssertEqual(test_argument_label(someArg: 10, 100), 110) - } - -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/AsyncTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/AsyncTests.swift deleted file mode 100644 index 0a22bb53..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/AsyncTests.swift +++ /dev/null @@ -1,195 +0,0 @@ -// -// SharedStructAttributeTests.swift -// SwiftRustIntegrationTestRunnerTests -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class AsyncTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testSwiftCallsRustAsyncFn() async throws { - await rust_async_return_null() - } - - /// Verify that we can pass and return a u8 to an async Rust function - func testSwiftCallsRustAsyncFnReflectU8() async throws { - let num = await rust_async_reflect_u8(123) - XCTAssertEqual(num, 123) - } - - /// Verify that we can pass and return a String to an async Rust function - func testSwiftCallsRustAsyncFnReflectString() async throws { - let string = await rust_async_reflect_string("hello world") - XCTAssertEqual(string.toString(), "hello world") - } - - /// Verify that we can call async Rust methods - func testSwiftCallsRustAsyncMethodReflectU16() async throws { - let test = TestRustAsyncSelf() - - let num = await test.reflect_u16(567) - XCTAssertEqual(num, 567) - } - - - /// Verify that we can pass and return a Result to an async Rust function - func testSwiftCallsRustAsyncFnReflectResultOpaqueRust() async throws { - - // Should return an AsyncResultOpaqueRustType1 type. - do { - let _ = try await rust_async_func_reflect_result_opaque_rust(.Ok(AsyncResultOpaqueRustType1(10))) - } catch { - XCTFail() - } - - // Should throw an AsyncResultOpaqueRustType2 type that conforms to Error protocol. - do { - let _ = try await rust_async_func_reflect_result_opaque_rust(.Err(AsyncResultOpaqueRustType2(100))) - XCTFail() - } catch let error as AsyncResultOpaqueRustType2 { - XCTAssertEqual(error.val(), 100) - } catch { - XCTFail() - } - } - - /// Verify that we can return a Result from async Rust function - func testSwiftCallsRustAsyncFnReturnResultTransparentEnum() async throws { - - //Should return an AsyncResultOkEnum - do { - let value: AsyncResultOkEnum = try await rust_async_func_return_result_transparent_enum_and_transparent_enum(true) - switch value { - case .NoFields: - XCTFail() - case .UnnamedFields(let valueInt32, let valueString): - XCTAssertEqual(valueInt32, 123) - XCTAssertEqual(valueString.toString(), "hello") - case .NamedFields(_): - XCTFail() - } - } catch { - XCTFail() - } - - //Should throw an AsyncResultErrEnum - do { - let _ = try await rust_async_func_return_result_transparent_enum_and_transparent_enum(false) - XCTFail() - } catch let error as AsyncResultErrEnum { - switch error { - case .UnnamedFields(_, _): - XCTFail() - case .NamedFields(let valueUInt32): - XCTAssertEqual(valueUInt32, 100) - } - } catch { - XCTFail() - } - } - - /// Verify that we can return a Result from async Rust function - func testSwiftCallsRustAsyncFnReturnResultOpaqueRustTransparentEnum() async throws { - //Should return an AsyncResultOpaqueRustType1 - do { - let value: AsyncResultOpaqueRustType1 = try await rust_async_func_return_result_opaque_rust_and_transparent_enum(true) - XCTAssertEqual(value.val(), 10) - } catch { - XCTFail() - } - - //Should throw an AsyncResultErrEnum - do { - let _: AsyncResultOpaqueRustType1 = try await rust_async_func_return_result_opaque_rust_and_transparent_enum(false) - } catch let error as AsyncResultErrEnum { - switch error { - case .UnnamedFields(_, _): - XCTFail() - case .NamedFields(let value): - XCTAssertEqual(value, 1000) - } - } catch { - XCTFail() - } - } - - /// Verify that we can return a Result from async Rust function - func testSwiftCallsRustAsyncFnReturnResultTransparentEnumOpaqueRust() async throws { - //Should return an AsyncResultOkEnum - do { - let value: AsyncResultOkEnum = try await rust_async_func_return_result_transparent_enum_and_opaque_rust(true) - switch value { - case .NoFields: - break - case .UnnamedFields(_, _): - XCTFail() - case .NamedFields(let value): - XCTFail() - } - } catch { - XCTFail() - } - - //Should throw an AsyncResultOpaqueRustType1 - do { - let _ = try await rust_async_func_return_result_transparent_enum_and_opaque_rust(false) - XCTFail() - } catch let error as AsyncResultOpaqueRustType1 { - XCTAssertEqual(error.val(), 1000) - } catch { - XCTFail() - } - - } - - /// Verify that we can return a Result<(), TransparentEnum> from async Rust function - func testSwiftCallsRustAsyncFnReturnResultNullTransparentEnum() async throws { - //Should return an Unit type - do { - let _: () = try await rust_async_func_return_result_null_and_transparent_enum(true) - } catch { - XCTFail() - } - - //Should throw an AsyncResultErrEnum - do { - let _ = try await rust_async_func_return_result_null_and_transparent_enum(false) - XCTFail() - } catch let error as AsyncResultErrEnum { - switch error { - case .UnnamedFields(let valueString, let valueInt32): - XCTAssertEqual(valueString.toString(), "foo") - XCTAssertEqual(valueInt32, 123) - case .NamedFields(_): - XCTFail() - } - } catch { - XCTFail() - } - } - - func testSwiftCallsRustAsyncFnRetStruct() async throws { - let _: AsyncRustFnReturnStruct = await rust_async_return_struct() - } - - func testSwiftCallsRustAsyncFnReturnResultNullOpaqueRust() async throws { - try await rust_async_func_return_result_null_opaque_rust(true) - - do { - try await rust_async_func_return_result_null_opaque_rust(false) - XCTFail() - } catch let error as AsyncResultOpaqueRustType2 { - XCTAssertEqual(error.val(), 111) - } - } -} - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/CallbackTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/CallbackTests.swift deleted file mode 100644 index 659837a8..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/CallbackTests.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// CallbackTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 9/11/22. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class CallbackTests: XCTestCase { - - /// Run our tests where Rust passes a callback to Swift. - func testRustCallsSwift() throws { - test_callbacks_rust_calls_swift() - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ConditionalCompilationTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ConditionalCompilationTests.swift deleted file mode 100644 index 4c90aee7..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ConditionalCompilationTests.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// SwiftFnUsesOpaqueRustTypeTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/28/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - - -class ConditionalCompilationTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - /// Call a function from a bridge module that is only exposed when the - /// "this_is_enabled" feature is enabled for the Rust crate. - /// We have that feature enabled by default, so we should be able to call the function. - func testConditionalCompilation() throws { - XCTAssertEqual(conditionally_exposed_fn(), 123) - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeGetTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeGetTests.swift deleted file mode 100644 index 71b74110..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeGetTests.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// FunctionAttributeGetTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 5/10/22. -// - -import Foundation - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests the #[swift_bridge(get(...))] attribute. -class FunctionAttributeGetTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - /// Verify that the `swift_bridge(get(...))` attribute works for a Option<&'static str>. - func testGetOptStaticStr() throws { - let val = SomeTypeGet() - XCTAssertEqual(val.my_opt_static_str()!.toString(), "world") - } -} - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeIdentifiableTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeIdentifiableTests.swift deleted file mode 100644 index 9e13b67b..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeIdentifiableTests.swift +++ /dev/null @@ -1,41 +0,0 @@ -// -// FunctionAttributeIdentifiableTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 1/27/22. -// - -import Foundation - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests the #[swift_bridge(Identifiable)] attribute. -class FunctionAttributeIdentifiableTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - /// Verify that the `swift_bridge(Identifiable)` attribute works. - func testIdentifiable() throws { - XCTAssertEqual(verifyIsIdentifiable(IdentifiableFnNamedId()).id(), 123) - XCTAssertEqual(IdentifiableFnNotNamedId().id, 123) - XCTAssertEqual(OpaqueCopyTypeIdentifiable().id(), 123) - - XCTAssertEqual(verifyIsIdentifiable(IdentifiableU8()).id(), 123) - XCTAssertEqual(verifyIsIdentifiable(IdentifiableI8()).id(), 123) - - "hello world".toRustStr({rustStr in - XCTAssertEqual(verifyIsIdentifiable(IdentifiableStr()).id(), rustStr) - }) - } -} - -func verifyIsIdentifiable(_ arg: T) -> T { - arg -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeTests.swift deleted file mode 100644 index 35e65d45..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/FunctionAttributeTests.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// FunctionAttributeIdentifiableTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Erik Živković on 2022-12-17. -// - -import Foundation - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests the #[swift_bridge(swift_name = "x")] attribute. -class FunctionAttributeTests: XCTestCase { - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - /// Verify that the `swift_bridge(swift_name = "x")` attribute works. - func testSwiftNameAttribute() throws { - XCTAssertEqual(testCallRustFromSwiftByNameAttribute().toString(), "StringFromRust") - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/GenericTests.rs.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/GenericTests.rs.swift deleted file mode 100644 index 67bbddb5..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/GenericTests.rs.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// GenericTests.rs.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 4/30/22. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests for generic types such as `type SomeType` -class GenericTests: XCTestCase { - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testReflectGenericOpaqueRustType() { - let val = new_some_generic_type_u32() - let _: SomeGenericType = reflect_generic_u32(val) - } - - func testReflectGenericOpaqueCopyRustType() { - let val = new_some_generic_copy_type_u32() - let _: SomeGenericCopyType = reflect_generic_copy_u32(val) - } - - func testReflectGenericWithInnerOpaqueRustType() { - let val = new_generic_with_inner_opaque_type() - let _: GenericWithOpaqueRustInnerTy = reflect_generic_with_inner_opaque_type(val) - } -} - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueRustStructTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueRustStructTests.swift deleted file mode 100644 index 7057dc76..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueRustStructTests.swift +++ /dev/null @@ -1,134 +0,0 @@ -// -// OpaqueRustStructTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/14/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class OpaqueRustStructTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - /// Verify that we can create and work with an opaque Rust struct via a generated class - func testOpaqueRustStruct() throws { - let stack = ARustStack() - - XCTAssertEqual(stack.len(), 0) - stack.push(5) - stack.push(10) - XCTAssertEqual(stack.len(), 2) - - XCTAssertEqual(stack.as_slice()[0], 5) - XCTAssertEqual(stack.as_slice()[1], 10) - - stack.pop() - XCTAssertEqual(stack.len(), 1) - } - - /// Verify that when we de-alocate a class instance that is wrapping a type that was returned to us from - /// Rust by reference we do not free the Rust type's memory (like we do with owned values). - /// - /// We call a function twice that returns the same &ARustStack each time. - /// - /// This means that we create two class instances on the Swift side that each reference the - /// same &ARustStack. - /// - /// By calling it twice we ensures that we did not free memory after dropping these instances - /// since that would result in a malloc error "pointer being freed was not allocated". - func testReferenceToOpaqueRustStruct() throws { - let stack_wrapper = StackWrapper() - - let ref1 = stack_wrapper.get_stack_mut() - let ref2 = stack_wrapper.get_stack_mut() - - ref1.push(5) - ref2.push(10) - - XCTAssertEqual(ref1.len(), 2) - XCTAssertEqual(ref1.len(), ref2.len()) - } - - /// Verify that we can pass a Copy opaque Rust type between Rust and Swift. - func testOpaqueRustTypeImplCopy() throws { - let val = RustCopyType() - let val2 = RustCopyType() - - // Because `val` is copy we can still use it after calling - // a method that takes an owned `self` . - val.consume() - - XCTAssert(val.eq(val2)) - } - - func testOpaqueRustTypeImplEquatable() throws { - XCTContext.runActivity(named: "Should be equal"){ - _ in - let val1 = RustEquatableType() - let val2 = RustEquatableType() - - XCTAssertEqual(val1, val2) - } - - XCTContext.runActivity(named: "Should not be equal"){ - _ in - let val1 = RustEquatableType() - let val2 = RustEquatableType() - - val1.set_value(11) - val2.set_value(22) - - XCTAssertNotEqual(val1, val2) - } - } - - func testOpaqueRustTypeImplHashable() throws { - XCTContext.runActivity(named: "Same hash value"){ - _ in - let val1 = RustHashableType(10) - let val2 = RustHashableType(10) - - var table: [RustHashableType: String] = [:] - table[val1] = "hello" - table[val2] = "world" - - //Should be overwritten. - if let element = table[val1] { - XCTAssertEqual(element, "world") - }else { - XCTFail() - } - } - - XCTContext.runActivity(named: "Not same hash value"){ - _ in - let val1 = RustHashableType(10) - let val2 = RustHashableType(100) - - var table: [RustHashableType: String] = [:] - table[val1] = "hello" - table[val2] = "world" - - //Should not be overwritten - if let element = table[val1] { - XCTAssertEqual(element, "hello") - }else { - XCTFail() - } - if let element = table[val2] { - XCTAssertEqual(element, "world") - }else { - XCTFail() - } - } - } -} - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueSwiftStructTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueSwiftStructTests.swift deleted file mode 100644 index 1ce8917e..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueSwiftStructTests.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// OpaqueRustStructTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/14/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class OpaqueSwiftStructTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - /// Run the Rust tests that create and use an opaque Swift struct. - func testOpaqueSwiftStruct() throws { - run_opaque_swift_class_tests() - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueTypeAttributeTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueTypeAttributeTests.swift deleted file mode 100644 index 16ce2d4d..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OpaqueTypeAttributeTests.swift +++ /dev/null @@ -1,53 +0,0 @@ -// -// OpaqueTypeAttributeTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 1/6/22. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests for attributes on opaque types. -class OpaqueTypeAttributeTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - /// Verify that we can call an initializers, methods and associated functions that were declared in a different module from - /// where the opaque Rust type was defined. - /// This ensures that our code generation properly generates Swift convenience initializers inside of class extensions. - /// See crates/swift-integration-tests/src/type_attributes/already_declared.rs - func testExternRustAlreadyDeclaredOpaqueRustType() throws { - let val = AlreadyDeclaredTypeTest() - - XCTAssert(val.a_ref_method()) - XCTAssert(val.a_ref_mut_method()) - XCTAssert(val.an_owned_method()) - - XCTAssert(AlreadyDeclaredTypeTest.an_associated_function()) - } - - func testExternRustAlreadyDeclaredCopyOpaqueRustTypeType() throws { - let val = AlreadyDeclaredCopyTypeTest() - - XCTAssert(val.a_ref_method()) - XCTAssert(val.an_owned_method()) - - XCTAssert(AlreadyDeclaredCopyTypeTest.an_associated_function()) - } - - - func testPerformanceExample() throws { - // This is an example of a performance test case. - self.measure { - // Put the code you want to measure the time of here. - } - } - -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OptionTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OptionTests.swift deleted file mode 100644 index 34cf859a..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/OptionTests.swift +++ /dev/null @@ -1,230 +0,0 @@ -// -// OptionTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/21/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class OptionTests: XCTestCase { - - /// Verify that Swift can call Rust functions that accept and return Option - /// where T is a primitive. - func testSwiftCallRustOptionPrimitive() throws { - XCTAssertEqual(rust_reflect_option_u8(70), 70) - XCTAssertEqual(rust_reflect_option_u8(nil), nil) - - XCTAssertEqual(rust_reflect_option_i8(70), 70) - XCTAssertEqual(rust_reflect_option_i8(nil), nil) - - XCTAssertEqual(rust_reflect_option_u16(70), 70) - XCTAssertEqual(rust_reflect_option_u16(nil), nil) - - XCTAssertEqual(rust_reflect_option_i16(70), 70) - XCTAssertEqual(rust_reflect_option_i16(nil), nil) - - XCTAssertEqual(rust_reflect_option_u32(70), 70) - XCTAssertEqual(rust_reflect_option_u32(nil), nil) - - XCTAssertEqual(rust_reflect_option_i32(70), 70) - XCTAssertEqual(rust_reflect_option_i32(nil), nil) - - XCTAssertEqual(rust_reflect_option_u64(70), 70) - XCTAssertEqual(rust_reflect_option_u64(nil), nil) - - XCTAssertEqual(rust_reflect_option_i64(70), 70) - XCTAssertEqual(rust_reflect_option_i64(nil), nil) - - XCTAssertEqual(rust_reflect_option_f32(70.0), 70.0) - XCTAssertEqual(rust_reflect_option_f32(nil), nil) - - XCTAssertEqual(rust_reflect_option_f64(70.0), 70.0) - XCTAssertEqual(rust_reflect_option_f64(nil), nil) - - XCTAssertEqual(rust_reflect_option_bool(true), true) - XCTAssertEqual(rust_reflect_option_bool(false), false) - XCTAssertEqual(rust_reflect_option_bool(nil), nil) - } - - /// Verify that Rust can call Swift functions that accept and return Option. - func testRustCallSwiftOptionPrimitive() throws { - test_rust_calls_swift_option_primitive() - } - - /// Verify that Swift can call a Rust function that accepts and returns an Option - /// where T is a String. - func testSwiftCallRustReturnOptionString() throws { - let string = rust_reflect_option_string("hello world") - XCTAssertEqual(string!.toString(), "hello world") - - let none: String? = nil - XCTAssertNil(rust_reflect_option_string(none)) - } - - /// We use an `Option<&'static str>` that we create on the Rust side so that - /// we don't run into any lifetime issues. - func testSwiftCallRustReturnOptionStr() throws { - let str = rust_create_option_static_str() - XCTAssertEqual(str!.toString(), "hello") - - let reflected = rust_reflect_option_str(str) - XCTAssertEqual(reflected!.toString(), "hello") - - let none: RustStr? = nil - XCTAssertNil(rust_reflect_option_str(none)) - } - - func testSwiftCallRustWithOptionVecOfPrimitiveType() throws { - let vec = RustVec() - vec.push(value: 123) - vec.push(value: 321) - - let reflected = rust_reflect_option_vector_rust_type(vec)! - XCTAssertEqual(reflected.len(), 2) - - XCTAssertEqual(reflected.get(index: 0), 123) - XCTAssertEqual(reflected.get(index: 1), 321) - - XCTAssertNil(rust_reflect_option_vector_rust_type(nil)) - } - - func testSwiftCallRustWithOptionOpaqueRustType() throws { - let val = OptTestOpaqueRustType(123) - let reflect = rust_reflect_option_opaque_rust_type(val) - XCTAssertEqual(reflect!.field(), 123) - - XCTAssertNil(rust_reflect_option_opaque_rust_type(nil)) - } - - /// Verify that we can bridge options of opaque Swift types. - func testSwiftCallRustWithOptionOpaqueSwiftType() throws { - let val = OptTestOpaqueSwiftType(val: 727) - let reflect = rust_reflect_option_opaque_swift_type(val) - XCTAssertEqual(reflect!.val, 727) - - XCTAssertNil(rust_reflect_option_opaque_swift_type(nil)) - } - - /// Verify that we can pass and receive an `Option<&RustType>`. - /// - /// We deinitialize the first reference and create a second to confirm that - /// deinitializing the reference does not deinitialize the Rust type. - func testSwiftCallRustWithOptionRefOpaqueRustType() throws { - let val = OptTestOpaqueRefRustType.new(123) - let opt_ref = val.field_ref() - - var reflect = rust_reflect_option_ref_opaque_rust_type(opt_ref) - XCTAssertEqual(reflect!.field(), 123) - XCTAssertNil(rust_reflect_option_ref_opaque_rust_type(nil)) - reflect = nil - - reflect = rust_reflect_option_ref_opaque_rust_type(opt_ref) - XCTAssertEqual(reflect!.field(), 123) - } - - func testSwiftCallRustWithOptionOpaqueRustCopyType() throws { - let val = new_opaque_rust_copy_type(123) - let _: OptTestOpaqueRustCopyType? = rust_reflect_option_opaque_rust_copy_type(val) - - // TODO: Support methods on generic types - // XCTAssertEqual(reflect!.field(), 123) - XCTAssertNil(rust_reflect_option_opaque_rust_copy_type(nil)) - } - - func testSwiftCallRustWithOptionGenericOpaqueRustType() throws { - let val = new_generic_opaque_rust_type(123) - let _: OptTestGenericOpaqueRustType? = rust_reflect_option_generic_opaque_rust_type(val) - - // TODO: Support methods on generic types - // XCTAssertEqual(reflect!.field(), 123) - XCTAssertNil(rust_reflect_option_opaque_rust_type(nil)) - } - - func testSwiftCallRustWithOptionGenericOpaqueRustCopyType() throws { - let val = new_generic_opaque_rust_copy_type(123) - let _: OptTestGenericOpaqueRustCopyType? = rust_reflect_option_generic_opaque_rust_copy_type(val) - - // TODO: Support methods on generic types - // XCTAssertEqual(reflect!.field(), 123) - XCTAssertNil(rust_reflect_option_generic_opaque_rust_copy_type(nil)) - } - - - func testStructWithOptionFieldsSome() throws { - let val = StructWithOptionFields( - u8: 123, i8: 123, u16: 123, i16: 123, - u32: 123, i32: 123, u64: 123, i64: 123, - usize: 123, isize: 123, f32: 123.4, f64: 123.4, - boolean: true - ) - let reflected = rust_reflect_struct_with_option_fields(val) - XCTAssertEqual(reflected.u8, 123) - XCTAssertEqual(reflected.i8, 123) - XCTAssertEqual(reflected.u16, 123) - XCTAssertEqual(reflected.i16, 123) - XCTAssertEqual(reflected.u32, 123) - XCTAssertEqual(reflected.i32, 123) - XCTAssertEqual(reflected.u64, 123) - XCTAssertEqual(reflected.i64, 123) - XCTAssertEqual(reflected.usize, 123) - XCTAssertEqual(reflected.isize, 123) - XCTAssertEqual(reflected.f32, 123.4) - XCTAssertEqual(reflected.f64, 123.4) - XCTAssertEqual(reflected.boolean, true) - } - - func testStructWithOptionFieldsNone() { - let val = StructWithOptionFields( - u8: nil, i8: nil, u16: nil, i16: nil, - u32: nil, i32: nil, u64: nil, i64: nil, - usize: nil, isize: nil, f32: nil, f64: nil, - boolean: nil - ) - let reflected = rust_reflect_struct_with_option_fields(val) - XCTAssertEqual(reflected.i8, nil) - XCTAssertEqual(reflected.u16, nil) - XCTAssertEqual(reflected.i16, nil) - XCTAssertEqual(reflected.u32, nil) - XCTAssertEqual(reflected.i32, nil) - XCTAssertEqual(reflected.u64, nil) - XCTAssertEqual(reflected.i64, nil) - XCTAssertEqual(reflected.usize, nil) - XCTAssertEqual(reflected.isize, nil) - XCTAssertEqual(reflected.f32, nil) - XCTAssertEqual(reflected.f64, nil) - XCTAssertEqual(reflected.boolean, nil) - } - - func testEnumWhereVariantsHaveNoData() { - let val = OptionEnumWithNoData.Variant2 - let reflectedSome = rust_reflect_option_enum_with_no_data(val) - let reflectedNone = rust_reflect_option_enum_with_no_data(nil) - - switch reflectedSome! { - case .Variant2: - break; - default: - XCTFail() - } - - XCTAssertNil(reflectedNone) - } - - func testOptionStruct() { - let val = OptionStruct(field: 123) - let reflectedSome = rust_reflect_option_struct_with_no_data(val) - let reflectedNone = rust_reflect_option_struct_with_no_data(nil) - - XCTAssertEqual(reflectedSome!.field, 123) - XCTAssertNil(reflectedNone) - } - - /// Verify that we can use failable initializers defined on the Rust side. - func testFailableInitializer() { - XCTAssertEqual(FailableInitType(false), nil) - let failableInitType = FailableInitType(true) - XCTAssertEqual(failableInitType!.count(), 132) - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/PointerTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/PointerTests.swift deleted file mode 100644 index 40a7ff1d..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/PointerTests.swift +++ /dev/null @@ -1,40 +0,0 @@ -// -// PointerTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/22/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class PointerTests: XCTestCase { - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testSwiftCallRustCvoid() throws { - let value = [1, 2, 3] - - let pointer = UnsafeRawPointer(value) - let pointer_mut = UnsafeMutableRawPointer(mutating: value) - - let pointer_copy = rust_echo_const_c_void(pointer) - let pointer_mut_copy = rust_echo_mut_c_void(pointer_mut) - - XCTAssertEqual(pointer, pointer_copy) - XCTAssertEqual(pointer_mut, pointer_mut_copy) - } - - func testRustCallSwiftCvoid() throws { - rust_run_opaque_pointer_tests() - } - - func testRustCallSwiftUInt8() throws { - rust_run_u8_pointer_tests() - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/PrimitiveTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/PrimitiveTests.swift deleted file mode 100644 index 0ad23689..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/PrimitiveTests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// PrimitiveTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 10/3/22. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests for generic types such as `type SomeType` -class PrimitiveTests: XCTestCase { - /// Run tests where Rust calls Swift functions that take primitive args. - func testRustCallsSwiftPrimitives() throws { - test_rust_calls_swift_primitives() - } - - /// Run tests where Swift calls Rust functions that take primitive args. - func testSwiftCallsRustPrimitives() throws { - XCTAssertEqual(rust_double_u8(10), 20); - XCTAssertEqual(rust_double_i8(10), 20); - XCTAssertEqual(rust_double_u16(10), 20); - XCTAssertEqual(rust_double_i16(10), 20); - XCTAssertEqual(rust_double_u32(10), 20); - XCTAssertEqual(rust_double_i32(10), 20); - XCTAssertEqual(rust_double_u64(10), 20); - XCTAssertEqual(rust_double_i64(10), 20); - XCTAssertEqual(rust_double_f32(10.0), 20.0); - XCTAssertEqual(rust_double_f64(10.0), 20.0); - XCTAssertEqual(rust_negate_bool(true), false); - XCTAssertEqual(rust_negate_bool(false), true); - } -} - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift deleted file mode 100644 index 058ec2e1..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift +++ /dev/null @@ -1,275 +0,0 @@ -// -// ResultTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 9/20/22. - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class ResultTests: XCTestCase { - /// Verify that we can pass a Result from Swift -> Rust - func testSwiftCallRustResultString() throws { - rust_func_takes_result_string(.Ok("Success Message")) - rust_func_takes_result_string(.Err("Error Message")) - } - - /// Verify that we can pass a Result from Swift -> Rust - func testSwiftCallRustResultOpaqueRust() throws { - let reflectedOk = try! rust_func_reflect_result_opaque_rust( - .Ok(ResultTestOpaqueRustType(111)) - ) - XCTAssertEqual(reflectedOk.val(), 111) - - do { - let _ = try rust_func_reflect_result_opaque_rust( - .Err(ResultTestOpaqueRustType(222)) - ) - XCTFail("The function should have returned an error.") - } catch let error as ResultTestOpaqueRustType { - XCTAssertEqual(error.val(), 222) - } - } - - /// Verify that we can pass a Result from Swift -> Rust - func testSwiftCallRustResultOpaqueSwift() throws { - rust_func_takes_result_opaque_swift( - .Ok(ResultTestOpaqueSwiftType(val: 555)) - ) - rust_func_takes_result_opaque_swift( - .Err(ResultTestOpaqueSwiftType(val: 666)) - ) - } - - /// Verify that we can receive a Result<(), OpaqueRust> from Rust - func testSwiftCallRustResultNullOpaqueRust() throws { - try! rust_func_return_result_null_opaque_rust(true) - - do { - try rust_func_return_result_null_opaque_rust(false) - XCTFail("The function should have returned an error.") - } catch let error as ResultTestOpaqueRustType { - XCTAssertEqual(error.val(), 222) - } - } - - /// Verify that we can receive a Result from Rust - func testSwiftCallRustResultUnitStructOpaqueRust() throws { - try! rust_func_return_result_unit_struct_opaque_rust(true) - - do { - try rust_func_return_result_unit_struct_opaque_rust(false) - XCTFail("The function should have returned an error.") - } catch let error as ResultTestOpaqueRustType { - XCTAssertEqual(error.val(), 222) - } - } - - /// Verify that we can receive a Result from Rust - func testResultOpaqueRustTransparentEnum() throws { - XCTContext.runActivity(named: "Should return a ResultTestOpaqueRustType") { - _ in - do { - let _ :ResultTestOpaqueRustType = try rust_func_return_result_opaque_rust_transparent_enum(true) - } catch { - XCTFail() - } - } - - XCTContext.runActivity(named: "Should throw an error") { - _ in - do { - let _: ResultTestOpaqueRustType = try rust_func_return_result_opaque_rust_transparent_enum(false) - XCTFail("The function should have returned an error.") - } catch let error as ResultTransparentEnum { - switch error { - case .NamedField(let data): - XCTAssertEqual(data, 123) - case .UnnamedFields(_, _): - XCTFail() - case .NoFields: - XCTFail() - } - } catch { - XCTFail() - } - } - } - - /// Verify that we can receive a Result from Rust - func testResultTransparentEnumOpaqueRust() throws { - XCTContext.runActivity(named: "Should return a ResultTestOpaqueRustType") { - _ in - do { - let resultTransparentEnum : ResultTransparentEnum = try rust_func_return_result_transparent_enum_opaque_rust(true) - switch resultTransparentEnum { - case .NamedField(let data): - XCTAssertEqual(data, 123) - case .UnnamedFields(_, _): - XCTFail() - case .NoFields: - XCTFail() - } - } catch { - XCTFail() - } - } - - XCTContext.runActivity(named: "Should throw an error") { - _ in - do { - let _: ResultTransparentEnum = try rust_func_return_result_transparent_enum_opaque_rust(false) - XCTFail("The function should have returned an error.") - } catch _ as ResultTestOpaqueRustType { - - } catch { - XCTFail() - } - } - } - - /// Verify that we can receive a Result<(), TransparentEnum> from Rust - func testResultUnitTypeTransparentEnum() throws { - XCTContext.runActivity(named: "Should return a Unit type") { - _ in - do { - let _ :() = try rust_func_return_result_unit_type_enum_opaque_rust(true) - } catch { - XCTFail() - } - } - - XCTContext.runActivity(named: "Should throw an error") { - _ in - do { - let _ :() = try rust_func_return_result_unit_type_enum_opaque_rust(false) - XCTFail("The function should have returned an error.") - } catch let error as ResultTransparentEnum { - switch error { - case .NamedField(let data): - XCTAssertEqual(data, 123) - case .UnnamedFields(_, _): - XCTFail() - case .NoFields: - XCTFail() - } - } catch { - XCTFail() - } - } - } - - /// Verify that we can receive a Result<(primitive type, OpaqueRustType, String), TransparentEnum> from Rust - func testResultTupleTransparentEnum() throws { - XCTContext.runActivity(named: "Should return a tuple type") { - _ in - do { - let tuple: (Int32, ResultTestOpaqueRustType, RustString) = try rust_func_return_result_tuple_transparent_enum(true) - XCTAssertEqual(tuple.0, 123) - XCTAssertEqual(tuple.1.val(), ResultTestOpaqueRustType(123).val()) - XCTAssertEqual(tuple.2.toString(), "hello") - } catch { - XCTFail() - } - } - - XCTContext.runActivity(named: "Should throw an error") { - _ in - do { - let _: (Int32, ResultTestOpaqueRustType, RustString) = try rust_func_return_result_tuple_transparent_enum(false) - XCTFail("The function should have returned an error.") - } catch let error as ResultTransparentEnum { - switch error { - case .NamedField(let data): - XCTAssertEqual(data, -123) - case .UnnamedFields(_, _): - XCTFail() - case .NoFields: - XCTFail() - } - } catch { - XCTFail() - } - } - } - - /// Verify that we can receive a Result<(), TransparentStruct> from Rust - func testResultNullTransparentStruct() throws { - try! rust_func_return_result_null_transparent_struct(true) - - do { - try rust_func_return_result_null_transparent_struct(false) - XCTFail("The function should have returned an error.") - } catch let error as ResultTransparentStruct { - XCTAssertEqual(error.inner.toString(), "failed") - } - - XCTContext.runActivity(named: "Should return a Unit type") { - _ in - do { - let _ :() = try rust_func_return_result_unit_type_enum_opaque_rust(true) - } catch { - XCTFail() - } - } - - XCTContext.runActivity(named: "Should throw an error") { - _ in - do { - let _ :() = try rust_func_return_result_unit_type_enum_opaque_rust(false) - XCTFail("The function should have returned an error.") - } catch let error as ResultTransparentEnum { - switch error { - case .NamedField(let data): - XCTAssertEqual(data, 123) - case .UnnamedFields(_, _): - XCTFail() - case .NoFields: - XCTFail() - } - } catch { - XCTFail() - } - } - } - - /// Verify that we can receive a Result, OpaqueRust> from Rust - func testSwiftCallRustResultVecUInt32Rust() throws { - let vec = try! rust_func_return_result_of_vec_u32() - XCTAssertEqual(vec.len(), 3) - for (i, value) in vec.enumerated() { - XCTAssertEqual(UInt32(i), value) - } - } - - func testSwiftCallRustResultVecOpaqueRust() throws { - let vec = try! rust_func_return_result_of_vec_opaque() - XCTAssertEqual(vec.len(), 3) - for (i, value) in vec.enumerated() { - XCTAssertEqual(UInt32(i), value.val()) - } - } - - /// Verify that we can use throwing initializers defined on the Rust side. - func testThrowingInitializers() throws { - XCTContext.runActivity(named: "Should fail") { - _ in - do { - let throwingInitializer = try ThrowingInitializer(false) - } catch let error as ResultTransparentEnum { - if case .NamedField(data: -123) = error { - // This case should pass. - } else { - XCTFail() - } - } catch { - XCTFail() - } - } - XCTContext.runActivity(named: "Should succeed") { - _ in - let throwingInitializer = try! ThrowingInitializer(true) - XCTAssertEqual(throwingInitializer.val(), 123) - } - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/RustFnUsesOpaqueSwiftTypeTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/RustFnUsesOpaqueSwiftTypeTests.swift deleted file mode 100644 index a36b4d9c..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/RustFnUsesOpaqueSwiftTypeTests.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// RustFnReturnOpaqueSwiftTypeTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/27/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class RustFnReturnOpaqueSwiftTypeTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testRustFnReturnOpaqueSwiftType() throws { - let someSwiftType = rust_fn_return_opaque_swift_type() - XCTAssertEqual(someSwiftType.text, "I was initialized from Rust") - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedEnumAttributeTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedEnumAttributeTests.swift deleted file mode 100644 index 0572fb59..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedEnumAttributeTests.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// SharedEnumAttributeTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 12/15/22. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests for attributes on transparent enum types. -class SharedEnumAttributeTests: XCTestCase { - /// Verify that we change the Swift name of a transparent enum. - func testSharedEnumSwiftName() throws { - XCTAssertEqual( - extern_rust_enum_rename( - EnumRename.Variant1 - ), - EnumRename.Variant1 - ) - } - - - /// Verify that we can call a rust function from swift that uses a type that was already declared in a different bridge module. - func testSharedEnumAlreadyDeclared() throws { - XCTAssertEqual( - rust_reflect_already_declared_enum( - AlreadyDeclaredEnumTest.Variant - ), - AlreadyDeclaredEnumTest.Variant - ) - } - - /// Verify that we can call a swift function from rust that uses a type that was already declared in a different bridge module. - func testRustCallsSwiftFunctionSharedEnumAlreadyDeclared() throws { - test_rust_calls_swift_already_declared_enum() - } - - /// Verify that we can use the generated Debug impl. - func testSharedEnumDeriveDebug() throws { - let debugString = String(reflecting: DeriveDebugEnum.Variant) - XCTAssertEqual(debugString, "Variant") - } - -} - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedEnumTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedEnumTests.swift deleted file mode 100644 index c4abcba0..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedEnumTests.swift +++ /dev/null @@ -1,131 +0,0 @@ -// -// SharedEnumTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 2/8/22. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class SharedEnumTests: XCTestCase { - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testEnumWithNoData() { - let enumWithNoData1 = EnumWithNoData.Variant1 - let enumWithNoData2 = EnumWithNoData.Variant2 - - let reflected1 = reflect_enum_with_no_data(enumWithNoData1) - let reflected2 = reflect_enum_with_no_data(enumWithNoData2) - - switch (reflected1, reflected2) { - case (.Variant1, .Variant2): - break; - default: - XCTFail() - } - } - - func testEnumWithUnnamedData() { - let enumWithUnnamedData1 = EnumWithUnnamedData.TwoFields(create_string("hello"), OpaqueRustForEnumTest()) - switch reflect_enum_with_unnamed_data(enumWithUnnamedData1) { - case .TwoFields(let rustString, let opaqueRustForEnumTest): - XCTAssertEqual(rustString.toString(), "hello") - XCTAssertEqual(opaqueRustForEnumTest, OpaqueRustForEnumTest()) - default: - XCTFail() - } - - let enumWithUnnamedData2 = EnumWithUnnamedData.OneField(1000) - switch reflect_enum_with_unnamed_data(enumWithUnnamedData2) { - case .OneField(let valueInt32): - XCTAssertEqual(valueInt32, 1000) - default: - XCTFail() - } - - let enumWithUnnamedData3 = EnumWithUnnamedData.NoFields - switch reflect_enum_with_unnamed_data(enumWithUnnamedData3) { - case .NoFields: - break - default: - XCTFail() - } - } - - func testEnumWithNamedData() { - let enumWithNamedData1 = EnumWithNamedData.TwoFields(hello: create_string("hello"), data_u8: 123) - switch reflect_enum_with_named_data(enumWithNamedData1) { - case .TwoFields(let hello, let dataU8): - XCTAssertEqual(hello.toString(), "hello") - XCTAssertEqual(dataU8, 123) - default: - XCTFail() - } - - let enumWithNamedData2 = EnumWithNamedData.OneField(data_i32: -123) - switch reflect_enum_with_named_data(enumWithNamedData2) { - case .OneField(let dataI32): - XCTAssertEqual(dataI32, -123) - default: - XCTFail() - } - - let enumWithNamedData3 = EnumWithNamedData.NoFields - switch reflect_enum_with_named_data(enumWithNamedData3) { - case .NoFields: - break - default: - XCTFail() - } - } - - func testEnumWithOpaqueRust() { - let named = EnumWithOpaqueRust.Named(data: OpaqueRustForEnumTest()) - switch reflect_enum_with_opaque_type(named) { - case .Named(let value): - XCTAssertEqual(value, OpaqueRustForEnumTest()) - case .Unnamed(_): - XCTFail() - } - - let unnamed = EnumWithOpaqueRust.Unnamed(OpaqueRustForEnumTest()) - switch reflect_enum_with_opaque_type(unnamed) { - case .Named(_): - XCTFail() - case .Unnamed(let value): - XCTAssertEqual(value, OpaqueRustForEnumTest()) - } - } - - func testEnumWithGenericOpaqueRust() { - let named = EnumWithGenericOpaqueRust.Named(data: new_generic_opaque_rust_for_enum_test()) - switch reflect_enum_with_generic_opaque_type(named) { - case .Named(_): - // TODO: call a method on GenericOpaqueRustForEnumTest - // after we add support for methods on generic opaque Rust Types. - // See https://github.com/chinedufn/swift-bridge/issues/44#issuecomment-1114198605 - break - case .Unnamed(_): - XCTFail() - } - - let unnamed = EnumWithGenericOpaqueRust.Unnamed(new_generic_opaque_rust_for_enum_test()) - switch reflect_enum_with_generic_opaque_type(unnamed) { - case .Named(_): - XCTFail() - case .Unnamed(_): - // TODO: call a method on GenericOpaqueRustForEnumTest - // after we add support for methods on generic opaque Rust Types. - // See https://github.com/chinedufn/swift-bridge/issues/44#issuecomment-1114198605 - break - } - } - -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedStructAttributeTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedStructAttributeTests.swift deleted file mode 100644 index c24d6d62..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedStructAttributeTests.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// SharedStructAttributeTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 1/6/22. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests for attributes on shared structs types. -class SharedStructAttributeTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - /// Verify that we can call a function that uses a type that was already declared in a different bridge module. - /// See crates/swift-integration-tests/src/struct_attributes/already_declared.rs - func testSharedStructAlreadyDeclaredCallInitializer() throws { - let val = AlreadyDeclaredStructTest(field: 123) - - XCTAssertEqual( - rust_reflect_already_declared_struct(val).field, - 123 - ) - } - - /// Verify that we can call a swift function from rust that uses a type that was already declared in a different bridge module. - func testSharedStructAlreadyDeclared() throws { - test_rust_calls_swift_already_declared_struct() - } -} - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedStructTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedStructTests.swift deleted file mode 100644 index 8d3efd57..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SharedStructTests.swift +++ /dev/null @@ -1,55 +0,0 @@ -// -// ExternalCTypes.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/24/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class SharedStructTests: XCTestCase { - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - /// Run all of the tests that are defined on the Rust side in - /// crates/swift-integration-tests/src/shared_types/shared_struct.rs - func testRust() { - test_rust_calls_swift() - } - - func testStructWithNoFields() { - let _: StructWithNoFields = swift_calls_rust_struct_with_no_fields(StructWithNoFields()) - } - - func testStructReprStructWithOnePrimitiveField() { - let val = swift_calls_rust_struct_repr_struct_one_primitive_field( - StructReprStructWithOnePrimitiveField(named_field: 56) - ); - XCTAssertEqual(val.named_field, 56) - } - - /// Verify that we can pass a transparent struct that contains a String back and forth between Rust and Swift. - /// `SharedStruct { field: String }`. - func testStructReprStructWithOneStringField() { - let val = rust_calls_swift_struct_repr_struct_one_string_field( - arg: StructReprStructWithOneStringField(field: "hello world".intoRustString()) - ); - XCTAssertEqual(val.field.toString(), "hello world") - } - - - /// Verify that we can create a tuple struct. - func testTupleStruct() { - let val = StructReprStructTupleStruct(_0: 11, _1: 22) - let reflected = swift_calls_rust_tuple_struct(val) - - XCTAssertEqual(val._0, reflected._0) - XCTAssertEqual(val._1, reflected._1) - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SingleRepresentationTypeElisionTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SingleRepresentationTypeElisionTests.swift deleted file mode 100644 index cfe321a2..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SingleRepresentationTypeElisionTests.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// SingleRepresentationTypeElisionTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 2/23/23. -// - -import Foundation - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Test that we can call functions that have elided single representation types. -/// See: -/// - crates/swift-bridge-ir/src/codegen/codegen_tests/single_representation_type_elision_codegen_tests.rs -/// - crates/swift-integration-tests/src/single_representation_type_elision.rs -final class SingleRepresentationTypeElisionTest: XCTestCase { - /// Verify that we can call functions that take the null type. - func testSwiftCallsRustNullType() throws { - let _: () = rust_one_null_arg(()) - let _: () = rust_two_null_args((), ()) - } - - /// Verify that we can call functions that take a unit struct. - func testSwiftCallsRustUnitStruct() throws { - let _: SingleReprTestUnitStruct = rust_one_unit_struct(SingleReprTestUnitStruct()) - let _: SingleReprTestUnitStruct = rust_two_unit_structs(SingleReprTestUnitStruct(), SingleReprTestUnitStruct()) - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/StringTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/StringTests.swift deleted file mode 100644 index 8c52818a..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/StringTests.swift +++ /dev/null @@ -1,71 +0,0 @@ -// -// SwiftRustIntegrationTestRunnerTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/14/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class StringTests: XCTestCase { - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testRunRustCallsSwiftTests() throws { - run_string_tests() - } - - /// Verify that we can get a RustString's length - func testRustStringLen() throws { - let string = " hello " - let rustString: RustString = create_string(string) - - XCTAssertEqual(rustString.len(), 7) - } - - /// Verify that we can trim a RustString - func testTrimRustString() throws { - let string = " hello " - let rustString: RustString = create_string(string) - - let trimmed: RustStr = rustString.trim() - XCTAssertEqual(trimmed.len, 5) - } - - func testRustStringToString() throws { - let string = "hi" - - XCTAssertEqual( - create_string(string).toString(), - "hi" - ) - } - - func testRustStrEqualityOperator() throws { - XCTContext.runActivity(named: "Should be equal"){ - _ in - let hello1 = create_string("hello") - let hello2 = create_string("hello") - XCTAssertEqual(hello1.as_str(), hello2.as_str()) - } - XCTContext.runActivity(named: "Should not be equal"){ - _ in - //Not equal length - let hi = create_string("hi") - let hello = create_string("hello") - XCTAssertNotEqual(hi.as_str(), hello.as_str()) - - //Equal length - let foo = create_string("foo") - let bar = create_string("bar") - XCTAssertNotEqual(foo.as_str(), bar.as_str()) - } - } -} - diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SwiftFnUsesOpaqueRustTypeTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SwiftFnUsesOpaqueRustTypeTests.swift deleted file mode 100644 index e27d31ca..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SwiftFnUsesOpaqueRustTypeTests.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// SwiftFnUsesOpaqueRustTypeTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/28/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - - -class SwiftFnUsesOpaqueRustTypeTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testRustFnCallsWithFnWithOwnedOpaqueArg() throws { - test_call_swift_fn_with_owned_opaque_rust_arg() - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SwiftFnUsesOpaqueSwiftTypeTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SwiftFnUsesOpaqueSwiftTypeTests.swift deleted file mode 100644 index 20b2f8d2..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/SwiftFnUsesOpaqueSwiftTypeTests.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// SwiftFnUsesOpaqueSwiftTypeTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 8/23/22. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class SwiftFnReturnOpaqueSwiftTypeTests: XCTestCase { - - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testSwiftFnReturnOpaqueSwiftType() throws { - test_rust_calls_swift_fn_reflects_owned_opaque_swift_type() - } - - func testSwiftMethodReturnOpaqueSwiftType() throws { - test_rust_calls_swift_method_reflects_owned_opaque_swift_type() - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/TupleTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/TupleTests.swift deleted file mode 100644 index f445dd93..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/TupleTests.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// TupleTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Niwaka on 2023/03/12. -// - -import Foundation - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -/// Tests tuples -final class TupleTest: XCTestCase { - /// Verify that we can pass and return Rust tuples. - func testSwiftCallsRustTuples() throws { - XCTContext.runActivity(named: "Verify that we can pass and return a (primitive type, primitive type).") { - _ in - let tuple = rust_reflect_tuple_primitives((-1, 10)) - XCTAssertEqual(tuple.0, -1) - XCTAssertEqual(tuple.1, 10) - } - XCTContext.runActivity(named: "Verify that we can pass and return a (OpaqueRustType, String, primitive type).") { - _ in - let tuple = rust_reflect_tuple_opaque_rust_and_string_and_primitive((TupleTestOpaqueRustType(123), "foo", 128)) - XCTAssertEqual(tuple.0.val(), 123) - XCTAssertEqual(tuple.1.toString(), "foo") - XCTAssertEqual(tuple.2, 128) - } - XCTContext.runActivity(named: "Verify that we can pass and return a (F64, UInt, Bool).") { - _ in - let tuple = rust_reflect_tuple_f64_and_usize_and_bool((0.1, 123, true)) - XCTAssertEqual(tuple.0, 0.1) - XCTAssertEqual(tuple.1, 123) - XCTAssertEqual(tuple.2, true) - } - } - - /// Verify that Rust can call Swift functions that accept and return Tuples. - func testRustCallsSwiftTuple() throws { - test_rust_calls_swift_tuples() - } -} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/VecTests.swift b/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/VecTests.swift deleted file mode 100644 index e81b51a1..00000000 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/VecTests.swift +++ /dev/null @@ -1,133 +0,0 @@ -// -// VecTests.swift -// SwiftRustIntegrationTestRunnerTests -// -// Created by Frankie Nwafili on 11/21/21. -// - -import XCTest -@testable import SwiftRustIntegrationTestRunner - -class VecTests: XCTestCase { - override func setUpWithError() throws { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDownWithError() throws { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testRustVecU8Len() throws { - let vec = RustVec() - XCTAssertEqual(vec.len(), 0) - vec.push(value: 123) - XCTAssertEqual(vec.len(), 1) - } - func testRustVecU8Pop() throws { - let vec = RustVec() - vec.push(value: 123) - let popped = vec.pop() - XCTAssertEqual(popped, 123) - XCTAssertEqual(vec.len(), 0) - } - func testRustVecU8Get() throws { - let vec = RustVec() - vec.push(value: 111) - vec.push(value: 222) - XCTAssertEqual(vec.get(index: 1), 222) - } - func testRustVecU8AsPtr() throws { - let vec = RustVec() - vec.push(value: 10) - let ptr = vec.as_ptr() - XCTAssertEqual(ptr.pointee, 10) - } - func testRustVecU8Iterator() throws { - let vec = RustVec() - vec.push(value: 111) - vec.push(value: 222) - - var iterations = 0 - for (index, val) in vec.enumerated() { - XCTAssertEqual(val, vec[index]) - iterations += 1 - } - XCTAssertEqual(iterations, 2) - } - - func testVecOfOpaqueRustTypeLen() throws { - let vec = RustVec() - XCTAssertEqual(vec.len(), 0) - vec.push(value: ARustTypeInsideVecT("hello world")) - XCTAssertEqual(vec.len(), 1) - } - func testVecOfOpaqueRustTypeGet() throws { - let vec: RustVec = RustVec() - vec.push(value: ARustTypeInsideVecT("hello world")) - XCTAssertEqual(vec.get(index: 0)!.text().toString(), "hello world") - } - func testVecOfOpaqueRustTypePop() throws { - let vec: RustVec = RustVec() - vec.push(value: ARustTypeInsideVecT("hello world")) - - XCTAssertEqual(vec.len(), 1) - let popped = vec.pop() - XCTAssertEqual(popped?.text().toString(), "hello world") - XCTAssertEqual(vec.len(), 0) - } - - /// Verify that a Vec of opaque Rust types can be used as an argument and return - /// type for extern "Rust" functions. - func testReflectVecOfOpaqueRustType() throws { - let vec: RustVec = RustVec() - vec.push(value: ARustTypeInsideVecT("hello world")) - - let reflected = rust_reflect_vec_opaque_rust_type(vec) - XCTAssertEqual(reflected.len(), 1) - XCTAssertEqual(reflected.get(index: 0)!.text().toString(), "hello world") - } - - /// Verify that a Vec of transparent enums can be used as an argument and return - /// type for extern "Rust" functions. - func testReflectVecOfTransparentEnum() throws { - let vec: RustVec = RustVec() - vec.push(value: TransparentEnumInsideVecT.VariantB) - - let reflected = rust_reflect_vec_transparent_enum(vec) - XCTAssertEqual(reflected.len(), 1) - XCTAssertEqual(reflected.get(index: 0)!, TransparentEnumInsideVecT.VariantB) - XCTAssertEqual(reflected.pop()!, TransparentEnumInsideVecT.VariantB) - } - - /// Verify that we can construct a RustVec of every primitive type. - /// We tested all of the methods on two different primitives above to be sure that our - /// functions that generate the pieces of the RustVec support aren't accidentally hard coded to - /// only work for one type. - /// Here we call the rest of the types, confident that if we can construct them then the rest of their - /// methods will work since they worked for the other types above. - func testConstructPrimitiveRustVecs() throws { - XCTAssertEqual(RustVec().pop(), nil); - XCTAssertEqual(RustVec().len(), 0); - XCTAssertEqual(RustVec().len(), 0); - XCTAssertEqual(RustVec().len(), 0); - XCTAssertEqual(RustVec().len(), 0); - - XCTAssertEqual(RustVec().len(), 0); - XCTAssertEqual(RustVec().len(), 0); - XCTAssertEqual(RustVec().len(), 0); - XCTAssertEqual(RustVec().len(), 0); - XCTAssertEqual(RustVec().len(), 0); - - XCTAssertEqual(RustVec().len(), 0); - - XCTAssertEqual(RustVec().len(), 0); - XCTAssertEqual(RustVec().len(), 0); - } - - /// Verify that Rust can pass `RustVec`s to and receive `RustVec`s from Swift. - func testRustCallsSwiftRustVecFunctions() { - run_vec_tests() - } -} - - diff --git a/SwiftRustIntegrationTestRunner/build-rust.sh b/SwiftRustIntegrationTestRunner/build-rust.sh deleted file mode 100755 index dbd551d0..00000000 --- a/SwiftRustIntegrationTestRunner/build-rust.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -set -e - -if [[ -z "$PROJECT_DIR" ]]; then - echo "Missing PROJECT_DIR environment variable." 1>&2 - exit 1 -fi - -export PATH="$HOME/.cargo/bin:$PATH" - -# Without this we can't compile on MacOS Big Sur -# https://github.com/TimNN/cargo-lipo/issues/41#issuecomment-774793892 -if [[ -n "${DEVELOPER_SDK_DIR:-}" ]]; then - export LIBRARY_PATH="${DEVELOPER_SDK_DIR}/MacOSX.sdk/usr/lib:${LIBRARY_PATH:-}" -fi - -cd "$PROJECT_DIR" - -if [[ $CONFIGURATION == "Release" ]]; then - echo "BUIlDING FOR RELEASE" - - cargo build --release --manifest-path ../crates/swift-integration-tests/Cargo.toml -else - echo "BUIlDING FOR DEBUG" - - cargo build --manifest-path ../crates/swift-integration-tests/Cargo.toml -fi diff --git a/SwiftRustIntegrationTestRunner/integration-test-create-swift-package/Cargo.toml b/SwiftRustIntegrationTestRunner/integration-test-create-swift-package/Cargo.toml deleted file mode 100644 index 1b1fafa8..00000000 --- a/SwiftRustIntegrationTestRunner/integration-test-create-swift-package/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "integration-test-create-swift-package" -version = "0.1.0" -edition = "2021" -publish = false - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -swift-bridge-build = { path = "../../crates/swift-bridge-build" } diff --git a/SwiftRustIntegrationTestRunner/integration-test-create-swift-package/src/main.rs b/SwiftRustIntegrationTestRunner/integration-test-create-swift-package/src/main.rs deleted file mode 100644 index 0a058d0a..00000000 --- a/SwiftRustIntegrationTestRunner/integration-test-create-swift-package/src/main.rs +++ /dev/null @@ -1,19 +0,0 @@ -use std::collections::HashMap; -use std::path::PathBuf; - -use swift_bridge_build::ApplePlatform as Platform; -use swift_bridge_build::{create_package, CreatePackageConfig}; - -fn main() { - create_package(CreatePackageConfig { - bridge_dir: PathBuf::from("swift-package-rust-library-fixture/generated"), - paths: HashMap::from([( - Platform::MacOS, - PathBuf::from( - "swift-package-rust-library-fixture/target/universal/libtest_swift_packages.a", - ) as _, - )]), - out_dir: PathBuf::from("swift-package-rust-library-fixture/MySwiftPackage"), - package_name: "MySwiftPackage".to_string(), - }); -} diff --git a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/.gitignore b/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/.gitignore deleted file mode 100644 index 76ec3a2b..00000000 --- a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target/ -package/ -generated/ -MySwiftPackage \ No newline at end of file diff --git a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/Cargo.toml b/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/Cargo.toml deleted file mode 100644 index 670701eb..00000000 --- a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "test-swift-packages" -version = "0.1.0" -edition = "2021" -publish = false - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["staticlib"] - -[build-dependencies] -swift-bridge-build = { path = "../../crates/swift-bridge-build" } - -[dependencies] -swift-bridge = { path = "../.." } diff --git a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/build.rs b/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/build.rs deleted file mode 100644 index 284d926e..00000000 --- a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/build.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::path::PathBuf; - -fn main() { - let out_dir = PathBuf::from("./generated"); - - let bridges = vec!["src/lib.rs"]; - for path in &bridges { - println!("cargo:rerun-if-changed={}", path); - } - - swift_bridge_build::parse_bridges(bridges) - .write_all_concatenated(out_dir, env!("CARGO_PKG_NAME")); -} diff --git a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/build.sh b/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/build.sh deleted file mode 100755 index 86bc3c7e..00000000 --- a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -THIS_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) -ROOT_DIR="$THIS_DIR" -cd $ROOT_DIR - -cargo build --target x86_64-apple-darwin --target-dir "$(pwd)/target" -cargo build --target aarch64-apple-darwin --target-dir "$(pwd)/target" - -mkdir -p "$(pwd)/target/universal/" - -lipo \ - $(pwd)/target/aarch64-apple-darwin/debug/libtest_swift_packages.a \ - $(pwd)/target/x86_64-apple-darwin/debug/libtest_swift_packages.a -create -output \ - $(pwd)/target/universal/libtest_swift_packages.a - diff --git a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/src/lib.rs b/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/src/lib.rs deleted file mode 100644 index 8582a022..00000000 --- a/SwiftRustIntegrationTestRunner/swift-package-rust-library-fixture/src/lib.rs +++ /dev/null @@ -1,18 +0,0 @@ -#[swift_bridge::bridge] -mod ffi { - extern "Rust" { - fn hello_rust() -> String; - } - - #[swift_bridge(swift_repr = "struct")] - struct SomeStruct { - field: u8, - } - - #[swift_bridge(swift_repr = "struct")] - struct UnnamedStruct(u8); -} - -fn hello_rust() -> String { - String::from("Hello, From Rust!") -} diff --git a/SwiftRustIntegrationTestRunner/swift-package-test-package/.gitignore b/SwiftRustIntegrationTestRunner/swift-package-test-package/.gitignore deleted file mode 100644 index bb460e7b..00000000 --- a/SwiftRustIntegrationTestRunner/swift-package-test-package/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.DS_Store -/.build -/Packages -/*.xcodeproj -xcuserdata/ -DerivedData/ -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata diff --git a/SwiftRustIntegrationTestRunner/swift-package-test-package/Package.swift b/SwiftRustIntegrationTestRunner/swift-package-test-package/Package.swift deleted file mode 100644 index 0c823555..00000000 --- a/SwiftRustIntegrationTestRunner/swift-package-test-package/Package.swift +++ /dev/null @@ -1,23 +0,0 @@ -// swift-tools-version:5.5 - -import PackageDescription - -let package = Package( - name: "swift-package-test-package", - products: [ - .library( - name: "swift-package-test-package", - targets: ["swift-package-test-package"]), - ], - dependencies: [ - .package(path: "../swift-package-rust-library-fixture/MySwiftPackage") - ], - targets: [ - .target( - name: "swift-package-test-package", - dependencies: []), - .testTarget( - name: "swift-package-test-packageTests", - dependencies: ["swift-package-test-package", "MySwiftPackage"]), - ] -) diff --git a/SwiftRustIntegrationTestRunner/swift-package-test-package/Sources/swift-package-test-package/swift_package_test_package.swift b/SwiftRustIntegrationTestRunner/swift-package-test-package/Sources/swift-package-test-package/swift_package_test_package.swift deleted file mode 100644 index 8b137891..00000000 --- a/SwiftRustIntegrationTestRunner/swift-package-test-package/Sources/swift-package-test-package/swift_package_test_package.swift +++ /dev/null @@ -1 +0,0 @@ - diff --git a/SwiftRustIntegrationTestRunner/swift-package-test-package/Tests/swift-package-test-packageTests/swift_package_test_packageTests.swift b/SwiftRustIntegrationTestRunner/swift-package-test-package/Tests/swift-package-test-packageTests/swift_package_test_packageTests.swift deleted file mode 100644 index 92624c86..00000000 --- a/SwiftRustIntegrationTestRunner/swift-package-test-package/Tests/swift-package-test-packageTests/swift_package_test_packageTests.swift +++ /dev/null @@ -1,17 +0,0 @@ -import XCTest -import MySwiftPackage -@testable import swift_package_test_package - -final class swift_package_test_packageTests: XCTestCase { - func testPackageRun() throws { - XCTAssertEqual("Hello, From Rust!", hello_rust().toString()) - } - - func testInstantiateSharedStruct() throws { - XCTAssertEqual(SomeStruct(field: 1).field, 1); - } - - func testInstantiateSharedStructUnnamed() throws { - XCTAssertEqual(UnnamedStruct(_0: 1)._0, 1); - } -} diff --git a/crates/swift-integration-tests/build.rs b/crates/swift-integration-tests/build.rs index cc519062..bcbc04e5 100644 --- a/crates/swift-integration-tests/build.rs +++ b/crates/swift-integration-tests/build.rs @@ -1,8 +1,8 @@ use std::path::PathBuf; fn main() { - let out_dir = "../../SwiftRustIntegrationTestRunner/Generated"; - let out_dir = PathBuf::from(out_dir); + // TODO: we can use --artifact-dir with OUT_DIR when that stabilizes. + let out_dir = PathBuf::from("../../integration-tests/Sources/Generated"); let mut bridges = vec![]; read_files_recursive(PathBuf::from("src"), &mut bridges); diff --git a/integration-tests/.gitignore b/integration-tests/.gitignore new file mode 100644 index 00000000..24e5b0a1 --- /dev/null +++ b/integration-tests/.gitignore @@ -0,0 +1 @@ +.build diff --git a/integration-tests/.swift-format b/integration-tests/.swift-format new file mode 100644 index 00000000..eca0ade6 --- /dev/null +++ b/integration-tests/.swift-format @@ -0,0 +1,10 @@ +{ + "version": 1, + "lineLength": 100, + "indentation": { + "spaces": 4 + }, + "maximumBlankLines": 1, + "respectsExistingLineBreaks": true, + "lineBreakBeforeControlFlowKeywords": false, +} diff --git a/integration-tests/Package.swift b/integration-tests/Package.swift new file mode 100644 index 00000000..6098cf39 --- /dev/null +++ b/integration-tests/Package.swift @@ -0,0 +1,26 @@ +// swift-tools-version: 6.0 + +import PackageDescription + +let linkerSettings: [LinkerSetting] = [ + .linkedLibrary("swift_integration_tests"), + .unsafeFlags(["-L../target/debug/"]) +] + +let package = Package( + name: "IntegrationTests", + targets: [ + // The compiled static rust library. + .systemLibrary( + name: "RustLib"), + // The generated Swift wrapper code for the Rust library, plus some + // Swift code used by the Rust library. + .target( + name: "SharedLib", + dependencies: ["RustLib"], + linkerSettings: linkerSettings), + .testTarget( + name: "IntegrationTests", + dependencies: ["SharedLib", "RustLib"]), + ] +) diff --git a/SwiftRustIntegrationTestRunner/Generated/.gitignore b/integration-tests/Sources/Generated/.gitignore similarity index 100% rename from SwiftRustIntegrationTestRunner/Generated/.gitignore rename to integration-tests/Sources/Generated/.gitignore diff --git a/integration-tests/Sources/RustLib/bridge.h b/integration-tests/Sources/RustLib/bridge.h new file mode 100644 index 00000000..85c0efae --- /dev/null +++ b/integration-tests/Sources/RustLib/bridge.h @@ -0,0 +1,2 @@ +#include "../Generated/SwiftBridgeCore.h" +#include "../Generated/swift-integration-tests/swift-integration-tests.h" diff --git a/integration-tests/Sources/RustLib/module.modulemap b/integration-tests/Sources/RustLib/module.modulemap new file mode 100644 index 00000000..8535f48c --- /dev/null +++ b/integration-tests/Sources/RustLib/module.modulemap @@ -0,0 +1,5 @@ +module RustLib [system] { + header "bridge.h" + link "swift_integration_tests" + export * +} diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/ASwiftStack.swift b/integration-tests/Sources/SharedLib/ASwiftStack.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/ASwiftStack.swift rename to integration-tests/Sources/SharedLib/ASwiftStack.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Callbacks.swift b/integration-tests/Sources/SharedLib/Callbacks.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Callbacks.swift rename to integration-tests/Sources/SharedLib/Callbacks.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/FunctionAttributes.swift b/integration-tests/Sources/SharedLib/FunctionAttributes.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/FunctionAttributes.swift rename to integration-tests/Sources/SharedLib/FunctionAttributes.swift diff --git a/integration-tests/Sources/SharedLib/Generated/.gitignore b/integration-tests/Sources/SharedLib/Generated/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/integration-tests/Sources/SharedLib/Generated/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Option.swift b/integration-tests/Sources/SharedLib/Option.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Option.swift rename to integration-tests/Sources/SharedLib/Option.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Pointer.swift b/integration-tests/Sources/SharedLib/Pointer.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Pointer.swift rename to integration-tests/Sources/SharedLib/Pointer.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Primitive.swift b/integration-tests/Sources/SharedLib/Primitive.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Primitive.swift rename to integration-tests/Sources/SharedLib/Primitive.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Result.swift b/integration-tests/Sources/SharedLib/Result.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Result.swift rename to integration-tests/Sources/SharedLib/Result.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/RustFnUsesOpaqueSwiftType.swift b/integration-tests/Sources/SharedLib/RustFnUsesOpaqueSwiftType.swift similarity index 95% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/RustFnUsesOpaqueSwiftType.swift rename to integration-tests/Sources/SharedLib/RustFnUsesOpaqueSwiftType.swift index 1c4138fe..d2cb9721 100644 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/RustFnUsesOpaqueSwiftType.swift +++ b/integration-tests/Sources/SharedLib/RustFnUsesOpaqueSwiftType.swift @@ -6,15 +6,16 @@ // import Foundation +import RustLib /// We expose this to the `rust_function_return_swift_type.rs` test. public class SomeSwiftType { var text: String - + init() { text = "initial text" } - + func setText(text: RustStr) { self.text = text.toString() } diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SharedEnumAttributes.swift b/integration-tests/Sources/SharedLib/SharedEnumAttributes.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SharedEnumAttributes.swift rename to integration-tests/Sources/SharedLib/SharedEnumAttributes.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SharedStruct.swift b/integration-tests/Sources/SharedLib/SharedStruct.swift similarity index 56% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SharedStruct.swift rename to integration-tests/Sources/SharedLib/SharedStruct.swift index 36648391..c0504972 100644 --- a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SharedStruct.swift +++ b/integration-tests/Sources/SharedLib/SharedStruct.swift @@ -6,15 +6,20 @@ // import Foundation +import RustLib func rust_calls_swift_struct_with_no_fields(arg: StructWithNoFields) -> StructWithNoFields { arg } -func rust_calls_swift_struct_repr_struct_one_primitive_field(arg: StructReprStructWithOnePrimitiveField) -> StructReprStructWithOnePrimitiveField { +func rust_calls_swift_struct_repr_struct_one_primitive_field( + arg: StructReprStructWithOnePrimitiveField +) -> StructReprStructWithOnePrimitiveField { arg } -func rust_calls_swift_struct_repr_struct_one_string_field(arg: StructReprStructWithOneStringField) -> StructReprStructWithOneStringField { +func rust_calls_swift_struct_repr_struct_one_string_field(arg: StructReprStructWithOneStringField) + -> StructReprStructWithOneStringField +{ arg } diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SharedStructAttributes.swift b/integration-tests/Sources/SharedLib/SharedStructAttributes.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SharedStructAttributes.swift rename to integration-tests/Sources/SharedLib/SharedStructAttributes.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/String.swift b/integration-tests/Sources/SharedLib/String.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/String.swift rename to integration-tests/Sources/SharedLib/String.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftFnUsesOpaqueRustType.swift b/integration-tests/Sources/SharedLib/SwiftFnUsesOpaqueRustType.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftFnUsesOpaqueRustType.swift rename to integration-tests/Sources/SharedLib/SwiftFnUsesOpaqueRustType.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftFnUsesOpaqueSwiftType.swift b/integration-tests/Sources/SharedLib/SwiftFnUsesOpaqueSwiftType.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/SwiftFnUsesOpaqueSwiftType.swift rename to integration-tests/Sources/SharedLib/SwiftFnUsesOpaqueSwiftType.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Tuple.swift b/integration-tests/Sources/SharedLib/Tuple.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Tuple.swift rename to integration-tests/Sources/SharedLib/Tuple.swift diff --git a/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Vec.swift b/integration-tests/Sources/SharedLib/Vec.swift similarity index 100% rename from SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunner/Vec.swift rename to integration-tests/Sources/SharedLib/Vec.swift diff --git a/integration-tests/Tests/IntegrationTests/PrimitiveTests.swift b/integration-tests/Tests/IntegrationTests/PrimitiveTests.swift new file mode 100644 index 00000000..c7d75730 --- /dev/null +++ b/integration-tests/Tests/IntegrationTests/PrimitiveTests.swift @@ -0,0 +1,28 @@ +import RustLib +import XCTest + +@testable import SharedLib + +/// Tests for generic types such as `type SomeType` +class PrimitiveTests: XCTestCase { + /// Run tests where Rust calls Swift functions that take primitive args. + func testRustCallsSwiftPrimitives() throws { + test_rust_calls_swift_primitives() + } + + /// Run tests where Swift calls Rust functions that take primitive args. + func testSwiftCallsRustPrimitives() throws { + XCTAssertEqual(rust_double_u8(10), 20) + XCTAssertEqual(rust_double_i8(10), 20) + XCTAssertEqual(rust_double_u16(10), 20) + XCTAssertEqual(rust_double_i16(10), 20) + XCTAssertEqual(rust_double_u32(10), 20) + XCTAssertEqual(rust_double_i32(10), 20) + XCTAssertEqual(rust_double_u64(10), 20) + XCTAssertEqual(rust_double_i64(10), 20) + XCTAssertEqual(rust_double_f32(10.0), 20.0) + XCTAssertEqual(rust_double_f64(10.0), 20.0) + XCTAssertEqual(rust_negate_bool(true), false) + XCTAssertEqual(rust_negate_bool(false), true) + } +} diff --git a/test-swift-rust-integration.sh b/test-swift-rust-integration.sh index bc6d7946..ef077007 100755 --- a/test-swift-rust-integration.sh +++ b/test-swift-rust-integration.sh @@ -1,8 +1,4 @@ -#!/bin/bash - -# Integration tests between Swift and Rust - -set -e +#!/bin/bash -e export RUSTFLAGS="-D warnings" @@ -11,17 +7,19 @@ THIS_DIR=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) ROOT_DIR="$THIS_DIR" cd "$ROOT_DIR" -cd SwiftRustIntegrationTestRunner -# If project files don't exist before Xcode begins building we get something like: -# error: Build input file cannot be found: '/path/to/Generated/SwiftBridgeCore.swift' -# So.. here we create empty versions of the files that will get generated during the -# build so that Xcode knows about them. -# During the build process these will get overwritten with their real final contents. -touch ./Generated/SwiftBridgeCore.{h,swift} -mkdir -p ./Generated/swift-integration-tests -touch ./Generated/swift-integration-tests/swift-integration-tests.{h,swift} +# Compile the rust library used by the integration tests. +cargo build --manifest-path crates/swift-integration-tests/Cargo.toml + +# Create a swift file with the generated swift code and an import for the +# generated C code. This is necessary because SPM projects don't support +# mixed-source - the C code has to be a separate SPM target. +OUT_DIR="integration-tests/Sources/Generated" +DST="integration-tests/Sources/SharedLib/Generated/SharedLib.swift" +echo "import RustLib" > "$DST" +cat "${OUT_DIR}/SwiftBridgeCore.swift" >> "$DST" +cat "${OUT_DIR}/swift-integration-tests/swift-integration-tests.swift" >> "$DST" + +# Run the swift package tests. Note that we have to instruct swift where to look +# for the rust static lib. +(cd integration-tests && swift test) -xcodebuild \ - -project SwiftRustIntegrationTestRunner.xcodeproj \ - -scheme SwiftRustIntegrationTestRunner \ - clean test