0testA Zero Install feed can specify a command to run to test the program automatically using the self-test attribute. 0test runs this command. It can also test combinations of various versions of a program and its dependencies. |
|
Create a short-cut to it in the usual way:
$ 0alias 0test http://0install.net/2008/interfaces/0test.xml
Usage
Most simply, you can use it to run the tests for a program you have downloaded or checked out of version control. e.g.
$ git clone some-program $ 0test some-program/program.xml
You can also use it to test released programs, e.g. to test the default version of 0compile:
$ 0test http://0install.net/2006/interfaces/0compile.xml
You can specify a particular set of versions to test:
$ 0test http://0install.net/2006/interfaces/0compile.xml 0.16 0.17
Finally, you can specify versions of libraries the program depends on too. 0test will try all combinations. This tests three versions of 0compile against two versions of Zero Install (a total of 2 x 3 = 6 tests):
$ 0test http://0install.net/2006/interfaces/0compile.xml 0.17 0.18 0.18-post \
http://0install.net/2007/interfaces/ZeroInstall.xml 0.41 0.42
A summary is printed at the end showing the result of each combination:
- Passed
- the tests all passed successfully (the command returned an exit status of zero)
- Skipped
- this combination of versions can't be used together (or no tests are defined)
- Failed
- some tests failed (the self-test command returned a non-zero exit status)
Specifying a test command
The --test-command option can be used to run the command of your choice, rather than the test command given in the feed's self-test attribute. The path of the program's main executable is available as $1.
For example, to check that "rox --version" worked in versions 2.8 and 2.9 of ROX-Filer:
0test -t '$1 --version > /dev/null' http://rox.sourceforge.net/2005/interfaces/ROX-Filer 2.8 2.9
Test-only dependencies
Dependencies marked with use="testing" in their feed are normally ignored by 0launch. However, when using 0test they are enabled.
This allows you to add extra dependencies that are only used when testing your program. For example, you can use this to depend on a testing framework or a large test data-set:
<group self-test="tests/testall.py">
<requires interface="http://example.com/somelib.xml">
...
</requires>
<requires interface="http://testing.com/testframework.xml" use="testing">
<environment insert="" mode="replace" name="TEST_FRAMEWORK"/>
</requires>
<implementation id="." version="0.1-pre"/>
</group>
Note: 0launch < 0.43 doesn't know about the use attribute and will include the dependency in all cases.