-
Notifications
You must be signed in to change notification settings - Fork 38
ignore module for import, if it matches the current module #19
Conversation
How to test this though... Couple of options:
|
Wondering if we could unit-test that change to ensure it properly ignores the module for both cases (env and param)? |
I've tested them locally, and they work. |
Should I merge now and you'll write unit tests later when you figure out something, or should I wait? |
Gimme a couple of minutes and I'll push something, we can discuss it then |
Tests/TestsHelper.swift
Outdated
Generate variations of a context. | ||
|
||
- Parameter name: The name of the context | ||
- Parameter contex: The context itself |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/contex/context/
734bc40
to
b7983d1
Compare
contextVariations: StoryboardsiOSTests.variations) | ||
} | ||
|
||
private static func enrich(_ context: [String: Any], env: [String: Any]? = nil, param: [String: Any]? = nil) -> [String: Any] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if the default value for env
shouldn't be ProcessInfo().environment
instead of nil
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno, it is a "stub" method, and we have no control over environment variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, yeah. I confused this method with the one from StencilSwiftKit
(which we should maybe use instead to ensure consistency?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would we control the env. variables then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either by modifying the method in StencilSwiftKit
to pass the env
as parameters, with default value ProcessInfo().environment
so that except from tests we don't have to specify it… or by stubbing ProcessInfo
via swizzling :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for SwiftGen/StencilSwiftKit#19 to be merged to remove the enrich
test helper function and use the one from StencilSwiftKit
instead
b7983d1
to
ff03e90
Compare
ff03e90
to
78a34bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nitpickings, otherwise OK to merge
Tests/Pods/StencilSwiftKit/README.md
Outdated
] | ||
``` | ||
|
||
For easier use, you can use the `enrich(context:parameters:)` function to add the following variables to a context: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StencilContext.enrich(context:parameters:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn, that's in fact from the StencilSwiftKit pod, I missed it there ^^
Tests/TestsHelper.swift
Outdated
@@ -134,7 +134,7 @@ extension XCTestCase { | |||
- Parameter contextVariations: Optional closure to generate context variations. | |||
*/ | |||
func test(template templateName: String, contextNames: [String], outputPrefix: String, directory: Fixtures.Directory, contextVariations: VariationGenerator? = nil) { | |||
let template = SwiftTemplate(templateString: Fixtures.template(for: "\(templateName).stencil"), | |||
let template = StencilSwiftTemplate(templateString: Fixtures.template(for: "\(templateName).stencil"), | |||
environment: stencilSwiftEnvironment()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation
78a34bb
to
3286da5
Compare
3286da5
to
498d415
Compare
Hi @djbe, I've noticed that you didn't include this change in the |
Oh wow that's unfortunate 😦 I'll add it real quick! |
This simply introduces the use of the
env
andparam
variables, and uses it to fix SwiftGen/SwiftGen#254. The templates work as-is, but for the fix to work, SwiftGen/StencilSwiftKit#8 must first be merged and added to the contexts.Replacing (and removing)
enumName
and other variables is left for another PR.