jsDriver.pl is normally used to run a series of tests against
one of the JavaScript shells. These tests are expected to be laid out
in a directory structure exactly two levels deep. The first level
represents a "Test Suite" and generally marks a broad
category such as ECMA Level 1 or Live Connect 3. The next
level represents a "Suite Category" and divides tests
inside a suite into smaller categories, such as Execution Contexts
or Lexical Rules. Testcases reside under the "Suite
Categories" as normal JavaScript (*.js) files. If a file named
shell.js exists in either the suite path (the parent directory of the
"Test Suites") or the indiviual "Suite Category"
directory, it is loaded into the shell before the testcase. You can
use this to declare functions and variables common to an entire suite
or category.
Testcases can report failures back to jsDriver.pl in one of
two ways. The most common is to write a line of text containing
the word FAILED!
to STDOUT or STDERR.
When the engine encounters a matching line, the test is marked as
failed, and any line containing FAILED!
is displayed in
the failure report. The second way a test case can report failure is
to return an unexpected exit code. By default, jsDriver.pl
expects all test cases to return exit code 0, although a test
can output a line containing EXPECT EXIT n
where
n is the exit code the driver should expect to see. Testcases
can return a nonzero exit code by calling the shell function
exit(n)
where n
is the
code to exit with. Also, the various JavaScript shells report
non-zero exit codes under the following conditions:
Reason |
Exit Code |
Engine initialization failure.
|
1
|
Invalid argument on command line.
|
2
|
Runtime error (uncaught exception) encountered.
|
3
|
File argument specified on command line not found.
|
4
|
Reserverd for future use.
|
5-9
|