Sourcery
Sourcery copied to clipboard
Handle methods with variadic parameters & fixed generated code for existential parameters
1 - handle methods with variadic parameters 2 - fixed generated code for existential parameters
This PR fixes issues https://github.com/krzysztofzablocki/Sourcery/issues/1267 https://github.com/krzysztofzablocki/Sourcery/issues/1265
@rokridi Linux tests failed because in the modified stencil there is a call to isVariadic on type String and not a type from AST.
See the error text: SourceryRuntime/TypeName_Linux.swift:31: Fatal error: unable to lookup: isVariadic in String?
@rokridi Linux tests failed because in the modified stencil there is a call to isVariadic on type String and not a type from AST.
See the error text: SourceryRuntime/TypeName_Linux.swift:31: Fatal error: unable to lookup: isVariadic in String?
How can I run tests locally ?
How can I run tests locally ?
I suggest to read Stencil carefully, and check all occurrences of isVariadic
, at least one of them is used against String type.
It is faster and more reliable to do than if to setup a VM and dive into debugging in VSCode.
If you won't be able to deduct what's wrong, feel free to tell me, I might have a chance to check it myself later this week.
Hey @pocketal ,
the last CI build failed with the following issue:
SourceryRuntime/TypeName_Linux.swift:31: Fatal error: unable to lookup: isImplicitlyUnwrappedOptional in String?
Please check in which case isImplicitlyUnwrappedOptional
is called on String type and not AST type.
resolves #1267 fixes #1265
@rokridi to make GitHub understand what needs to be automatically closed, keyword "resolves" or "fixes" needs to be put in front of each issue number like here 👆🏻 in the original post of the Merge Request.
Reference: https://github.blog/2013-05-14-closing-issues-via-pull-requests/
👋🏻 @rokridi I have run tests for macOS variant, and here are my findings:
- Extected file (AutoMockable.expected) is outdated in your branch. Please find the instructions how to update it here.
- Generated code for one of the mockable protocols is not valid swift:
class StaticMethodProtocolMock: StaticMethodProtocol {
static func reset()
{
//MARK: - staticFunction
staticFunctionStringStringCallsCount = 0
staticFunctionStringStringReceived = nil
staticFunctionStringStringReceivedInvocations = []
staticFunctionStringStringClosure = nil
}
//MARK: - staticFunction
static var staticFunctionStringStringCallsCount = 0
static var staticFunctionStringStringCalled: Bool {
return staticFunctionStringStringCallsCount > 0
}
static var staticFunctionStringStringReceived: (String)?
static var staticFunctionStringStringReceivedInvocations: [(String)] = []
static var staticFunctionStringStringReturnValue: String!
static var staticFunctionStringStringClosure: ((String) -> String)?
static func staticFunction(_ : String) -> String {
staticFunctionStringStringCallsCount += 1
staticFunctionStringStringReceived =
staticFunctionStringStringReceivedInvocations.append()
if let staticFunctionStringStringClosure = staticFunctionStringStringClosure {
return staticFunctionStringStringClosure()
} else {
return staticFunctionStringStringReturnValue
}
}
}
Everything else seems to be OK within the macOS tests context! Great work! 🤝
Hello @art-divin 👋
- Extected file (AutoMockable.expected) is outdated in your branch. Please find the instructions how to update it here.
When we follow the instructions to update AutoMockable.expected
we only get this from the generated file:
// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT
internal extension AutoCasesEnum {
static let count: Int = 4
static let allCases: [AutoCasesEnum] = [
.north,
.south,
.east,
.west
]
}
public extension AutoCasesHasAssociatedValuesEnum {
static let count: Int = 2
}
internal extension AutoCasesOneValueEnum {
static let count: Int = 1
static let allCases: [AutoCasesOneValueEnum] = [
.one
]
}
- Generated code for one of the mockable protocols is not valid swift:
This generated mock does not compile even with latest Sourcery release.
When we follow the instructions to update AutoMockable.expected we only get this from the generated file:
@rokridi yes, my mistake. You need to comment out all except AutoMockable assertion before following that instruction:
👋🏻 Hey @pocketal
Do you need any help with this PR? I could take over if you want, I am almost done with 2.1.8 release preparation at the moment, and I would love to include this fix into it.
Thanks for your contribution 👍🏻
If I would take over, I would cherry-pick your commits into a new PR and continue from there, persisting attribution.
Hey @art-divin Sorry I was very busy these days and didn't have time to look into it. You can take over if you want. Thanks for you help 🙏
Closing in favor of #1304