From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 497FC2A339 for ; Fri, 24 Aug 2018 08:51:26 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id umSwZD8eAUas for ; Fri, 24 Aug 2018 08:51:26 -0400 (EDT) Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id EDDB12A31A for ; Fri, 24 Aug 2018 08:51:25 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH] lua: show locals when a tap test fails From: Vladislav Shpilevoy References: <84509c8ab6e29159082ff27a5d72c9228adc1c21.1534595542.git.alexander.turenko@tarantool.org> <4ed59be1-1b73-423f-f016-d7ecb14ed907@tarantool.org> Message-ID: Date: Fri, 24 Aug 2018 15:51:23 +0300 MIME-Version: 1.0 In-Reply-To: <4ed59be1-1b73-423f-f016-d7ecb14ed907@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: Alexander Turenko , Eugine Blikh Cc: tarantool-patches@freelists.org Sorry, forgot diff. > > My diff (so far it is requested by SOP to paste it here): > diff --git a/src/lua/tap.lua b/src/lua/tap.lua index 9dd531422..625326065 100644 --- a/src/lua/tap.lua +++ b/src/lua/tap.lua @@ -41,21 +41,19 @@ local function locals(test, level) local variables = {} local idx = 1 while true do - local name, value = debug.getlocal(level, idx) - if name ~= nil then - -- compare a table with a tuple raises an error, so we check types - -- first - local eq = type(value) == type(test) and value == test - -- temporary values start with '(' - if not name:startswith('(') and not eq then - variables[name] = value - end - else - break - end - idx = 1 + idx + local name, value = debug.getlocal(level, idx) + if not name then + return variables + end + -- Compare a table with a tuple raises an error, so we + -- check types first. + local is_test = type(value) == type(test) and value == test + -- Temporary values start with '('. + if not name:startswith('(') and not is_test then + variables[name] = value + end + idx = idx + 1 end - return variables end local function diag(test, fmt, ...)