MDL-68705 testing: New CLI args to disable composer features

This commit introduces the following new flags:

  --no-composer-self-update   Disable composer self-update of the
                              composer.phar utility

  --no-composer-upgrade       Disable upgrade of development
                              dependencies using Composer.

  --disable-composer          Disable both composer self-update and
                              composer upgrade
This commit is contained in:
Andrew Nicols 2020-08-04 11:21:03 +08:00 committed by Eloy Lafuente (stronk7)
parent b430493ca8
commit 5e60d77da1
2 changed files with 88 additions and 12 deletions

View file

@ -50,6 +50,9 @@ list($options, $unrecognized) = cli_get_params(
'optimize-runs' => '',
'add-core-features-to-theme' => false,
'axe' => false,
'disable-composer' => false,
'composer-upgrade' => true,
'composer-self-update' => true,
),
array(
'j' => 'parallel',
@ -65,19 +68,36 @@ $help = "
Behat utilities to initialise behat tests
Usage:
php init.php [--parallel=value [--maxruns=value] [--fromrun=value --torun=value]] [--help]
php init.php [--parallel=value [--maxruns=value] [--fromrun=value --torun=value]]
[--axe] [-o | --optimize-runs] [-a | --add-core-features-to-theme]
[--no-composer-self-update] [--no-composer-upgrade]
[--disable-composer]
[--help]
Options:
-j, --parallel Number of parallel behat run to initialise
-m, --maxruns Max parallel processes to be executed at one time.
--fromrun Execute run starting from (Used for parallel runs on different vms)
--torun Execute run till (Used for parallel runs on different vms)
--axe Include axe accessibility tests
-j, --parallel Number of parallel behat run to initialise
-m, --maxruns Max parallel processes to be executed at one time
--fromrun Execute run starting from (Used for parallel runs on different vms)
--torun Execute run till (Used for parallel runs on different vms)
--axe Include axe accessibility tests
-o, --optimize-runs Split features with specified tags in all parallel runs.
-a, --add-core-features-to-theme Add all core features to specified theme's
-o, --optimize-runs
Split features with specified tags in all parallel runs.
-h, --help Print out this help
-a, --add-core-features-to-theme
Add all core features to specified theme's
--no-composer-self-update
Prevent upgrade of the composer utility using its self-update command
--no-composer-upgrade
Prevent update development dependencies using composer
--disable-composer
A shortcut to disable composer self-update and dependency update
Note: Installation of composer and/or dependencies will still happen as required
-h, --help Print out this help
Example from Moodle root directory:
\$ php admin/tool/behat/cli/init.php --parallel=2
@ -120,8 +140,15 @@ if ($options['parallel'] && $options['parallel'] > 1) {
$cwd = getcwd();
$output = null;
// If behat dependencies not downloaded then do it first, else symfony/process can't be used.
testing_update_composer_dependencies();
if ($options['disable-composer']) {
// Disable self-update and upgrade easily.
// Note: Installation will still occur regardless of this setting.
$options['composer-self-update'] = false;
$options['composer-upgrade'] = false;
}
// Install and update composer and dependencies as required.
testing_update_composer_dependencies($options['composer-self-update'], $options['composer-upgrade']);
// Check whether the behat test environment needs to be updated.
chdir(__DIR__);

View file

@ -38,8 +38,57 @@ require_once(__DIR__.'/../../../../lib/clilib.php');
require_once(__DIR__.'/../../../../lib/phpunit/bootstraplib.php');
require_once(__DIR__.'/../../../../lib/testing/lib.php');
list($options, $unrecognized) = cli_get_params(
[
'help' => false,
'disable-composer' => false,
'composer-upgrade' => true,
'composer-self-update' => true,
],
[
'h' => 'help',
]
);
$help = "
Utilities to initialise the PHPUnit test site.
Usage:
php init.php [--no-composer-self-update] [--no-composer-upgrade]
[--help]
--no-composer-self-update
Prevent upgrade of the composer utility using its self-update command
--no-composer-upgrade
Prevent update development dependencies using composer
--disable-composer
A shortcut to disable composer self-update and dependency update
Note: Installation of composer and/or dependencies will still happen as required
-h, --help Print out this help
Example from Moodle root directory:
\$ php admin/tool/phpunit/cli/init.php
";
if (!empty($options['help'])) {
echo $help;
exit(0);
}
echo "Initialising Moodle PHPUnit test environment...\n";
testing_update_composer_dependencies();
if ($options['disable-composer']) {
// Disable self-update and upgrade easily.
// Note: Installation will still occur regardless of this setting.
$options['composer-self-update'] = false;
$options['composer-upgrade'] = false;
}
// Install and update composer and dependencies as required.
testing_update_composer_dependencies($options['composer-self-update'], $options['composer-upgrade']);
$output = null;
exec('php --version', $output, $code);