-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Support execution constraints per exec group #13110
Changes from 6 commits
62ce436
bb997b3
da8952d
1afeaf2
903343e
2ecd6e0
d6a4438
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,5 +299,173 @@ EOF | |
grep "child_value" out.txt || fail "Did not find the overriding value" | ||
} | ||
|
||
function test_platform_execgroup_properties_cc_test() { | ||
cat > a.cc <<'EOF' | ||
int main() {} | ||
EOF | ||
cat > BUILD <<'EOF' | ||
cc_test( | ||
name = "a", | ||
srcs = ["a.cc"], | ||
) | ||
|
||
platform( | ||
name = "my_platform", | ||
parents = ["@local_config_platform//:host"], | ||
exec_properties = { | ||
"platform_key": "default_value", | ||
"test.platform_key": "test_value", | ||
} | ||
) | ||
EOF | ||
bazel build --extra_execution_platforms=":my_platform" :a --execution_log_json_file out.txt || fail "Build failed" | ||
grep "platform_key" out.txt || fail "Did not find the platform key" | ||
grep "default_value" out.txt || fail "Did not find the default value" | ||
(! grep "test_value" out.txt) || fail "Used the test-action value when not testing" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know this syntax existed. I see the benefits, but it's very different than all the other tests, so can you please change this back to the previous style, and use the same style in your new tests? I think consistency is better in this case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I couldn't figure out why, but one of the tests failed with that style (and I missed the test case with expected failure). I ended up removing it, as there is a positive test anyway. |
||
|
||
bazel test --extra_execution_platforms=":my_platform" :a --execution_log_json_file out.txt || fail "Test failed" | ||
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" | ||
} | ||
|
||
function test_platform_execgroup_properties_nongroup_override_cc_test() { | ||
cat > a.cc <<'EOF' | ||
int main() {} | ||
EOF | ||
cat > BUILD <<'EOF' | ||
cc_test( | ||
name = "a", | ||
srcs = ["a.cc"], | ||
exec_properties = { | ||
"platform_key": "override_value", | ||
}, | ||
) | ||
|
||
platform( | ||
name = "my_platform", | ||
parents = ["@local_config_platform//:host"], | ||
exec_properties = { | ||
"platform_key": "default_value", | ||
"test.platform_key": "test_value", | ||
} | ||
) | ||
EOF | ||
bazel build --extra_execution_platforms=":my_platform" :a --execution_log_json_file out.txt || fail "Build failed" | ||
grep "platform_key" out.txt || fail "Did not find the platform key" | ||
grep "override_value" out.txt || fail "Did not find the overriding value" | ||
(! grep "default_value" out.txt) || fail "Used the default value" | ||
|
||
bazel test --extra_execution_platforms=":my_platform" :a --execution_log_json_file out.txt || fail "Test failed" | ||
grep "platform_key" out.txt || fail "Did not find the platform key" | ||
grep "override_value" out.txt || fail "Did not find the overriding value" | ||
} | ||
|
||
function test_platform_execgroup_properties_group_override_cc_test() { | ||
cat > a.cc <<'EOF' | ||
int main() {} | ||
EOF | ||
cat > BUILD <<'EOF' | ||
cc_test( | ||
name = "a", | ||
srcs = ["a.cc"], | ||
exec_properties = { | ||
"test.platform_key": "test_override", | ||
}, | ||
) | ||
|
||
platform( | ||
name = "my_platform", | ||
parents = ["@local_config_platform//:host"], | ||
exec_properties = { | ||
"platform_key": "default_value", | ||
"test.platform_key": "test_value", | ||
} | ||
) | ||
EOF | ||
bazel build --extra_execution_platforms=":my_platform" :a --execution_log_json_file out.txt || fail "Build failed" | ||
grep "platform_key" out.txt || fail "Did not find the platform key" | ||
grep "default_value" out.txt || fail "Used the default value" | ||
|
||
bazel test --extra_execution_platforms=":my_platform" :a --execution_log_json_file out.txt || fail "Test failed" | ||
grep "platform_key" out.txt || fail "Did not find the platform key" | ||
grep "test_override" out.txt || fail "Did not find the overriding test-action value" | ||
} | ||
|
||
function test_platform_execgroup_properties_override_group_and_default_cc_test() { | ||
cat > a.cc <<'EOF' | ||
int main() {} | ||
EOF | ||
cat > BUILD <<'EOF' | ||
cc_test( | ||
name = "a", | ||
srcs = ["a.cc"], | ||
exec_properties = { | ||
"platform_key": "override_value", | ||
"test.platform_key": "test_override", | ||
}, | ||
) | ||
|
||
platform( | ||
name = "my_platform", | ||
parents = ["@local_config_platform//:host"], | ||
exec_properties = { | ||
"platform_key": "default_value", | ||
"test.platform_key": "test_value", | ||
} | ||
) | ||
EOF | ||
bazel build --extra_execution_platforms=":my_platform" :a --execution_log_json_file out.txt || fail "Build failed" | ||
grep "platform_key" out.txt || fail "Did not find the platform key" | ||
grep "override_value" out.txt || fail "Did not find the overriding value" | ||
(! grep "default_value" out.txt) || fail "Used the default value" | ||
|
||
bazel test --extra_execution_platforms=":my_platform" :a --execution_log_json_file out.txt || fail "Test failed" | ||
grep "platform_key" out.txt || fail "Did not find the platform key" | ||
grep "test_override" out.txt || fail "Did not find the overriding test-action value" | ||
} | ||
|
||
function test_platform_properties_only_applied_for_relevant_execgroups_cc_test() { | ||
cat > a.cc <<'EOF' | ||
int main() {} | ||
EOF | ||
cat > BUILD <<'EOF' | ||
cc_test( | ||
name = "a", | ||
srcs = ["a.cc"], | ||
) | ||
|
||
platform( | ||
name = "my_platform", | ||
parents = ["@local_config_platform//:host"], | ||
exec_properties = { | ||
"platform_key": "default_value", | ||
"unknown.platform_key": "unknown_value", | ||
} | ||
) | ||
EOF | ||
bazel test --extra_execution_platforms=":my_platform" :a --execution_log_json_file out.txt || fail "Build failed" | ||
grep "platform_key" out.txt || fail "Did not find the platform key" | ||
grep "default_value" out.txt || fail "Did not find the default value" | ||
(! grep "unknown_value" out.txt) || fail "Used the value for an unknown execgroup" | ||
} | ||
|
||
function test_cannot_set_properties_for_irrelevant_execgroup_on_target_cc_test() { | ||
cat > a.cc <<'EOF' | ||
int main() {} | ||
EOF | ||
cat > BUILD <<'EOF' | ||
cc_test( | ||
name = "a", | ||
srcs = ["a.cc"], | ||
exec_properties = { | ||
"platform_key": "default_value", | ||
"unknown.platform_key": "unknown_value", | ||
} | ||
) | ||
EOF | ||
(! bazel test :a >& $TEST_log) || fail "Build passed when we expected an error" | ||
grep "Tried to set properties for non-existent exec group" $TEST_log || fail "Did not complain about unknown exec group" | ||
} | ||
|
||
run_suite "platform mapping test" | ||
|
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.
Wow, I hate Map> so much, but I see this predates your change so leave it. I will probably send a followup shortly to change this to a Table.
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.
Acknowledged. I didn't know about Table (never wrote Java at Google). I would be happy to fix this - please let me know if you'd like me to do this as part of this PR - but you probably have more context.