Skip to content

Commit

Permalink
Merge branch 'MDL-69740' of https://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Oct 9, 2020
2 parents fac0b05 + 3a04854 commit b687080
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion admin/tool/behat/cli/util_single_run.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,13 @@
behat_config_manager::set_behat_run_config_value('axe', $options['axe']);

// Enable test mode.
$timestart = microtime(true);
mtrace('Creating Behat configuration ...', '');
behat_util::start_test_mode($options['add-core-features-to-theme'], $options['optimize-runs'], $parallel, $run);
mtrace(' done in ' . round(microtime(true) - $timestart, 2) . ' seconds.');

// Themes are only built in the 'enable' command.
behat_util::build_themes();
behat_util::build_themes(true);
mtrace("Testing environment themes built");

// This is only displayed once for parallel install.
Expand Down
5 changes: 2 additions & 3 deletions lib/behat/classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static function install_site() {
/**
* Build theme CSS.
*/
public static function build_themes() {
public static function build_themes($mtraceprogress = false) {
global $CFG;
require_once("{$CFG->libdir}/outputlib.php");

Expand All @@ -147,7 +147,7 @@ public static function build_themes() {
}, $themenames);

// Build the list of themes and cache them in local cache.
$themes = theme_build_css_for_themes($themeconfigs, ['ltr'], true);
$themes = theme_build_css_for_themes($themeconfigs, ['ltr'], true, $mtraceprogress);

$framework = self::get_framework();
$storageroot = self::get_dataroot() . "/{$framework}/themedata";
Expand Down Expand Up @@ -278,7 +278,6 @@ protected static function test_environment_problem() {
* @return void
*/
public static function start_test_mode($themesuitewithallfeatures = false, $tags = '', $parallelruns = 0, $run = 0) {
global $CFG;

if (!defined('BEHAT_UTIL')) {
throw new coding_exception('This method can be only used by Behat CLI tool');
Expand Down
11 changes: 10 additions & 1 deletion lib/outputlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ function theme_get_css_filename($themename, $globalrevision, $themerevision, $di
* @param bool $cache Should the generated files be stored in local cache.
* @return array The built theme content in a multi-dimensional array of name => direction => content
*/
function theme_build_css_for_themes($themeconfigs = [], $directions = ['rtl', 'ltr'], $cache = true): array {
function theme_build_css_for_themes($themeconfigs = [], $directions = ['rtl', 'ltr'],
$cache = true, $mtraceprogress = false): array {
global $CFG;

if (empty($themeconfigs)) {
Expand All @@ -202,6 +203,11 @@ function theme_build_css_for_themes($themeconfigs = [], $directions = ['rtl', 'l

// First generate all the new css.
foreach ($directions as $direction) {
if ($mtraceprogress) {
$timestart = microtime(true);
mtrace('Building theme CSS for ' . $themeconfig->name . ' [' .
$direction . '] ...', '');
}
// Lock it on. Technically we should build all themes for SVG and no SVG - but ie9 is out of support.
$themeconfig->force_svg_use(true);
$themeconfig->set_rtl_mode(($direction === 'rtl'));
Expand All @@ -212,6 +218,9 @@ function theme_build_css_for_themes($themeconfigs = [], $directions = ['rtl', 'l
$filename = theme_get_css_filename($themeconfig->name, $themerev, $newrevision, $direction);
css_store_css($themeconfig, $filename, $themecss[$direction]);
}
if ($mtraceprogress) {
mtrace(' done in ' . round(microtime(true) - $timestart, 2) . ' seconds.');
}
}
$themescss[$themeconfig->name] = $themecss;

Expand Down

0 comments on commit b687080

Please sign in to comment.