diff --git a/plugins/TestRunner/Commands/TestsRunUI.php b/plugins/TestRunner/Commands/TestsRunUI.php index e02a452607ddf168c162e1e49742bccd36e7dbe5..453b777570a91424573875771d2c4260c434ee5e 100644 --- a/plugins/TestRunner/Commands/TestsRunUI.php +++ b/plugins/TestRunner/Commands/TestsRunUI.php @@ -27,6 +27,7 @@ class TestsRunUI extends ConsoleCommand $this->addOption('drop', null, InputOption::VALUE_NONE, "Drop the existing database and re-setup a persisted fixture."); $this->addOption('assume-artifacts', null, InputOption::VALUE_NONE, "Assume the diffviewer and processed screenshots will be stored on the builds artifacts server. For use with travis build."); $this->addOption('plugin', null, InputOption::VALUE_REQUIRED, "Execute all tests for a plugin."); + $this->addOption('core', null, InputOption::VALUE_NONE, "Execute only tests for Piwik core & core plugins."); $this->addOption('skip-delete-assets', null, InputOption::VALUE_NONE, "Skip deleting of merged assets (will speed up a test run, but not by a lot)."); } @@ -40,6 +41,7 @@ class TestsRunUI extends ConsoleCommand $assumeArtifacts = $input->getOption('assume-artifacts'); $plugin = $input->getOption('plugin'); $skipDeleteAssets = $input->getOption('skip-delete-assets'); + $core = $input->getOption('core'); if (!$skipDeleteAssets) { AssetManager::getInstance()->removeMergedAssets(); @@ -69,6 +71,11 @@ class TestsRunUI extends ConsoleCommand if ($plugin) { $options[] = "--plugin=" . $plugin; } + + if ($core) { + $options[] = "--core"; + } + $options = implode(" ", $options); $specs = implode(" ", $specs); diff --git a/tests/lib/screenshot-testing/support/app.js b/tests/lib/screenshot-testing/support/app.js index 674377d0b6bec4dc364c0477c098a3c59714af03..0de86e1da3046c3207efce99d121f41c6becfb37 100644 --- a/tests/lib/screenshot-testing/support/app.js +++ b/tests/lib/screenshot-testing/support/app.js @@ -33,6 +33,12 @@ var walk = function (dir, pattern, result) { return result; }; +var isCorePlugin = function (pathToPlugin) { + // if the plugin is a .git checkout, it's not part of core + var gitDir = path.join(pathToPlugin, '.git'); + return !fs.exists(gitDir); +}; + var Application = function () { this.runner = null; @@ -59,6 +65,7 @@ Application.prototype.printHelpAndExit = function () { console.log(" builds artifacts server. For use with travis build."); console.log(" --screenshot-repo: Specifies the github repository that contains the expected screenshots"); console.log(" to link to in the diffviewer. For use with travis build."); + console.log(" --core: Only execute UI tests that are for Piwik core or Piwik core plugins."); phantom.exit(0); }; @@ -94,6 +101,12 @@ Application.prototype.loadTestModules = function () { // load all UI tests we can find var modulePaths = walk(uiTestsDir, /_spec\.js$/); + if (options.core) { + plugins = plugins.filter(function (path) { + return isCorePlugin(path); + }); + } + plugins.forEach(function (pluginPath) { walk(path.join(pluginPath, 'Test'), /_spec\.js$/, modulePaths); walk(path.join(pluginPath, 'tests'), /_spec\.js$/, modulePaths); diff --git a/tests/travis/travis.sh b/tests/travis/travis.sh index 9f871a037d9d99423bc8104a669e08b640046a07..383a0e3a2de929bda2ca3bfeda242a2b9ea7709d 100755 --- a/tests/travis/travis.sh +++ b/tests/travis/travis.sh @@ -50,7 +50,7 @@ then then phantomjs ../lib/screenshot-testing/run-tests.js --assume-artifacts --persist-fixture-data --screenshot-repo=$TRAVIS_REPO_SLUG --plugin=$PLUGIN_NAME else - phantomjs ../lib/screenshot-testing/run-tests.js --store-in-ui-tests-repo --persist-fixture-data --assume-artifacts + phantomjs ../lib/screenshot-testing/run-tests.js --store-in-ui-tests-repo --persist-fixture-data --assume-artifacts --core fi elif [ "$TEST_SUITE" = "AllTests" ] then