Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Vault.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Vault/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Vault/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 6.0
// swift-tools-version: 6.3

import CompilerPluginSupport
import PackageDescription
Expand Down Expand Up @@ -56,7 +56,7 @@ let package = Package(
.package(url: "https://github.com/dm-zharov/swift-security.git", exact: "2.5.1"),
.package(url: "https://github.com/gonzalezreal/swift-markdown-ui", exact: "2.4.1"),
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", exact: swiftLintVersion),
.package(url: "https://github.com/swiftlang/swift-syntax", from: "600.0.0"),
.package(url: "https://github.com/swiftlang/swift-syntax", from: "603.0.0"),
],
targets: [
.target(
Expand Down Expand Up @@ -114,7 +114,6 @@ let package = Package(
name: "TestHelpers",
dependencies: [
"FoundationExtensions",
"TestHelpersMacros",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
swiftSettings: swiftSettings,
Expand Down Expand Up @@ -232,7 +231,7 @@ let package = Package(
),
.testTarget(
name: "VaultFeedTests",
dependencies: ["VaultFeed", "VaultCore", "FoundationExtensions", "TestHelpers"],
dependencies: ["VaultFeed", "VaultCore", "FoundationExtensions", "TestHelpers", "TestHelpersMacros"],
swiftSettings: swiftSettings,
plugins: testTargetPlugins,
),
Expand All @@ -243,7 +242,7 @@ let package = Package(
),
.testTarget(
name: "FoundationExtensionsTests",
dependencies: ["FoundationExtensions", "TestHelpers"],
dependencies: ["FoundationExtensions", "TestHelpers", "TestHelpersMacros"],
swiftSettings: swiftSettings,
plugins: testTargetPlugins,
),
Expand Down
12 changes: 0 additions & 12 deletions Vault/Sources/TestHelpers/SwiftTesting/LeakTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@ public func withLeakTracking<R>(
return result
}

/// Wraps the function body in ``withLeakTracking(_:)``. Apply alongside `@Test`:
/// ```swift
/// @Test @LeakTracked
/// func myTest() throws {
/// let sut = makeSUT()
/// #expect(sut.foo)
/// }
/// ```
/// The function must be `throws` (or `async throws`).
@attached(body)
public macro LeakTracked() = #externalMacro(module: "TestHelpersMacros", type: "LeakTrackedMacro")

/// Registers `instance` with the currently active ``LeakTracker``. When the enclosing
/// ``withLeakTracking(_:)`` scope ends, an Issue is recorded if `instance` has not been
/// deallocated.
Expand Down
5 changes: 4 additions & 1 deletion Vault/Sources/TestHelpersMacros/LeakTrackedMacro.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import SwiftCompilerPlugin
import SwiftDiagnostics
import SwiftSyntax
import SwiftSyntaxMacros

#if canImport(SwiftCompilerPlugin)
import SwiftCompilerPlugin

@main
struct TestHelpersMacrosPlugin: CompilerPlugin {
let providingMacros: [any Macro.Type] = [LeakTrackedMacro.self]
}
#endif

/// Body macro that wraps the function body in a `withLeakTracking { ... }` scope. Apply alongside
/// `@Test` so that any object registered via `trackForMemoryLeaks(_:)` inside the body is verified
Expand Down
5 changes: 5 additions & 0 deletions Vault/Tests/FoundationExtensionsTests/LeakTrackedMacro.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// Wraps the function body in `withLeakTracking(_:)`.
///
/// The function must be `throws` (or `async throws`).
@attached(body)
macro LeakTracked() = #externalMacro(module: "TestHelpersMacros", type: "LeakTrackedMacro")
5 changes: 5 additions & 0 deletions Vault/Tests/VaultFeedTests/LeakTrackedMacro.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// Wraps the function body in `withLeakTracking(_:)`.
///
/// The function must be `throws` (or `async throws`).
@attached(body)
macro LeakTracked() = #externalMacro(module: "TestHelpersMacros", type: "LeakTrackedMacro")