diff --git a/src/dom/test/README b/src/dom/test/README new file mode 100644 index 00000000..a980f16e --- /dev/null +++ b/src/dom/test/README @@ -0,0 +1,168 @@ +Core GIT Tests +============== + +This directory holdstest scripts for the DOM implementation. The first part of +this short document describes how to run the tests and read their output. + +When fixing the tools or adding enhancements, you are strongly encouraged to +add tests in this directory to cover what you are trying to fix or enhance. +The later part of this short document describes how your test scripts should be +organized. + + +Running Tests +------------- + +The easiest way to run tests is to say "make test". This runs all the tests. + + *** test-sgml-parser-basic *** + * ok 1: parse a small document. + ... + * ok 23: parse a CDATA section. + * passed all 23 test(s) + *** test-dom-select-basic *** + * ok 1: match the root node. + * ok 2: match universal element. + ... + +Or you can run each test individually from command line, like this: + + $ sh ./test-sgml-parser-basic + * ok 1: parse a small document. + ... + * ok 23: parse a CDATA section. + * passed all 23 test(s) + +You can pass --verbose (or -v), --debug (or -d), and --immediate (or -i) +command line argument to the test. + +--verbose:: + This makes the test more verbose. Specifically, the + command being run and their output if any are also + output. + +--debug:: + This may help the person who is developing a new test. + It causes the command defined with test_debug to run. + +--immediate:: + This causes the test to immediately exit upon the first + failed test. + + +Naming Tests +------------ + +The test files should be named so that it is clear what part of the DOM +implementation it is aimed for. The name MUST start with "test-" and have four +hyphen separated words which name first the module, then the feature and last +what the purpose of the test is (such as basic stuff or a specific use case). +In short use the following as a template: + + test--- + +For example test-sgml-parser-basic. + +If you create files under test/ directory (i.e. here) that is not the top-level +test script, never name the file to match the above pattern. The Makefile here +considers all such files as the top-level test script and tries to run all of +them. A care is especially needed if you are creating a common test library +file, similar to libtest, because such a library file may not be suitable for +standalone execution. + + +Writing Tests +------------- + +The test script is written as a shell script. It should start with the standard +"#!/bin/sh" with copyright notices, and an assignment to variable +'test_description', like this: + + #!/bin/sh + # + # Copyright (c) 2005 Junio C Hamano + # + + test_description='Test the very basic feature of module foo. + + This test runs very basic features, like checking that bar is correctly + bazzed. + ' + + +Source 'libtest' +-------------------- + +After assigning test_description, the test script should source test-lib.sh +like this: + + . ./libtest + +This test harness library does the following things: + + - If the script is invoked with command line argument --help (or -h), it shows + the test_description and exits. + + - Creates an empty test directory. This directory is 'test/trash' if you must + know, but I do not think you care. + + - Defines standard test helper functions for your scripts to use. These + functions are designed to make all scripts behave consistently when command + line arguments --verbose (or -v), --debug (or -d), and --immediate (or -i) + is given. + + +End with test_done +------------------ + +Your script will be a sequence of tests, using helper functions from the test +harness library. At the end of the script, call 'test_done'. + + +Test harness library +-------------------- + +There are a handful helper functions defined in the test harness library for +your script to use. + + - test_expect_success