Open endobson opened 6 years ago
Handing off to Configurability to take a first look and see if it is your problem.
Hmmm, so, if I'm understanding correctly, the problem is that given a testonly rule //toplevel
which uses an aspect aspect
which depends on a testonly rule //aspectdata
, then the application of aspect
to a non-testonly rule //normalrule
will fail because the testonly validation is looking at the testonly bits for //normalrule
(false) and //aspectdata
(true). What you would like is for //toplevel
's testonly bit to be used instead.
Note that the rule which launched the aspect is not associated with the aspect, so we can't just use the testonly bit of the rule which sent the aspect out.
This is a problem for visibility, too, as the access of the rule the aspect is being applied to is used instead of the access of the rule which created the aspect.
I think the Starlark team might have to weigh in on this, as it's something of an API question for defining aspects. If an aspect depends on a testonly rule, can we just say that aspect itself is testonly, and forbid using it from non-testonly rules? Should we use the aspect's package for aspect attributes' visibility? All of these would work, but what do we want this to look like for aspect authors?
Not sure who's responsible for aspects core behavior. Lukács, any opinion on this issue?
@dslomov it is (sorry for the late reply)
Visibility: the only rule that makes sense is that visibility of aspect's package is used.
testonly: I think it would make sense to mark aspects at testonly
- then only testonly
rules can originate them.
/cc @c-parsons
cc @mai93
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.
Testonly is an attribute that is applied to rules, and is enforced on aspect extended versions of the rule even if that is not appropriate.
I want to build an aspect which needs a testonly file as a dependency to build a aspect which is being added by a testonly rule. But I cannot as the aspect is being (recursively) applied to a non testonly rule, and the enforcement currently is that all aspect extensions of a non-testonly rule are non-testonly.
Example error message:
I would think that the solution is that aspect extended rules would have a seperate testonly bit and that aspects can be marked as testonly which means that anything they apply to gets the testonly bit set.
Code to reproduce: https://github.com/endobson/yaspl2/tree/aspect-testonly bazel build //:missing_imports