summaryrefslogtreecommitdiffstats
path: root/3rdparty/simpletest/extensions/coverage/autocoverage.php
blob: 9fc961bf43af84407e324794dcf5748d46007d6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/**
 * @package        SimpleTest
 * @subpackage     Extensions
 */
/**
 * Include this in any file to start coverage, coverage will automatically end
 * when process dies.
 */
require_once(dirname(__FILE__) .'/coverage.php');

if (CodeCoverage::isCoverageOn()) {
    $coverage = CodeCoverage::getInstance();
    $coverage->startCoverage();
    register_shutdown_function("stop_coverage");
}

function stop_coverage() {
    # hack until i can think of a way to run tests first and w/o exiting
    $autorun = function_exists("run_local_tests");
    if ($autorun) {
        $result = run_local_tests();
    }
    CodeCoverage::getInstance()->stopCoverage();
    if ($autorun) {
        exit($result ? 0 : 1);
    }
}
?>