TargetSubject¶
TargetSubject wraps a Target object and provides method for asserting
its state.
TargetSubject.action_generating¶
TargetSubject.action_generating(short_path)
Get the single action generating the given path.
Method: TargetSubject.action_generating
NOTE: in order to use this method, the target must have the TestingAspectInfo
provider (added by the testing_aspect aspect.)
PARAMETERS ¶
- short_path¶:
(
str) the output’s short_path to match. The value is formatted usingformat_str, so its template keywords can be directly passed.
- RETURNS ¶
ActionSubjectfor the matching action. If no action is found, or more than one action matches, then an error is raised.
TargetSubject.action_named¶
TargetSubject.action_named(mnemonic)
Get the single action with the matching mnemonic.
Method: TargetSubject.action_named
NOTE: in order to use this method, the target must have the [TestingAspectInfo]
provider (added by the [testing_aspect] aspect.)
PARAMETERS ¶
- RETURNS ¶
ActionSubject. If no action matches, or more than one action matches, an error is raised.
TargetSubject.attr¶
TargetSubject.attr(name, factory=None)
Gets a subject-wrapped value for the named attribute.
Method: TargetSubject.attr
NOTE: in order to use this method, the target must have the TestingAspectInfo
provider (added by the testing_aspect aspect.)
PARAMETERS ¶
- name¶:
(
str) the attribute to get. If it’s an unsupported attribute, and no explicit factory was provided, an error will be raised.- factory¶:
(default
None) (callable) function to create the returned subject based on the attribute value. If specified, it takes precedence over the attributes that are inherently understood. It must have the following signature:def factory(value, *, meta), wherevalueis the value of the attribute, andmetais the call chain metadata.
- RETURNS ¶
A Subject-like object for the given attribute. The particular subject type returned depends on attribute and
factoryarg. If it isn’t know what type of subject to use for the attribute, an error is raised.
TargetSubject.data_runfiles¶
TargetSubject.data_runfiles()
Creates a subject asserting on the target’s data runfiles.
Method: TargetSubject.data_runfiles
- RETURNS ¶
RunfilesSubjectobject
TargetSubject.default_outputs¶
TargetSubject.default_outputs()
Creates a subject asserting on the target’s default outputs.
Method: TargetSubject.default_outputs
- RETURNS ¶
DepsetFileSubjectobject.
TargetSubject.executable¶
TargetSubject.executable()
Creates a subject asesrting on the target’s executable File.
Method: TargetSubject.executable
- RETURNS ¶
FileSubjectobject.
TargetSubject.failures¶
TargetSubject.failures()
Creates a subject asserting on the target’s failure message strings.
Method: TargetSubject.failures
- RETURNS ¶
CollectionSubjectofstr.
TargetSubject.get_attr¶
TargetSubject.get_attr(name)
PARAMETERS ¶
- name¶:
undocumented
TargetSubject.has_provider¶
TargetSubject.has_provider(provider,
provider_name=”
Asserts that the target as provider provider.
Method: TargetSubject.has_provider
PARAMETERS ¶
TargetSubject.label¶
TargetSubject.label()
Returns a LabelSubject for the target’s label value.
Method: TargetSubject.label
TargetSubject.new¶
TargetSubject.new(target, meta)
Creates a subject for asserting Targets.
Method: TargetSubject.new
Public attributes:
actual: The wrappedTargetobject.
PARAMETERS ¶
- target¶:
(
Target) the target to check against.- meta¶:
(
ExpectMeta) metadata about the call chain.
- RETURNS ¶
TargetSubjectobject
TargetSubject.output_group¶
TargetSubject.output_group(name)
Returns a DepsetFileSubject of the files in the named output group.
Method: TargetSubject.output_group
PARAMETERS ¶
- RETURNS ¶
DepsetFileSubject of the named output group.
TargetSubject.provider¶
TargetSubject.provider(provider_key,
factory=None,
provider_name=”
Returns a subject for a provider in the target.
Method: TargetSubject.provider
PARAMETERS ¶
- provider_key¶:
The provider key to create a subject for
- factory¶:
(default
None) optional callable. The factory function to use to create the subject for the found provider. Required if the provider key is not an inherently supported provider. It must have the following signature:def factory(value, /, *, meta). Additional types of providers can be pre-registered by using theprovider_subject_factoriesarg ofanalysis_test.- provider_name¶:
(default
"<Unknown provider>") The display name of the provider. This must be supplied separately because str(provider_key) just returns “”, which isn’t helpful. For lack of a better option, this defaults to .
- RETURNS ¶
A subject wrapper of the provider value.
TargetSubject.runfiles¶
TargetSubject.runfiles()
Creates a subject asserting on the target’s default runfiles.
Method: TargetSubject.runfiles
- RETURNS ¶
RunfilesSubjectobject.
TargetSubject.tags¶
TargetSubject.tags()
Gets the target’s tags as a CollectionSubject
Method: TargetSubject.tags
- RETURNS ¶
CollectionSubjectasserting the target’s tags.