Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <diosmosis@users.noreply.github.com>2018-09-06 01:33:03 +0300
committerGitHub <noreply@github.com>2018-09-06 01:33:03 +0300
commitd679c5571ece625b9863c63ad9b99d09f28ce63f (patch)
tree92c8d40c945c21d9aaf13837eac24f91c7de4e97 /plugins/TestRunner
parent04c8456861787b50b22444617bef114eb00be7e1 (diff)
Add [tests] config option to enable logging in tests. (#13335)
* Add [tests] config option to enable logging in tests. * Allow tests:run/tests:run-ui commands to enable logging for individual runs + during tests only log to file. * Remove Fixture field * fix failing test * fixing build * Fix another failure. * Fix an other test.
Diffstat (limited to 'plugins/TestRunner')
-rw-r--r--plugins/TestRunner/Commands/TestsRun.php15
-rw-r--r--plugins/TestRunner/Commands/TestsRunUI.php7
-rw-r--r--plugins/TestRunner/Commands/TestsSetupFixture.php5
3 files changed, 22 insertions, 5 deletions
diff --git a/plugins/TestRunner/Commands/TestsRun.php b/plugins/TestRunner/Commands/TestsRun.php
index 76dd65583a..d60b5afc25 100644
--- a/plugins/TestRunner/Commands/TestsRun.php
+++ b/plugins/TestRunner/Commands/TestsRun.php
@@ -34,6 +34,7 @@ class TestsRun extends ConsoleCommand
$this->addOption('group', null, InputOption::VALUE_REQUIRED, 'Run only a specific test group. Separate multiple groups by comma, for instance core,plugins', '');
$this->addOption('file', null, InputOption::VALUE_REQUIRED, 'Execute tests within this file. Should be a path relative to the tests/PHPUnit directory.');
$this->addOption('testsuite', null, InputOption::VALUE_REQUIRED, 'Execute tests of a specific test suite, for instance unit, integration or system.');
+ $this->addOption('enable-logging', null, InputOption::VALUE_NONE, 'Enable logging to the configured log file during tests.');
}
protected function execute(InputInterface $input, OutputInterface $output)
@@ -43,6 +44,7 @@ class TestsRun extends ConsoleCommand
$magics = $input->getArgument('variables');
// @todo remove piwik-domain fallback in Matomo 4
$matomoDomain = $input->getOption('matomo-domain') ?: $input->getOption('piwik-domain');
+ $enableLogging = $input->getOption('enable-logging');
$groups = $this->getGroupsFromString($groups);
@@ -115,7 +117,7 @@ class TestsRun extends ConsoleCommand
}
}
- $this->executeTests($matomoDomain, $suite, $testFile, $groups, $options, $command, $output);
+ $this->executeTests($matomoDomain, $suite, $testFile, $groups, $options, $command, $output, $enableLogging);
return $this->returnVar;
}
@@ -160,12 +162,12 @@ class TestsRun extends ConsoleCommand
return $this->fixPathToTestFileOrDirectory($testFile);
}
- private function executeTests($piwikDomain, $suite, $testFile, $groups, $options, $command, OutputInterface $output)
+ private function executeTests($piwikDomain, $suite, $testFile, $groups, $options, $command, OutputInterface $output, $enableLogging)
{
if (empty($suite) && empty($groups) && empty($testFile)) {
foreach ($this->getTestsSuites() as $suite) {
$suite = $this->buildTestSuiteName($suite);
- $this->executeTests($piwikDomain, $suite, $testFile, $groups, $options, $command, $output);
+ $this->executeTests($piwikDomain, $suite, $testFile, $groups, $options, $command, $output, $enableLogging);
}
return;
@@ -177,15 +179,18 @@ class TestsRun extends ConsoleCommand
$params = $params . " " . $testFile;
}
- $this->executeTestRun($piwikDomain, $command, $params, $output);
+ $this->executeTestRun($piwikDomain, $command, $params, $output, $enableLogging);
}
- private function executeTestRun($piwikDomain, $command, $params, OutputInterface $output)
+ private function executeTestRun($piwikDomain, $command, $params, OutputInterface $output, $enableLogging)
{
$envVars = '';
if (!empty($piwikDomain)) {
$envVars .= "PIWIK_DOMAIN=$piwikDomain";
}
+ if (!empty($enableLogging)) {
+ $envVars .= " MATOMO_TESTS_ENABLE_LOGGING=1";
+ }
$cmd = $this->getCommand($envVars, $command, $params);
$output->writeln('Executing command: <info>' . $cmd . '</info>');
diff --git a/plugins/TestRunner/Commands/TestsRunUI.php b/plugins/TestRunner/Commands/TestsRunUI.php
index 3c6fc15aa5..3a59994dff 100644
--- a/plugins/TestRunner/Commands/TestsRunUI.php
+++ b/plugins/TestRunner/Commands/TestsRunUI.php
@@ -11,6 +11,7 @@ use Piwik\AssetManager;
use Piwik\Config;
use Piwik\Plugin\ConsoleCommand;
use Piwik\Tests\Framework\Fixture;
+use Piwik\Tests\Framework\TestingEnvironmentVariables;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -39,6 +40,7 @@ class TestsRunUI extends ConsoleCommand
$this->addOption('store-in-ui-tests-repo', null, InputOption::VALUE_NONE, "For tests");
$this->addOption('debug', null, InputOption::VALUE_NONE, "Enable phantomjs debugging");
$this->addOption('extra-options', null, InputOption::VALUE_REQUIRED, "Extra options to pass to phantomjs.");
+ $this->addOption('enable-logging', null, InputOption::VALUE_NONE, 'Enable logging to the configured log file during tests.');
}
protected function execute(InputInterface $input, OutputInterface $output)
@@ -58,6 +60,7 @@ class TestsRunUI extends ConsoleCommand
$debug = $input->getOption('debug');
// @todo remove piwik-domain fallback in Matomo 4
$matomoDomain = $input->getOption('matomo-domain') ?: $input->getOption('piwik-domain');
+ $enableLogging = $input->getOption('enable-logging');
if (!$skipDeleteAssets) {
AssetManager::getInstance()->removeMergedAssets();
@@ -112,6 +115,10 @@ class TestsRunUI extends ConsoleCommand
$phantomJsOptions[] = "--debug=true";
}
+ if ($enableLogging) {
+ $options[] = '--enable-logging';
+ }
+
$phantomJsOptions[] = "--ignore-ssl-errors=true";
if ($extraOptions) {
diff --git a/plugins/TestRunner/Commands/TestsSetupFixture.php b/plugins/TestRunner/Commands/TestsSetupFixture.php
index ae2554d52b..9675a6d8be 100644
--- a/plugins/TestRunner/Commands/TestsSetupFixture.php
+++ b/plugins/TestRunner/Commands/TestsSetupFixture.php
@@ -87,6 +87,7 @@ class TestsSetupFixture extends ConsoleCommand
"Used by UI tests. Sets the \$_SERVER global variable from a JSON string.");
$this->addOption('plugins', null, InputOption::VALUE_REQUIRED,
"Used by UI tests. Comma separated list of plugin names to activate and install when setting up a fixture.");
+ $this->addOption('enable-logging', null, InputOption::VALUE_NONE, 'If enabled, tests will log to the configured log file.');
}
protected function execute(InputInterface $input, OutputInterface $output)
@@ -95,6 +96,10 @@ class TestsSetupFixture extends ConsoleCommand
define('PIWIK_TEST_MODE', true);
}
+ if ($input->getOption('enable-logging')) {
+ putenv("MATOMO_TESTS_ENABLE_LOGGING=1");
+ }
+
Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables()));
$serverGlobal = $input->getOption('server-global');