phpcoverage.remote.bottom.inc.php 1.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?php
/*
 *  $Id: phpcoverage.remote.bottom.inc.php 14665 2005-03-23 19:37:50Z npac $
 *  
 *  Copyright(c) 2004-2006, SpikeSource Inc. All Rights Reserved.
 *  Licensed under the Open Software License version 2.1
 *  (See http://www.spikesource.com/license.html)
*/
?>
<?php

    if(isset($_REQUEST)) {
        global $spc_config, $util;
        $logger = $util->getLogger();

        // Create a distinct hash (may or may not be unique)
        $session_id = md5($_SERVER["REMOTE_ADDR"] . $_SERVER["SERVER_NAME"]);
        $tmpFile = $util->getTmpDir() . "/phpcoverage.session." . $session_id;
        $logger->info("[phpcoverage.remote.bottom.inc.php] Session id: " . $session_id,
            __FILE__, __LINE__);

22
        if( ! isset($cov)) {
23 24 25 26 27 28 29 30 31
            if(file_exists($tmpFile)) {
                $object = file_get_contents($tmpFile);
                $cov = unserialize($object);
                $logger->info("[phpcoverage.remote.bottom.inc.php] Coverage object found: " . $cov, __FILE__, __LINE__);
            }
        }

        if(isset($cov)) {
            // PHPCoverage bottom half
32
            if( ! isset($called_script)) {
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
                $called_script = "";
            }
            $logger->info("[phpcoverage.remote.bottom.inc.php] END: " . $called_script,
                __FILE__, __LINE__);
            // Save the code coverage
            $cov->saveCoverageXml();
            $logger->info("[phpcoverage.remote.bottom.inc.php] Saved coverage xml",
                __FILE__, __LINE__);
            $cov->startInstrumentation();
            $logger->info("[phpcoverage.remote.bottom.inc.php] Instrumentation turned on.",
                __FILE__, __LINE__);
            $object = serialize($cov);
            file_put_contents($tmpFile, $object);
            $logger->info("[phpcoverage.remote.bottom.inc.php] ################## END ###################",
                __FILE__, __LINE__);
        }
    }

?>