From ad9cb418c41a9b777a20ce04c4b90c63d94d9113 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Wed, 10 Jul 2013 08:42:49 -0700 Subject: [PATCH] Display line number with assertion for failed test cases Summary: We use custom `assert*` functions here and there. Remove them from backtrace. Test Plan: Ran `XHPASTTreeTestCase`. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D6411 --- src/unit/engine/phutil/ArcanistPhutilTestCase.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/unit/engine/phutil/ArcanistPhutilTestCase.php b/src/unit/engine/phutil/ArcanistPhutilTestCase.php index 9b4f2bda..d88e5e93 100644 --- a/src/unit/engine/phutil/ArcanistPhutilTestCase.php +++ b/src/unit/engine/phutil/ArcanistPhutilTestCase.php @@ -52,8 +52,12 @@ abstract class ArcanistPhutilTestCase { $expect = PhutilReadableSerializer::printableValue($expect); $result = PhutilReadableSerializer::printableValue($result); - $where = debug_backtrace(); - $where = array_shift($where); + foreach (debug_backtrace() as $location) { + if (!preg_match('/^assert[A-Z]/', idx($location, 'function'))) { + break; + } + $where = $location; + } $line = idx($where, 'line'); $file = basename(idx($where, 'file')); -- 2.43.0