Skip to content

feat(erlang_app, ct_suite): forward target_compatible_with and tags - #14

Open
TrapsterDK wants to merge 1 commit into
bazelverse:mainfrom
TrapsterDK:pr2
Open

TrapsterDK wants to merge 1 commit into
bazelverse:mainfrom
TrapsterDK:pr2

Conversation

@TrapsterDK

Copy link
Copy Markdown

Fixes #13.

Problem
erlang_app and test_erlang_app cannot mark their generated targets as incompatible with a platform, or tag them. ct_suite passes target_compatible_with to the test but not to the suite's bytecode target, so the suite still compiles on platforms where it cannot run.

Change

  • erlang_app: new arguments target_compatible_with and tags, both default None. They are passed to erlang_bytecode, app_file, the appup copy_file and erlang_app_info.
  • ct_suite: also passes target_compatible_with to the suite's erlang_bytecode.
  • With the defaults nothing changes.

Test
test/erlang_app_attrs: an app, a test app and a suite, all with tags = ["attrs_fixture"] and target_compatible_with = ["@platforms//:incompatible"]. A macro in the same BUILD file walks native.existing_rules() and fails at loading time if a generated rule misses either attribute. bazel test //... skips the incompatible suite, and bazel query --output=build shows the tag on each target. On main the package fails to load (_erlang_app() got unexpected keyword arguments: tags, target_compatible_with).

Test output (OTP 29.1.2, Bazel 9.2.0, --nohome_rc)

The PR was also checked alone on main (root bazel test //... passes). The output below is from all four of my PRs stacked (bazel test //... in the root, then in test/).

//:util_tests_test_0 (cached) PASSED in 0.0s
//private:app_file_test (cached) PASSED in 0.0s
//private:util_tests_test_0 (cached) PASSED in 0.0s
//private/ct_auto_sname_test:auto_sname_posix_test (cached) PASSED in 0.0s
//private/ct_auto_sname_test:auto_sname_windows_test (cached) PASSED in 0.0s
//private/ct_auto_sname_test:default_posix_test (cached) PASSED in 0.0s
//private/ct_auto_sname_test:no_sname_posix_test (cached) PASSED in 0.0s
//private/ct_auto_sname_test:no_sname_windows_test (cached) PASSED in 0.1s
//private/otp_tree_test:erl_eval_with_release_tar_test (cached) PASSED in 0.0s
//private/otp_tree_test:erl_eval_with_tree_test (cached) PASSED in 0.1s
//private/otp_tree_test:erl_runs_from_tree_test (cached) PASSED in 0.0s
//private/otp_tree_test:eunit_with_tree_test (cached) PASSED in 0.0s
//private/otp_tree_test:template_vars_with_tree_test (cached) PASSED in 0.0s
//private/xrl_yrl_test:lexer_installs_erlang_test (cached) PASSED in 0.1s
//private/xrl_yrl_test:parser_installs_erlang_test (cached) PASSED in 0.0s
Executed 0 out of 15 tests: 15 tests pass.
//app_file:test_applications_preserved PASSED in 0.1s
//ct_no_sname:no_sname_SUITE PASSED in 3.2s
//custom_vars:custom_var_test PASSED in 0.0s
//dot_app_to_json:dialyze PASSED in 0.9s
//dot_app_to_json:dot_app_to_json_SUITE PASSED in 3.2s
//dot_app_to_json:xref PASSED in 0.6s
//erl_attrs_to_json:dialyze PASSED in 0.9s
//erl_attrs_to_json:erl_attrs_to_json_SUITE PASSED in 3.5s
//erl_attrs_to_json:xref PASSED in 0.3s
//rebar_config_to_json:dialyze PASSED in 0.9s
//rebar_config_to_json:rebar_config_to_json_SUITE PASSED in 3.2s
//rebar_config_to_json:xref PASSED in 0.6s
//shard_suite:dialyze PASSED in 0.9s
//shard_suite:eunit PASSED in 0.5s
//shard_suite:shard_suite_SUITE PASSED in 3.6s
//shard_suite:xref PASSED in 0.6s
//xrl_yrl:xrl_yrl_test PASSED in 0.1s
Executed 17 out of 18 tests: 17 tests pass and 1 was skipped.

Assisted by Claude.

erlang_app and test_erlang_app had no way to mark their generated
targets as incompatible with a platform or to tag them. ct_suite passed
target_compatible_with to the test but not to the suite's bytecode
target, so the suite still compiled on platforms it cannot run on.

Add target_compatible_with and tags to erlang_app (default None, so
nothing changes) and pass them to erlang_bytecode, app_file, the appup
copy and erlang_app_info. ct_suite now passes target_compatible_with to
the suite's erlang_bytecode as well. Add a test/ package whose targets
are all incompatible and whose BUILD file fails at loading time if a
generated rule misses either attribute.

Assisted by Claude.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

erlang_app and ct_suite cannot forward target_compatible_with and tags

1 participant