-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Groundwork for #1201] Rename or remove clashing variables #1239
Conversation
These variables are actually only used to set up some other variables, so we move them inside those variables’ declarations. The motivation for this change is that it’s groundwork for removing the Quick testing framework using an automated migrator tool (#1201). The migrator that I’m writing will pull all `spec` / `describe` / `context` level local variables to a single namespace for the whole file, so we need to avoid clashes. The easiest way in this particular case is to just remove the variables.
The motivation here is the same as dcf3e13 — avoiding clashes when the variables are pulled out to a file-wide namespace.
Same motivation as ef79b44.
Same motivation as ef79b44.
Same motivation as ef79b44.
Same motivation as ef79b44.
Same motivation as ef79b44.
The motivation for this change is that it’s groundwork for removing the Quick testing framework using an automated migrator tool (#1201). The migrator that I’m writing will pull all `spec` / `describe` / `context` level local variables outside of the class declaration and into fileprivate global variables. But if we let the migrator hoist this particular variable to a global with the same name, then it’ll be shadowed by XCTestCase’s `name` property, which we don’t want.
b0e3190
to
f4c0e1f
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.
I know it's just 'beautification' of the code but if it's possible you should create extension for 'JSON' type that will encode it. I don't like code repetition for encoding.
If it's not possible just ignore this comment 😁
@lukasz-szyszkowski I'd quite like to keep the scope of this PR limited to just the necessary refactorings, since it's already quite a large one as it is. Perhaps you'd like to create an issue if you think it's a problem worth fixing? |
What does this do?
Removes or renames some variables at the
spec
/describe
/context
level.Does it change the behaviour of the test suite?
No, it's just a refactor (moving variable declarations inside other ones, or renaming variables).
Why are we doing this?
It’s groundwork for removing the Quick testing framework using an automated migrator tool (#1201). The migrator that I’m writing will pull all
spec
/describe
/context
level variable and function declarations in a file into a flattened file-wide list of global declarations. This might lead to clashes if multiple contexts use the same variable name. So we rename / remove things to avoid these clashes.Note
I had hoped to avoid this step, by making the migrator automatically rename variables to avoid clashes. I had a solution almost working with
swift-refactor
but for some reason that tool wasn't correctly updating variable references inside helper function declarations. I decided not to investigate this further, since it would probably end up taking a lot of time for something that could be fixed relatively quickly by hand. It's a shame, though.