Bug 502907 - Allow for the registration of cleanup functions that run when the harness is done

Consumers can now call do_register_cleanup with a function that will run when
the harness is done running the tests.
r=ted
This commit is contained in:
Shawn Wilsher 2009-07-10 16:42:59 -07:00
Родитель 7c5e4009b8
Коммит 9730a9ab81
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -49,6 +49,7 @@ var _quit = false;
var _passed = true;
var _tests_pending = 0;
var _passedChecks = 0, _falsePassedChecks = 0;
var _cleanupFunctions = [];
// Disable automatic network detection, so tests work correctly when
// not connected to a network.
@ -136,6 +137,11 @@ function _execute_test() {
// _TAIL_FILES is dynamically defined by <runxpcshelltests.py>.
_load_files(_TAIL_FILES);
// Execute all of our cleanup functions.
var func;
while ((func = _cleanupFunctions.pop()))
func();
if (!_passed)
return;
@ -337,3 +343,15 @@ function do_parse_document(aPath, aType) {
lf = null;
return doc;
}
/**
* Registers a function that will run when the test harness is done running all
* tests.
*
* @param aFunction
* The function to be called when the test harness has finished running.
*/
function do_register_cleanup(aFunction)
{
_cleanupFunctions.push(aFunction);
}