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

Add a test execgroup to Starlark test rules, if not manually defined. #14019

Closed
wants to merge 2 commits into from

Conversation

quval
Copy link
Contributor

@quval quval commented Sep 21, 2021

Fixes #13986.

@google-cla google-cla bot added the cla: yes label Sep 21, 2021
@quval quval force-pushed the starlark-test-execgroup branch 2 times, most recently from 8d0137a to c287c4b Compare September 22, 2021 05:55
@quval
Copy link
Contributor Author

quval commented Sep 22, 2021

Unfortunately, the one specific shard that had a legitimate failure before, failed again on some technical issue – just when I thought I fixed the problem... is there a way to rerun that specific shard?

@aiuto aiuto requested review from katre and removed request for jin and floriographygoth September 22, 2021 14:14
@aiuto aiuto assigned katre and unassigned gregestren Sep 22, 2021
@katre
Copy link
Member

katre commented Sep 22, 2021

I hit the "retry" button for the failing shard, we'll see what happens.

Copy link
Member

@katre katre left a comment

Choose a reason for hiding this comment

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

This looks good, I have a few questions and requests.

Thanks very much for taking this on!

site/docs/exec-groups.md Show resolved Hide resolved
@@ -402,6 +403,9 @@ public StarlarkCallable rule(
}
builder.addExecGroups(execGroupDict);
}
if (test && (execGroupDict == null || !execGroupDict.containsKey(TEST_RUNNER_EXEC_GROUP))) {
Copy link
Member

Choose a reason for hiding this comment

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

The actual execGroups data in RuleClass.Builder is a map: https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/packages/RuleClass.java;drc=8965d25af90ba975cd207c84fa461b499d8d51c9;l=820

Would it be easier to expose a Set<String> getExecGroupNames() or boolean hasExecGroup(String name) method on RuleClass.Builder?

This works but it's not elegant and requires keeping track of the existing groups. It's fine for Starlark, but native rules can have inheritance which would make this trickier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I was wondering about the same thing – my reasoning against this was that I didn't see getters on any other builder classes, and I wasn't sure what you'd think of it.

grep "platform_key" out.txt || fail "Did not find the platform key"
grep "test_value" out.txt || fail "Did not find the test-action value"

bazel test --extra_execution_platforms="${pkg}:my_platform" ${pkg}:b --execution_log_json_file out.txt || fail "Test failed"
Copy link
Member

Choose a reason for hiding this comment

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

Can you split this into two separate tests? One for the default test exec group, one for the manual? I think that will make any future errors easier to diagnose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@quval quval force-pushed the starlark-test-execgroup branch from c287c4b to 2c95c3e Compare September 22, 2021 14:58
Copy link
Member

@katre katre left a comment

Choose a reason for hiding this comment

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

LGTM, some small test tweaks and this is ready to import.


starlark_test = rule(
implementation = _impl,
test = True,
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment here that the "test" exec group exists by default in "test" rules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done (I thought it was enough that the test name said it).

implementation = _impl,
test = True,
exec_groups = {
"test": exec_group(),
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment here that this overrides the default "test" exec group.

Can we add a property or something here and verify it's set when the target is built?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Initially I used run_shell instead of write and tested that we aren't seeing the value for the test execgroup on bazel build, but unfortunately this seemed not to build on Windows, and write actions don't show up in the execution log. So I'm not sure how to do this.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, you're right, I don't see an easy way to do that. This is better than what we have now, so that's good.

Copy link
Member

@katre katre left a comment

Choose a reason for hiding this comment

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

Thanks! I'll merge this shortly.

implementation = _impl,
test = True,
exec_groups = {
"test": exec_group(),
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, you're right, I don't see an easy way to do that. This is better than what we have now, so that's good.

@bazel-io bazel-io closed this in 9a06163 Sep 23, 2021
@quval quval deleted the starlark-test-execgroup branch September 24, 2021 10:49
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.

"test" exec_group is not present on starlark defined rules
3 participants