MakeAWishFoundation / SwiftyMocky

Framework for automatic mock generation. Adds a set of handy methods, simplifying testing. One of the best and most complete solutions, including generics support and much more.
MIT License
1.03k stars 104 forks source link

Support for async codegen and Sourcery 2.2.3 #359

Open art-divin opened 5 months ago

art-divin commented 5 months ago

Related to https://github.com/krzysztofzablocki/Sourcery/pull/1308

Context

This PR adds facilities to support concurrent codegen based on swifttemplate

Details

In order to be able to generate the code concurrently for every type, shared state needs to be removed.

This PR does the following:

  1. Removes all the shared state
  2. Update Sourcery version to 2.2.3
  3. Small improvements / refactoring
markst commented 5 months ago

This could probably overrule https://github.com/MakeAWishFoundation/SwiftyMocky/pull/352

markst commented 1 month ago

We might also need to update kSourceryVersion in Global.swift for the CLI: https://github.com/MakeAWishFoundation/SwiftyMocky/blob/master/Sources/CLI/Core/Utils/Global.swift#L5

markst commented 1 month ago

I've built from this branch multiple times:

swift build --disable-sandbox -c release

but using the build binary:

./swiftymocky generate --disableCache --verbose

Insists on the template including characters.split which fails post Swift 5:

❌  Error: ShellOut encountered an error
Status code: 3
Message: "Building for production...
[0/5] Write sources
[2/5] Write swift-version-33747A42983211AE.txt
[4/7] Emitting module SourceryRuntime
[5/7] Compiling SourceryRuntime AccessLevel.swift
[6/9] Emitting module SwiftTemplate
[7/9] Compiling SwiftTemplate main.swift
/private/var/folders/qv/k4c8t3_95tzc96m0cpv30tn80000gq/T/SwiftTemplate/EF30FB5F-CF6A-4725-B7E7-65C3340E92C4/2.2.2/Sources/SwiftTemplate/main.swift:251:96: error: 'characters' is unavailable: Please use String directly
            split($0, byFirstOccurenceOf: " where ").0.replacingOccurrences(of: " ", with: "").characters.split(separator: ":").map(String.init).first
                                                                                               ^~~~~~~~~~
Swift.String:5:16: note: 'characters' was obsoleted in Swift 5.0

I can't work out where this template is coming from, it's determined not to use the template in your branch despite building from checked out branch.

markst commented 1 month ago

Ah! it's because we need to update the base64 encoded files at Assets.swifttemplate.mock which are used for the CLI