| Path: | test/README.tests |
| Last Update: | Mon Oct 09 14:26:26 +0100 2006 |
This directory has both unit tests for the core VM and functional tests for the VM‘s runtime processes, and integration with the runtime library itself. You can run either set of tests, or all at once, using Rake from the top-level project directory thus:
$ rake test # alias for $ rake alltests $ rake unittests $ rake functests
The functional tests each depend on one or more Java classes, compiled from source kept in test/java_classes. If you use Rake to run those tests, the source will be compiled before the run (you‘ll need javac in your path). If you‘re running tests manually, you‘ll need to make sure the java is compiled first.
The test directory also has a runner.rb for use outside Rake, and testmodel / helper code.
Unit tests are named test_*.rb and functional tests are named func_test*.rb The unit test names pretty much speak for themselves. Most tests contain quite a few TODO comments (especially test_op_compat.rb). Functional tests are numbered, with the requirements on the VM generally increasing with the test number.
Currently, Functional tests 0-9 test the basic runtime behaviour of the VM, testing primitives, method dispatch, and so on.
Tests 10-19 focus on simple object instantiation, integration with core classes java.lang.Object and java.lang.String, and implicit native implementation.
Tests 20 and onward are more involved in terms of demand on runtime library integration, These tests usually involve the full initialization of the runtime library, and test the behaviour of certain important classes (e.g. java.util.Hashtable). Exception throw/catch is also tested in these tests, since a runtime implementation of java.lang.Exception involves many other classes, access to system properties, and native method dispatch.
When running the functional tests, you can specify an execution tracer to pass to the VM via the TRACER environment variable, which should be a ruby expression that will instantiate an appropriate tracer.
Ruva includes a print-tracer, which outputs the trace to stdout, or the stream of your choice.
To use it with Rake, do like so:
$ rake functests TRACER='Ruva::Utils::PrintTracer.new'
or, to send output somewhere else:
$ rake functests TRACER='Ruva::Utils::PrintTracer.new(some_stream)'
If you‘re running tests manually, how you specify this depends on your shell. You could either set the environment variable, or supply it on the command-line if your shell allows. In Bash, for example, you could run:
$ TRACER='Ruva::Utils::PrintTracer.new' ruby func_test10.rb
Bear in mind, though, that you‘ll often get a fair bit of output from the tracer, especially with tests 20 and up where the full runtime init gets run.