What's the best way to separate different kinds of...
# general
p
What's the best way to separate different kinds of tests? eg unit vs integration I think I read something about tags, or do I need to change the target name from
tests
to
unit-tests
or similar? ie for
python_tests()
is adjusting
name=
or
tags=
preferable for distinguishing unit/integration tests? If
tags=
is the better option, then what is the purpose of
name=
?
h
Tags are usually the way to go with this. In the pants repo we used to tag certain tests as "integration" so we could run them separately.
I don't think you can currently use the target name in recursive glob patterns
E.g.,
./pants list ::test
and any variants I could think of gives an error
Although it would certainly be better if we did support that, I don't think that was a conscious decision not to
Usually
name=
is for addressing individual targets, e.g., in
dependencies=
of other targets, or on the cmd line if necessary
It forms part of the address of the target
I'm curious about the implementation of
::
globbing now, and whether it could work with target names
p
Got it. I'll use tags then, and I'm curious what you find about
::test
😉 Is there any case where you would put a test target in a
dependencies=
field? Why would anything depend on a
python_tests
target?
Oh, and I assume tags are not inherited, right? So I would need to add tags to each of these files: st2actions/tests/unit/BUILD st2actions/tests/unit/controllers/BUILD st2actions/tests/unit/policies/BUILD
h
As for reasons to put a test target in a
dependencies=
, nothing comes to mind, as we move towards "targets are just metadata applied to source files" it's certainly possible that not all targets have addresses.
👍 1
In that example the target needs a name, so it might as well be
integration
, but the name isn't used in target selection AFAICT.
👍 1