The JDK Test Framework: Tag Language Specification Comments and questions to: jtreg-use@openjdk.dev.java.net 1.25 06/10/24 This is a specification document, not a tutorial. For more basic information please consult the jtreg faq at http://openjdk.dev.java.net/jtreg. LEADING COMMENTS AND DEFINING FILES A particular test may involve several files of various types, but the test is specified in just one of them. Let this be called the _defining_ file of the test. The defining file of a test may be one of several types of files. Test tags must be enclosed in a comment at the head of the file, optionally preceeded by comments which do not contain test tags. The comment in the defining file which includes the test tags is called the _leading_ comment. The following types of defining files are recognized: A Java source file, with file extension ".java". Only the "/*" to "*/" comment syntax is recognized. On each comment line leading asterisks, if any, are ignored. A Bourne shell file, with file extension ".sh". The leading comment is the first contiguous set of lines each of whose first character is '#'. The comment is terminated by the first line whose first character is not '#'. Note that shell tests should not contain "# !/bin/sh" on the first line; they are intended to be run only via explicit invocation of a shell. An HTML file, with file extension ".html". The leading comment is enclosed within the usual "" HTML tag. The contents of a leading comment are parsed into a sequence of tokens. A token is a maximal contiguous sequence of non-whitespace characters. Whitespace characters, which include newline and carriage-return characters, are significant only insofar as they separate tokens. The first token in the leading comment in the defining file of a test must be "@test". The harness discovers defining files by looking for such tokens. A file without comments is not a defining file. A file whose leading comment does not start with "@test" is not a defining file. TAG SYNTAX Within a leading comment, a tag consists of a tag token followed by some number of arguments. A tag token is any token whose first character is '@'. There is at present no syntax for quoting a leading '@' character. Case is significant when comparing tag tokens; all tag tokens defined here are in lower case. It is an error for the leading comment of a defining file to contain any tag token not defined here. As a special case, the token "@(#)" is not treated as a tag token. This token may appear in the arguments to an @test tag as part of the SCCS identification string. The arguments of a tag are simply the tokens that follow it. The argument tokens of a tag extend from the first token after the tag token to the end of the comment, the end of the file, or the next tag token, whichever comes first. Argument tokens are separated by whitespace; if commas are used, they will be considered to be part of the tokens to which they are adjacent. INFORMATIONAL TAGS Informational tags document the test. They do not affect the operation of the harness, but may be used by the harness in generating reports. @test * -- Defining-file identifier; * is typically SCCS identification info @bug + -- Bugtraq bug numbers @summary + -- Textual summary @author + -- Original author Any particular informational tag may occur at most once in a given test. DECLARATIVE TAGS Declarative tags govern the execution of the tags that follow them. @library + Add one or more pathnames or jar filenames to the library-directory list. Each argument must be relative using forward slashes and ".." to denote parent directories. The names are prepended to the list from right to left. When the harness runs a test it adds the library list to the class path used by the virtual machine. The class path will consist of the test-class directory, the current test-source directory, the library list with each element resolved against the test-class directory, and the system class directories or zip/jar files of the build being tested. The class path will be computed in the same fashion when the harness compiles a class. Classes in library directories are not automatically compiled. A test that relies upon library classes should contain appropriate @build directives to ensure that the classes will be compiled. The @library tag may be used more than once. It may only be used before the first @run tag. The @library tag and the library list have nothing to do with the search path (i.e., the PATH environment variable) defined in shell actions. @key + Label this test with the given keyword(s). Some harnesses allow tests to be selected via boolean expressions on keywords. The list of acceptable keywords may be specified in the TEST.ROOT file (see below). The @key tag may be used at most once in a given test. ACTION TAGS Action tags tell the harness how to perform the test. They are executed in the order in which they are given. Each action either passes or fails. If an action fails, no following actions, if any, are performed. A test passes if, and only if, all of its actions pass. Action tags begin with the tag token "@run", and have the following syntax: @run