From 167486b3168189521e79e1c68c2cce72945f4bfb Mon Sep 17 00:00:00 2001 From: David Monllao Date: Wed, 12 Feb 2014 17:37:58 +0800 Subject: [PATCH] MDL-44111 behat: Limiting dump files filename size --- lib/tests/behat/behat_hooks.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 6ac31a6183a..00485d15396 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -358,7 +358,7 @@ class behat_hooks extends behat_base { * This is used for content such as the DOM, and screenshots. * * @param StepEvent $event - * @param String $filetype The file suffix to use. + * @param String $filetype The file suffix to use. Limited to 4 chars. */ protected function get_faildump_filename(StepEvent $event, $filetype) { global $CFG; @@ -381,7 +381,11 @@ class behat_hooks extends behat_base { // The scenario title + the failed step text. // We want a i-am-the-scenario-title_i-am-the-failed-step.$filetype format. $filename = $event->getStep()->getParent()->getTitle() . '_' . $event->getStep()->getText(); - $filename = preg_replace('/([^a-zA-Z0-9\_]+)/', '-', $filename) . '.' . $filetype; + $filename = preg_replace('/([^a-zA-Z0-9\_]+)/', '-', $filename); + + // File name limited to 256 characters. Leaving 4 chars for the file + // extension as we allow .png for images and .html for DOM contents. + $filename = substr($filename, 0, 251) . '.' . $filetype; return array($dir, $filename); }