Skip to content
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

Implement --target_pattern_file flag for reading patterns from file #10856

Closed

Conversation

robbertvanginkel
Copy link
Contributor

An alternative to #10796 to fix #8609.

As #8609 (comment) points out there's currently a --query_file to read a query pattern from file, but there's no analogous feature available for build/test. Generic parameter file support attempted in #10796 turns out to be a little more complex than expected due to bazel's client/server architecture and likely requires some design document.

This PR would fix help #8609 without rushing into any designs, so we can spend time properly designing generic parameter files while also alleviating the immediate problem with a known/simpler pattern.

@robbertvanginkel
Copy link
Contributor Author

@michajlo thanks for your comments in #10796 (review) and your suggestion in #8609 (comment). While would like generic parameter file support in Bazel, I would also appreciate a more immediate solution to #8609. Suggesting we go with this much simpler approach for now till I can spend the time on a generic solution to the open questions in #10796.

Copy link
Contributor

@michajlo michajlo 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 the changes!

Copy link
Contributor

@michajlo michajlo left a comment

Choose a reason for hiding this comment

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

If you can figure out how to add a simple java unit test for TargetPatternFileSupport it'd be much appreciated - easier to get more coverage more quickly than the integration tests. Otherwise just minor comments.

@jin
Copy link
Member

jin commented Feb 28, 2020

Reviewers: once approved, please read the internal go/import-bazel-pr document for PR import instructions.

@robbertvanginkel
Copy link
Contributor Author

Processed the comments but did not get to the unit test yet. I looked at making one, but standing up a CommandEnvironment to pass in is a little tricky (its constructor is not public and in a different package), and when I attempted to make a mockito mock I got an error like

Cannot mock/spy class com.google.devtools.build.lib.runtime.CommandEnvironment
Mockito cannot mock/spy because :
 - final class

I'm not sure how best to approach that, if you have any recommendation please let me know and I'll try to finish the unit test.

@michajlo
Copy link
Contributor

michajlo commented Mar 2, 2020

CommandEnvironment should be mockable as of an hour or so ago.

@robbertvanginkel robbertvanginkel changed the title Implement --build_file flag for reading patterns from file Implement --target_pattern_file flag for reading patterns from file Mar 3, 2020
@michajlo
Copy link
Contributor

michajlo commented Mar 4, 2020

Let me know when that last test is ready, otherwise everything else lgtm.

An alternative to bazelbuild#10796 to fix bazelbuild#8609.

As bazelbuild#8609 (comment) points out there's currently a --query_file to read a query pattern from file, but there's no analogous feature available for build/test. Generic parameter file support attempted in bazelbuild#10796 turns out to be a little more complex than expected due to bazel's client/server architecture and likely requires some design document.

This PR would fix help bazelbuild#8609 without rushing into any designs, so we can spend time properly designing generic parameter files while also alleviating the immediate problem with a known/simpler pattern.
@robbertvanginkel
Copy link
Contributor Author

@michajlo I squashed the changes and rebased them on master to resolve a merge conflict github was showing. It seems like there was a few changes to use DetailedExitCode instead of ExitCode, I attempted to update the references.

I think all the changes, including unit and integration tests should be there. Please let me know if theres anything else!

Copy link
Contributor

@michajlo michajlo left a comment

Choose a reason for hiding this comment

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

All lgtm, just style/naming things on this round then good to go.

* list of targets based on the supplied command line options.
*/
public static class TargetPatternFileSupportException extends Exception {
public TargetPatternFileSupportException(String message) { super(message); }
Copy link
Contributor

Choose a reason for hiding this comment

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

style thing, mv the super(...) to a new line:

... {
  super(message);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Does Bazel have something like google-java-format setup? I couldn't find it myself in the contribution guidelines.

- TargetPatternFileSupport -> TargetPatternsHelper
- Add unittest for empty case
- Comments/style
@robbertvanginkel
Copy link
Contributor Author

All comments should be taken care of.

@bazel-io bazel-io closed this in bdae1c2 Mar 4, 2020
@robbertvanginkel robbertvanginkel deleted the robbert/build_file branch March 4, 2020 23:27
@robbertvanginkel
Copy link
Contributor Author

Thanks @michajlo!

@isaprykin
Copy link

--query_file accepts space separated list of targets.
It needs to be clarified that this only accepts newline separated list of targets.
I costed me a few hours.

apattidb pushed a commit to databricks/bazel that referenced this pull request Apr 17, 2023
An alternative to bazelbuild#10796 to fix bazelbuild#8609.

As bazelbuild#8609 (comment) points out there's currently a `--query_file` to read a query pattern from file, but there's no analogous feature available for build/test. Generic parameter file support attempted in bazelbuild#10796 turns out to be a little more complex than expected due to bazel's client/server architecture and likely requires some design document.

This PR would fix help bazelbuild#8609 without rushing into any designs, so we can spend time properly designing generic parameter files while also alleviating the immediate problem with a  known/simpler pattern.

Closes bazelbuild#10856.

PiperOrigin-RevId: 298953350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for reading a list of target patterns for from a file
5 participants