-
Notifications
You must be signed in to change notification settings - Fork 7
AF-2152: add more tests to cover additions made in AF-1928 #4
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
Conversation
Merge Requirements Met ✅Request Rosie to automerge this pull request by including @Workiva/release-management-p in a comment.
General InformationTicket(s): Code Review(s): #4 Reviewers: evanweible-wf Additional InformationWatchlist Notifications: None
Note: This is a shortened report. Click here to view Rosie's full evaluation. |
Security InsightsNo security relevant content was detected by automated scans. Action Items
Questions or Comments? Reach out on HipChat: InfoSec Forum. |
pubspec.yaml
Outdated
@@ -0,0 +1,16 @@ | |||
name: over_react_codemode |
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.
extra e
at the end
WORKDIR /build/ | ||
ADD . /build/ | ||
ENV TERM=linux | ||
ENV TERMINFO=/etc/terminfo |
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 remember you explaining this to me before, but could you remind me why this is needed?
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.
These are need to run 'migrater.py' within CI so the tests run properly.
ENV TERM=linux | ||
ENV TERMINFO=/etc/terminfo | ||
RUN echo "Install codemod" && \ | ||
pip install git+https://github.com/georgelesica-wf/codemod@dart-convert && \ |
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.
George's PR to codemod was accepted, so I believe we can install the official facebook version of codemod now
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.
We still need George's branch because they haven't released the changes he made.
|
||
// ignore: deprecated_member_use | ||
@Required(message: 'This Prop is Required for testing purposes.') | ||
var required; |
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.
The alternative for the deprecated @Required
is @requiredProp
– let's use that and then we won't also need to ignore the deprecated member use.
|
||
// ignore: deprecated_member_use | ||
@Required(isNullable: true, message: 'This prop can be set to null!') | ||
var nullable; |
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.
@nullableRequiredProp
test/migrater_test.dart
Outdated
/// Creates a temp directory and copies the un-modified test fixtures to it. Then | ||
/// migrater.py is run on these test fixtures to make the codemod changes. | ||
Future<Null> setupAndCodemod(String pathToTestFixtureDirectory) async { | ||
final pathToMigrater = p.absolute('migrater.py'); |
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.
Since this doesn't change, you could define it as a final
var at the top of the file.
test/migrater_test.dart
Outdated
test('correctly converts components with part directive', () async { | ||
final pathToTestFixtureDirectory = p.absolute('test/test_fixtures/before_codemod/component_in_parts'); | ||
final pathToExpectedResults = p.absolute('test/test_fixtures/after_codemod/component_in_parts/component_in_part.dart'); | ||
final pathToTestFile = p.absolute('test/test_fixtures/before_codemod/component_in_parts/temp/component_in_part.dart'); |
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.
Since the makeComparison
method is creating the temp directory and running codemod on it, it should be the one to handle finding the result of the codemod script. In other words, let's update makeComparison
to figure this path out on its own instead of needing to define it for each test and pass it in.
test/migrater_test.dart
Outdated
await Process.run('/bin/bash', | ||
['-c', 'mkdir -p temp && cp -r *.dart /$pathToTempDirectory'], workingDirectory: pathToTestFixtureDirectory); | ||
|
||
await Process.start('/bin/bash', ['-c', 'python $pathToMigrater'], workingDirectory: pathToTempDirectory).then((Process process) async { |
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.
Do we need to explicitly run the script via /bin/bash
like this? Or would this work:
Process.start('python', [pathToMigrater], workingDirectory: pathToTempDirectory)...
['-c', 'mkdir -p temp && cp -r *.dart /$pathToTempDirectory'], workingDirectory: pathToTestFixtureDirectory); | ||
|
||
await Process.start('/bin/bash', ['-c', 'python $pathToMigrater'], workingDirectory: pathToTempDirectory).then((Process process) async { | ||
await process.stdin.write('A\nA\n'); |
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.
We should probably add a flag to the migrater.py script that allows us to automatically apply all changes without requiring input from stdin, that way we can just include that flag in our command above
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.
There is no way for codemod to run in a way that will accept all changes, at least not in the current release. A PR (facebookarchive/codemod#48) was made that adds the flag we want, but it hasn't been released :(
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.
That should be in George's branch though, so I think I can get this to work.
test/migrater_test.dart
Outdated
|
||
/// Makes the comparison between the expected result (migrated file) and the test file | ||
/// (the file that is migrated during the test run in a temp directory). | ||
Future<Null> makeComparison(String pathToTestFixtureDirectory, String pathToExpectedResults, String pathToTestFile) async { |
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 think a slightly simpler/cleaner approach would be for this function to accept:
- The before
File
, which it will copy to a temp directory and run the codemod script on - The after
File
, which it will compare against the result of the codemod script
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.
Looks great!!
QA +1
@Workiva/release-management-p |
@evanweible-wf I will not merge this because:
|
+1 from RM |
DO NOT MERGE UNTIL #2 IS MERGED
Add more test to cover additions made in AF-1928.
@corwinsheahan-wf @evanweible-wf @maxwellpeterson-wf