From 0b8b2fd3647b566cfa836794d90ef790c3bb08a6 Mon Sep 17 00:00:00 2001 From: Tobias van Beek Date: Mon, 21 Jul 2014 13:42:39 +0200 Subject: [PATCH] Prevent undefined errors in TapParser if output from scripts failed. Closes #515 --- PHPCI/Plugin/Util/TapParser.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PHPCI/Plugin/Util/TapParser.php b/PHPCI/Plugin/Util/TapParser.php index 1aa25348..a18e89e5 100644 --- a/PHPCI/Plugin/Util/TapParser.php +++ b/PHPCI/Plugin/Util/TapParser.php @@ -44,7 +44,7 @@ class TapParser throw new \Exception('TapParser only supports TAP version 13'); } - if (preg_match(self::TEST_COVERAGE_PATTERN, $lines[count($lines) - 1])) { + if (isset($lines[count($lines) - 1]) && preg_match(self::TEST_COVERAGE_PATTERN, $lines[count($lines) - 1])) { array_pop($lines); if ($lines[count($lines) - 1] == "") { array_pop($lines); @@ -58,7 +58,8 @@ class TapParser $totalTests = (int) $matches[2]; } - if (preg_match(self::TEST_COUNTS_PATTERN, $lines[count($lines) - 1], $matches)) { + if (isset($lines[count($lines) - 1]) && + preg_match(self::TEST_COUNTS_PATTERN, $lines[count($lines) - 1], $matches)) { array_pop($lines); $totalTests = (int) $matches[2]; }