From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 0CC56741CE; Wed, 6 Oct 2021 16:04:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0CC56741CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633525496; bh=VkDJ22Jfv2ysjPkGiVFZqC50gM1c+xRxxo4ifuZgcWU=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ilOLvJyxXywBDHX+AJwaY9fJQ9PC0JqHi539y0w29YBkzviOogRKzf0tTXW3RetXd 2CgegD9ndomCPAFISgWFokD8UoPqo71917uC+9o4vEyN5x3+DvGF5JX4SwnGIUJE3T mW2QfF61GzgkdCtdfKVa63Zn9o4dn0uWQStOsgUw= Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 610B0741CE for ; Wed, 6 Oct 2021 16:04:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 610B0741CE Received: by mail-lf1-f42.google.com with SMTP id u18so10061140lfd.12 for ; Wed, 06 Oct 2021 06:04:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M8v3BbPOjf8yK6TclYj5BTGKiocZgwj+yD+INMg2KNQ=; b=yyQlbcUJC6EBW+kvf7nm4Mkpg1MzdzY3NmBPffnnaEMcuQ2vf2gJrLvkDiv5xR6dqi ZQPA4Be3TlN7yjTm/lbqwDmGliImrjz9hT+jrcIpA4ARSvM1aUk/IlXF5T7zXPdou35A LV1kaiObXXCZmAtBlVgGP7XhOPddzGypZhYsTBHBtIIKr5ASKeyKST/LykX8zkmqGmca hpG2sxvUM8U3MHIL9+YzuHFnwOE93egmaAIQ4h4HKfmnwEU181DbHNdXNSSW9NloUuyI gbUTBY45dY+ywJVMVEQKKjfZsiIfZqSHQSftpUYKoNLfb7U8VqzjOnIqjFVwCsQgcHQ0 DsHw== X-Gm-Message-State: AOAM532ARR3o18mSPqV95GZD6JH8st9XkCUYL9QEWkBhLkll/L59EtLU XGrreB2Pw4SW/NCif6Nubs331a4lnqrytg== X-Google-Smtp-Source: ABdhPJwUNRNg2JtHX4G3khKspNQCbiFdP3X8SitjSjemTUSdQG3pM0idDX5RAL9DAg3GCNzvNP1eOw== X-Received: by 2002:a2e:834e:: with SMTP id l14mr4520946ljh.215.1633525488506; Wed, 06 Oct 2021 06:04:48 -0700 (PDT) Received: from localhost.localdomain ([93.175.11.199]) by smtp.gmail.com with ESMTPSA id f13sm659184lfc.241.2021.10.06.06.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 06:04:47 -0700 (PDT) X-Google-Original-From: Maxim Kokryashkin To: tarantool-patches@dev.tarantool.org, imun@tarantool.org, skaplun@tarantool.org, m.shishatskiy@tarantool.org Date: Wed, 6 Oct 2021 16:04:44 +0300 Message-Id: <20211006130444.3031234-1-m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Maxim Kokryashkin via Tarantool-patches Reply-To: Maxim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" LuaJIT doesn't take into account tail calls for call-level counting, so `getfenv()` behaviour is different in tail calls. getfenv()` default level is 1 which is invalid for the test case when is called from tail call (`lj_debug_frame()` returns NULL). This commits adds local varibles, so there is no tail call any more. Part of tarantool/tarantool#5870 --- Issue: https://github.com/tarantool/tarantool/issues/5713 GitHub branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio CI: https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio test/PUC-Rio-Lua-5.1-tests/closure.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/test/PUC-Rio-Lua-5.1-tests/closure.lua b/test/PUC-Rio-Lua-5.1-tests/closure.lua index 551fe70d..86f6ad87 100644 --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua @@ -167,22 +167,23 @@ local function foo (a) assert(getfenv(0) == a) assert(getfenv(1) == _G) assert(getfenv(loadstring"") == a) - return getfenv() + +-- LuaJIT doesn't take into account tail calls for +-- call-level counting, so `getfenv()` behaviour is different +-- in tail calls. For example, `pcall()` to this functon returns false +-- in case of tailcall, because `getfenv()` default level is 1 which +-- is invalid for this case (`lj_debug_frame()` returns NULL). +-- See also https://github.com/tarantool/tarantool/issues/5713. + local env = getfenv() + return env end f = coroutine.wrap(foo) local a = {} assert(f(a) == _G) local a,b = pcall(f) --- FIXME: LuaJIT doesn't take into account tail calls for --- call-level counting, so `getfenv()` behaviour is different --- in tail calls. For example, this `pcall()` returns false, --- because `getfenv()` default level is 1 which is invalid for --- this case when is called from tail call (`lj_debug_frame()` --- returns NULL). --- See also https://github.com/tarantool/tarantool/issues/5713. --- Test is disabled for LuaJIT for now. --- assert(a and b == _G) +-- Test is adapted to the behavior LuaJIT. See the comment above. +assert(a and b == _G) -- tests for multiple yield/resume arguments -- 2.33.0