Skip to content

[pigeon] Recursively create output target files #4458

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

Merged

Conversation

Nitin-Poojary
Copy link
Contributor

@Nitin-Poojary Nitin-Poojary commented Jul 13, 2023

Recursively creates output target files before trying to write to it.

closes #128820

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@Nitin-Poojary Nitin-Poojary force-pushed the pigeon/create_target_files_recursively branch from f0ef9ee to c8ae34c Compare July 13, 2023 16:21
@Nitin-Poojary Nitin-Poojary marked this pull request as ready for review July 13, 2023 16:36
@tarrinneal
Copy link
Contributor

@stuartmorgan do you think this is something that can be reasonably tested?

@stuartmorgan-g
Copy link
Contributor

I don't see why not; we have lots of tests that generate output files. All we need is one that does so with a target directory that doesn't exist.

@Nitin-Poojary
Copy link
Contributor Author

I'm sorry, but I didn't quite understand your point. Could you please clarify what I need to do?

@Nitin-Poojary Nitin-Poojary force-pushed the pigeon/create_target_files_recursively branch from c8ae34c to e666bb2 Compare July 14, 2023 14:53
@tarrinneal
Copy link
Contributor

I'm sorry, but I didn't quite understand your point. Could you please clarify what I need to do?

Can you add a test in the pigeon_lib_test.dart file that tests writing a file in a directory that doesn't exist?

@Nitin-Poojary
Copy link
Contributor Author

I apologize, but I am having difficulty understanding the approach required to write this test. Could you please provide guidance or instructions on how to proceed?

@Nitin-Poojary Nitin-Poojary force-pushed the pigeon/create_target_files_recursively branch 3 times, most recently from 49d3fd2 to fb157be Compare July 19, 2023 13:50
@Nitin-Poojary
Copy link
Contributor Author

I apologize, but I am having difficulty understanding the approach required to write this test. Could you please provide guidance or instructions on how to proceed?

@stuartmorgan

@Nitin-Poojary Nitin-Poojary force-pushed the pigeon/create_target_files_recursively branch from fb157be to 1fe6fac Compare July 20, 2023 13:56
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize, but I am having difficulty understanding the approach required to write this test. Could you please provide guidance or instructions on how to proceed?

To test as a unit test, you would create a temp directory (see the logic in withTempFile for an example) and then call shouldGenerate on a generator with options that would write to a non-existent subdirectory of that temp directory, then check that it was created.

Alternately it could be done as an end-to-end test here by using an output path that doesn't exist.

@Nitin-Poojary Nitin-Poojary force-pushed the pigeon/create_target_files_recursively branch 3 times, most recently from c2e3be0 to 1d46423 Compare July 24, 2023 15:28
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@Nitin-Poojary Nitin-Poojary force-pushed the pigeon/create_target_files_recursively branch 8 times, most recently from b5479c5 to 7cd5a2e Compare July 31, 2023 12:54
'--input',
'pigeons/message.dart',
'--dart_out',
'$tempDir/subdirectory/message.g.dart',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you change this to '$tempDir/subdirectory/does/not/exist/message.g.dart'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks I just wanted to confirm whether I have to do something like this.

@Nitin-Poojary Nitin-Poojary force-pushed the pigeon/create_target_files_recursively branch 3 times, most recently from 1fba6d5 to 215531c Compare August 5, 2023 07:24
@Nitin-Poojary Nitin-Poojary force-pushed the pigeon/create_target_files_recursively branch from 215531c to 2cb30a0 Compare August 7, 2023 13:49
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits.

@@ -1,3 +1,7 @@
## 10.1.6

* Creates target files before trying to write to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "Fixes generation failures when an output file is in a directory that doesn't already exist."

@@ -472,6 +473,7 @@ class DartGeneratorAdapter implements GeneratorAdapter {
final DartOptions dartOptionsWithHeader = _dartOptionsWithCopyrightHeader(
options.dartOptions,
options.copyrightHeader,
dartOutPath: options.dartOut,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this change related to the fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change to investigate something, but then I forgot to revert it. Later, I mistakenly assumed that I had made the change intentionally, and I apologize for that.

@@ -366,6 +366,13 @@ Future<int> _runCommandLineTests() async {
'--ast_out',
tempOutput
],
// Test writing a file in a directory that doesn't exist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missing final period.

Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together!

@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 8, 2023
@auto-submit auto-submit bot merged commit 7bfcc0e into flutter:main Aug 8, 2023
@Nitin-Poojary
Copy link
Contributor Author

@tarrinneal @stuartmorgan I wanted to say a big thank you for your support and guidance during the review and merging of my pull request. Your help has been invaluable, and I'm grateful for the opportunity to contribute to this project.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 8, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 8, 2023
flutter/packages@d7ee75a...ac41376

2023-08-08 engine-flutter-autoroll@skia.org Roll Flutter from ad0aa8d to 436df69 (17 revisions) (flutter/packages#4663)
2023-08-08 10687576+bparrishMines@users.noreply.github.com [webview_flutter_wkwebview] Repeatedly pump WebViews until one is garbage collected (flutter/packages#4662)
2023-08-08 erikgerman917@gmail.com [xdg_directories] Add example app (flutter/packages#4554)
2023-08-08 70025277+Nitin-Poojary@users.noreply.github.com [pigeon] Recursively create output target files (flutter/packages#4458)
2023-08-07 jpnurmi@gmail.com [path_provider] Add getApplicationCachePath() (flutter/packages#4483)
2023-08-07 10687576+bparrishMines@users.noreply.github.com [flutter_markdown] Adopt code excerpts in README (flutter/packages#4656)
2023-08-07 reidbaker@google.com [All] Expand artifact hub to all plugins (flutter/packages#4645)
2023-08-07 engine-flutter-autoroll@skia.org Roll Flutter from 2ba9f7b to ad0aa8d (31 revisions) (flutter/packages#4659)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@tarrinneal
Copy link
Contributor

@tarrinneal @stuartmorgan I wanted to say a big thank you for your support and guidance during the review and merging of my pull request. Your help has been invaluable, and I'm grateful for the opportunity to contribute to this project.

We're always happy to help community members land good pr's! Thank you for putting in the effort and time to get this through to the finish line!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: pigeon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants