Package com.sun.javatest.finder
Class TagTestFinder
java.lang.Object
com.sun.javatest.TestFinder
com.sun.javatest.finder.TagTestFinder
- Direct Known Subclasses:
ExpandTestFinder
This class searches out test descriptions found in a file system
tree. Each attribute of the test description consists of JavaDoc-like tags
which provide an tag-name and associated value. The associated test script
for the test suite will interpret the values. All tags for a given test
description must be within the same block comment. A file may contain
multiple test descriptions.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.sun.javatest.TestFinder
TestFinder.ErrorHandler, TestFinder.Fault
-
Field Summary
Fields inherited from class com.sun.javatest.TestFinder
debug, env
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs the list of file names to exclude for pruning in the search for files to examine for test descriptions. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExtension
(String extn, Class<? extends CommentStream> commentStreamClass) Nominate a class to read files that have a particular extension.protected int
Decode the arg at a specified position in the arg array.void
Exclude all files with a particular name from being scanned.void
Exclude all files with particular names from being scanned.Class
<? extends CommentStream> getClassForExtension
(String extn) Get the class used to handle an extension.protected File
Get the name of the file currently being scanned.Get the current value of the initial tag that is checked for in a test description.boolean
isExcluded
(String s) Determine if the given extension is excluded from scanning.parseComment
(String comment, File currFile) Given a comment, find all tags of interest.void
Scan a file, looking for test descriptions and/or more files to scan.protected void
Scan a file, looking for comments and in the comments, for test description data.void
setInitialTag
(String tag) Set the initial tag to be checked for in a test description.void
Undo an exclude operation.Methods inherited from class com.sun.javatest.TestFinder
clearErrors, decodeAllArgs, error, error, error, foundFile, foundTestDescription, foundTestDescription, getComparator, getDefaultComparator, getErrorCount, getErrorHandler, getErrors, getFiles, getRoot, getRootDir, getTests, init, init, isFolder, lastModified, localizedError, normalize, processEntry, read, setComparator, setErrorHandler, setRoot, totalNumberOfTestsInTheSuite
-
Constructor Details
-
TagTestFinder
public TagTestFinder()Constructs the list of file names to exclude for pruning in the search for files to examine for test descriptions. This constructor also sets the allowable comment formats.
-
-
Method Details
-
decodeArg
Decode the arg at a specified position in the arg array. If overridden by a subtype, the subtype should try and decode any arg it recognizes, and then call super.decodeArg to give the superclass(es) a chance to recognize any arguments.- Overrides:
decodeArg
in classTestFinder
- Parameters:
args
- The array of argumentsi
- The next argument to be decoded.- Returns:
- The number of elements consumed in the array; for example, for a simple option like "-v" the result should be 1; for an option with an argument like "-f file" the result should be 2, etc.
- Throws:
TestFinder.Fault
- If there is a problem with the value of the current arg, such as a bad value to an option, the Fault exception can be thrown. The exception should NOT be thrown if the current arg is unrecognized: in that case, an implementation should delegate the call to the supertype.
-
scan
Scan a file, looking for test descriptions and/or more files to scan.- Specified by:
scan
in classTestFinder
- Parameters:
file
- The file to scan
-
getCurrentFile
Get the name of the file currently being scanned.- Returns:
- the name of the file currently being scanned.
-
exclude
Exclude all files with a particular name from being scanned. This will typically be for directories like SCCS, Codemgr_wsdata, etc- Parameters:
name
- The name of files to be excluded.
-
exclude
Exclude all files with particular names from being scanned. This will typically be for directories like SCCS, Codemgr_wsdata, etc- Parameters:
names
- The names of files to be excluded.
-
unexclude
Undo an exclude operation.- Parameters:
name
- The filename to stop ignoring, should never be null.- See Also:
-
isExcluded
Determine if the given extension is excluded from scanning.- Parameters:
s
- The extension to check for (should not contain the leading dot)- Returns:
- True if it is excluded, false otherwise.
- See Also:
-
addExtension
Nominate a class to read files that have a particular extension.- Parameters:
extn
- The extension for which this class is to be usedcommentStreamClass
- A class to read files of a particular extension. The class must be a subtype of CommentStream
-
getClassForExtension
Get the class used to handle an extension.- Parameters:
extn
- The extension in question- Returns:
- the class previously registered with addExtension
-
getInitialTag
Get the current value of the initial tag that is checked for in a test description. If null, no tag is required.- Returns:
- the value of the required initial tag, or null if none required.
- See Also:
-
setInitialTag
Set the initial tag to be checked for in a test description. If set to null, no initial tag is required. The default value for the initial tag is "test". (i.e. @test must appear in the test description.)- Parameters:
tag
- The tag to be checked for.- See Also:
-
scanFile
Scan a file, looking for comments and in the comments, for test description data.- Parameters:
file
- The file to scan
-
parseComment
Given a comment, find all tags of interest. Return a map containing the name-value pairs for those tags. If a duplicate name is found, the last name-value will be returned.- Parameters:
comment
- The comment to be parsed.currFile
- The name of the file currently being read.- Returns:
- A map containing the name-value pairs read from the comment.
-