diff options
Diffstat (limited to 'tests/PHPUnit/BaseFixture.php')
-rw-r--r-- | tests/PHPUnit/BaseFixture.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/PHPUnit/BaseFixture.php b/tests/PHPUnit/BaseFixture.php index d9fc108698..8b1253299e 100644 --- a/tests/PHPUnit/BaseFixture.php +++ b/tests/PHPUnit/BaseFixture.php @@ -325,4 +325,34 @@ abstract class Test_Piwik_BaseFixture extends PHPUnit_Framework_Assert throw new Exception("gunzip failed($return): " . implode("\n", $output)); } } + + protected static function executeLogImporter($logFile, $options) + { + $python = Piwik_Common::isWindows() ? "C:\Python27\python.exe" : 'python'; + + // create the command + $cmd = $python + . ' "' . PIWIK_INCLUDE_PATH . '/misc/log-analytics/import_logs.py" ' # script loc + . '-ddd ' // debug + . '--url="' . self::getRootUrl() . 'tests/PHPUnit/proxy/" ' # proxy so that piwik uses test config files + ; + + foreach ($options as $name => $value) { + $cmd .= $name; + if ($value !== false) { + $cmd .= '="' . $value . '"'; + } + $cmd .= ' '; + } + + $cmd .= '"' . $logFile . '" 2>&1'; + + // run the command + exec($cmd, $output, $result); + if ($result !== 0) { + throw new Exception("log importer failed: " . implode("\n", $output) . "\n\ncommand used: $cmd"); + } + + return $output; + } } |