Record Class TestDirective
- Record Components:
token- Source location of the directiverequirement- Optional requirement id this test anchors (null = unanchored)group- Optional group name for sequential execution (null = parallel)expectedExitCode- Optional exit code the program must end with (null = the default, 0)lineNumber- The line number the directive applies to (the program declaration line)
- All Implemented Interfaces:
Directive
@Test- parallel, unanchored, expects exit 0@Test: "database" - execution group, unanchored@Test: "REQ:fraud-screening" - anchored, parallel@Test: "REQ:fraud-screening": "database" - anchored and grouped@Test: "EXIT:3" - passes only when the program exits 3@Test: "REQ:input-validation": "validation": "EXIT:3" - all three, in any order
The parts are told apart by their content, not their position
A part starting EXIT: is the expected exit code. Any other part with a colon is a
requirement id (<PREFIX>:<slug>); an execution group may not contain one. That makes the
classification total and order-independent, and it is what closes an otherwise silent failure: a
mistyped prefix such as "RREQ:foo" or "EXT:3" would otherwise be a perfectly legal
group name, dropping the anchor or the exit expectation with no diagnostic anywhere. Any
colon-bearing part is therefore an anchor or exit attempt, and a malformed one is a
compile error rather than a quiet degradation to a group.
Zero of the 622 @Test usages in the corpus contained a colon when the rule landed,
so it was enforceable with no migration.
The fields also travel across phases on separate squirrelled keys. The group rides
TEST_DIRECTIVE, which TestRunner reads as the sequential execution group; packing
a requirement id or an exit code into it would silently reschedule every such test into a group
named after it. The requirement rides REQUIREMENT_REF, the exit code
TEST_EXIT_CODE.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTHE prefix of the expected-exit-code part,"EXIT:<n>".static final intThe highest exit code a test may expect: a process exit status carries 8 bits.static final intThe lowest exit code a test may expect. -
Constructor Summary
ConstructorsConstructorDescriptionTestDirective(IToken token, String requirement, String group, Integer expectedExitCode, int lineNumber) Creates an instance of aTestDirectiverecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpectedExitCoderecord component.intWhich line number does this directive apply to.Provide a token from the source, by default if not possible supply synthetic.group()Returns the value of thegrouprecord component.booleanCheck if this test declares the exit code its program must end with.booleanhasGroup()Check if this test has a group for sequential execution.final inthashCode()Returns a hash code value for this object.booleanCheck if this test anchors a requirement.booleanisForPhase(CompilationPhase phase) Is it for the particular compiler phase.intReturns the value of thelineNumberrecord component.Returns the value of therequirementrecord component.token()Returns the value of thetokenrecord component.final StringtoString()Returns a string representation of this record class.type()What s the type of the directive.
-
Field Details
-
EXIT_PREFIX
THE prefix of the expected-exit-code part,"EXIT:<n>". Shared with the editors that render the directive line, so the parser and the writers cannot disagree about its spelling.- See Also:
-
MIN_EXIT_CODE
public static final int MIN_EXIT_CODEThe lowest exit code a test may expect.- See Also:
-
MAX_EXIT_CODE
public static final int MAX_EXIT_CODEThe highest exit code a test may expect: a process exit status carries 8 bits.- See Also:
-
-
Constructor Details
-
TestDirective
public TestDirective(IToken token, String requirement, String group, Integer expectedExitCode, int lineNumber) Creates an instance of aTestDirectiverecord class.- Parameters:
token- the value for thetokenrecord componentrequirement- the value for therequirementrecord componentgroup- the value for thegrouprecord componentexpectedExitCode- the value for theexpectedExitCoderecord componentlineNumber- the value for thelineNumberrecord component
-
-
Method Details
-
type
Description copied from interface:DirectiveWhat s the type of the directive. -
isForPhase
Description copied from interface:DirectiveIs it for the particular compiler phase.- Specified by:
isForPhasein interfaceDirective
-
getAppliesToLineNumber
public int getAppliesToLineNumber()Description copied from interface:DirectiveWhich line number does this directive apply to.- Specified by:
getAppliesToLineNumberin interfaceDirective
-
getDirectiveToken
Description copied from interface:DirectiveProvide a token from the source, by default if not possible supply synthetic.- Specified by:
getDirectiveTokenin interfaceDirective
-
hasGroup
public boolean hasGroup()Check if this test has a group for sequential execution. -
hasRequirement
public boolean hasRequirement()Check if this test anchors a requirement.An unanchored test is entirely legitimate and carries no requirement by design - a unit test over a shared primitive is not "about" any one requirement.
-
hasExpectedExitCode
public boolean hasExpectedExitCode()Check if this test declares the exit code its program must end with. Without one the expectation is 0. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
token
-
requirement
Returns the value of therequirementrecord component.- Returns:
- the value of the
requirementrecord component
-
group
-
expectedExitCode
Returns the value of theexpectedExitCoderecord component.- Returns:
- the value of the
expectedExitCoderecord component
-
lineNumber
public int lineNumber()Returns the value of thelineNumberrecord component.- Returns:
- the value of the
lineNumberrecord component
-