Mobile/Fennec Xpcshell: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 38: Line 38:


NOTE: this runs 593 tests where there are about 223 tests which run on Firefox.  We still need to figure out why these tests are in the tree, but not run.
NOTE: this runs 593 tests where there are about 223 tests which run on Firefox.  We still need to figure out why these tests are in the tree, but not run.
==Adding tests==
Add a directory named "tests" to the component. In the Makefile.in for the tests directory add a _TEST_FILES section with a list of the files in this directory needed to run the mochitest (the mochitest html file itself and any helper files). Then add this line to the bottom of the Makefile.in:
if test is in central code:
<pre>
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
</pre>
if test is in mobile:
<pre>
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/../xulrunner/_tests/testing/mochitest/tests/$(relativesrcdir)
</pre>
When you build, the tests will be added to the xulrunner application's mochitest set.

Revision as of 22:16, 30 January 2009

Getting the Tests

Edit your mozconfig to contain the following lines:

ac_add_options --enable-tests

Get the source and build according to instructions.

to learn more about the tests, visit the [MDC Guide]

Porting tests to N800

If following directions for running fennec on N800/N810 devices, you will need to package up the tests from the xulrunner directory and the test harness from the source tree:

cp $(topsrcdir)/harness/xpcshell/* $(xul_objdir)/_tests/
cd $(xul_objdir)/_tests
tar -chf xpcshell.tar xpcshell/ xpcshell-simple/

Transfer tar file to device via scp and untar it.

NOTE: it would be nice if the build script (make) would copy the test harness from the source tree to the xulrunner directory.

Running the tests

The tests are normally ran via "make check" from the root of the objdir. In this case, we are running the tests on the device and there is no source tree.

Inspecting the test_all.sh script in harness/xpcshell, you can run the test from the command line by doing this:

Run the tests from the directory where you unzipped them like so:

./run-mozilla.sh xpcshell  -f /media/mmc1/unittests/xpcshell/xpcshell/head.js  -f /media/mmc1/unittests/xpcshell/xpcshell-simple/test_update/unit/test_0051_general.js  -f /media/mmc1/unittests/xpcshell/xpcshell/tail.js  -f /media/mmc1/unittests/xpcshell/xpcshell/execute_test.js

This is a cumbersome process, and to make this reasonable, we have created a script to run the tests. This script needs to be edited to point to the xpcshell executable as well as the root of the test harness and test directories. It will iterate the tests and build up a list of test_ files to run tests against, then run the above command for you.

NOTE: this runs 593 tests where there are about 223 tests which run on Firefox. We still need to figure out why these tests are in the tree, but not run.