Issue with config_settings starlark tests and nested WORKSPACE

21 views
Skip to first unread message

Menny Even Danan

unread,
Jun 28, 2024, 11:54:15 AMJun 28
to bazel-discuss
Hi all.

I'm trying to create tests that use config_settings in analysistest. But I experience a very annoying behavior, that may relate to the way we structure our repo (parent repo, and a nested repo - most of our code is in the nested repo, but almost all flows start from the root repo).

In the nested repo (@r2 in the example repo), I have a build-setting called css_processor_type. It has a target called @r2//starlark:css_processor_type. The default is set to postcss.

I created a few tests for the two possible values of the config-settings, plus one for the default value and another (failure) test for unknown value. Running these tests from the root repo works as expected. Running them from the nested repo (under r2/ folder) fails for the unknown and override values.

What I noticed is that when running the tests inside the nested repo (where the flag is being declared), Bazel reports the target without the @r2 prefix: <target //starlark:css_processor_type>

Example repo: https://github.com/menny/test-config-bazel-repo (I used bazel 7.1.1 for the example).

It seems like a simple setup, so I may have did something wrong with the repos structure. Any help would be helpful.

thanks.

Menny Even Danan

unread,
Jul 3, 2024, 9:04:22 PM (13 days ago) Jul 3
to bazel-discuss
The issue was the the the label I used should look (string-wise) differently in different workspaces.
So, in the root it should be "@r2//starlark:css_processor_type", but in the nested workspace is should be "@//starlark:css_processor_type".

The way to overcome this, is to hold the value in string:
label_as_string = str(Label("@r2//starlark:css_processor_type"))
Reply all
Reply to author
Forward
0 new messages