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 2F8F06E46D; Wed, 13 Oct 2021 18:55:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2F8F06E46D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1634140520; bh=xxMk3u/PxlFO0DAvpawtCd6jLknx8niuguZItRwugQ0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=rw+JxOwL7635yeqwe/pfin33IF9yZ4AXsQMaLgHUYaYW5vd4NQ73bgbLzXMc4moKm i9O5woJu76TCOxiVDGrJNww3caxMHaXkmfpuNJldobpVlmqyXvocRP5uVIWl6MgkiA VaMsWiaEbh71OxPePULSjuED4XX7ue3gGOINORN0= Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 10FF86E46D for ; Wed, 13 Oct 2021 18:55:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 10FF86E46D Received: by mail-lf1-f41.google.com with SMTP id z11so13236353lfj.4 for ; Wed, 13 Oct 2021 08:55:19 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=7aVBupDdjgrnLJqZ262Rv5zHW8JNvQBBTfKvYk0eMIQ=; b=RzbCjOKY5x5mnLqEUCvATyEIWULMIqunbC30MNfsgA5WaWsefKDKtwHyteLEr6SdfP opUIcFOe92na0cvqL/4Kuv2xfAShBYJ5zbIuw5i/IeRy/he7v6tHggVOR5c/34xD88XY 9IWPNTg9hLW1/buutPuj/8/hZ67Nqlp7JFWuWaxftmfsz+IFQeXIpbyK4GkImAeNgQ3q 6YkitzUKgCtL4XMWf3QOj14aCWyIp8XvqfvTz8Pr2wwBQyfSsuEgs3UyklVWZ1LknvQt 0Pf7z2EJu0LprmwkLQHObfMiVgUCd1nYN8b8dOlayDOTfwpwpfSRHCodWOUBeI/SKdJX amBA== X-Gm-Message-State: AOAM533gAdZujkzl6xmJ67o6RJwjBPID7JMNZrd5sQBsuCbbHOgBk7J6 sUEendcIQLGYuM+TEus+lZZPmIv9MZs= X-Google-Smtp-Source: ABdhPJyU1PP60ZcxokifAIFHC5IiYPGOkAWehElMnlkQ0xBOgqkOakRLh81n3ck4BCAoinOTOx7u9A== X-Received: by 2002:a2e:4a12:: with SMTP id x18mr136501lja.309.1634140504786; Wed, 13 Oct 2021 08:55:04 -0700 (PDT) Received: from localhost.localdomain ([93.175.11.199]) by smtp.gmail.com with ESMTPSA id b9sm1491303ljq.137.2021.10.13.08.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 08:55:04 -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, 13 Oct 2021 18:55:00 +0300 Message-Id: <20211013155500.2639254-1-m.kokryashkin@tarantool.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit v2] test: adapt disabled tests from PUC-Rio 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" Version and status are printed in stdout instead stderr since LuaJIT-2.0.0-beta11 (as it is not an error message). This behavior is the same as in Lua 5.2, so necessary changes in tests can be adapted from PUC-Rio Lua 5.2 test suite. However, those tests are disabled for Tarantool since its interactive shell doesn't support '=' at the beginning of statements. Here is an example: ======================================================================== $ luajit > = (6*2-6) -- === 6 $ tarantool tarantool> = (6*2-6) -- === --- - error: ' (6*2-6) -- ===:1: unexpected symbol near ''=''' ... ======================================================================== Part of tarantool/tarantool#5870 --- Changes in v2: - Fixed comments as per review by Sergey - Disabled some tests for Tarantool - Added link to CI jobs Issue: https://github.com/tarantool/tarantool/issues/5687 Branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5687-adapt-tests-output-PUC-Rio CI: https://github.com/tarantool/tarantool/tree/fckxorg/gh-5687-adapt-disabled-tests-from-PUC-Rio test/PUC-Rio-Lua-5.1-tests/main.lua | 97 ++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 31 deletions(-) diff --git a/test/PUC-Rio-Lua-5.1-tests/main.lua b/test/PUC-Rio-Lua-5.1-tests/main.lua index 07facc4c..38111560 100644 --- a/test/PUC-Rio-Lua-5.1-tests/main.lua +++ b/test/PUC-Rio-Lua-5.1-tests/main.lua @@ -24,11 +24,33 @@ local prepfile = function (s, p) assert(io.close()) end -function checkout (s) +-- Taken from PUC-Rio Lua 5.2 test suite. +-- See comment for checkprogout(). +function getoutput () io.input(out) local t = io.read("*a") io.input():close() assert(os.remove(out)) + return t +end + +-- Version and status are printed in stdout instead stderr since +-- LuaJIT-2.0.0-beta11 (as it is not an error message). +-- See commit 0bd1a66f2f055211ef55834ccebca3b82d03c735 +-- (Print version and JIT status to stdout, not stderr.). +-- This behavior is the same as in Lua 5.2. +-- See also https://github.com/tarantool/tarantool/issues/5687. +-- This function is adapted from PUC-Rio Lua 5.2 test suite. +-- It is used for test commands with -i flag. +function checkprogout (s) + local t = getoutput() + for line in string.gmatch(s, ".-\n") do + assert(string.find(t, line, 1, true)) + end +end + +function checkout (s) + local t = getoutput() if s ~= t then print(string.format("'%s' - '%s'\n", s, t)) end assert(s == t) return t @@ -117,39 +139,52 @@ prepfile[[ RUN("lua - < %s > %s", prog, out) checkout("1\tnil\n") --- FIXME: Version and status are printed to stdout instead of --- stderr since LuaJIT-2.0.0-beta11 (as it is not an error --- message). See commit 0bd1a66f2f055211ef55834ccebca3b82d03c735 --- (Print version and JIT status to stdout, not stderr.). --- This behavior is the same as in Lua 5.2. --- In Lua 5.2 this feature was introduced via commit --- 9e7de9473c65baee1f567852a778f2d33a47ea83. --- See also https://github.com/tarantool/tarantool/issues/5687. -prepfile[[ +-- FIXME: The following chunk is disabled for Tarantool since its interactive +-- shell doesn't support '=' at the beginning of statements. +-- Here is an example: +-- $ luajit +-- LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/ +-- JIT: ON SSE2 SSE3 SSE4.1 BMI2 fold cse dce fwd dse narrow loop abc sink fuse +-- > = (6*2-6) -- === +-- 6 + +-- $ tarantool +-- Tarantool 2.10.0-beta1-80-g201905544 +-- type 'help' for interactive help +-- tarantool> = (6*2-6) -- === +-- --- +-- - error: ' (6*2-6) -- ===:1: unexpected symbol near ''=''' +-- ... +if not _TARANTOOL then +-- Test is adapted from PUC-Rio Lua 5.2 test suite. +-- See comment for checkprogout(). + prepfile[[ = (6*2-6) -- === a = 10 print(a) = a]] --- FIXME: Behavior is different for LuaJIT. See the comment above. --- RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) --- checkout("6\n10\n10\n\n") - -prepfile("a = [[b\nc\nd\ne]]\n=a") -print(prog) --- FIXME: Behavior is different for LuaJIT. See the comment above. --- RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) --- checkout("b\nc\nd\ne\n\n") - -prompt = "alo" -prepfile[[ -- + RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) + checkprogout("6\n10\n10\n\n") + +-- Test is adapted from PUC-Rio Lua 5.2 test suite. +-- See comment for checkprogout(). + prepfile("a = [[b\nc\nd\ne]]\n=a") + print(prog) + RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) + checkprogout("b\nc\nd\ne\n\n") + +-- Test is adapted from PUC-Rio Lua 5.2 test suite. +-- See comment for checkprogout(). + prompt = "alo" + prepfile[[ -- a = 2 ]] --- FIXME: Behavior is different for LuaJIT. See the comment above. --- RUN([[lua "-e_PROMPT='%s'" -i < %s > %s]], prompt, prog, out) --- checkout(string.rep(prompt, 3).."\n") + RUN([[lua "-e_PROMPT='%s'" -i < %s > %s]], prompt, prog, out) + local t = getoutput() + assert(string.find(t, prompt .. ".*" .. prompt .. ".*" .. prompt)) -s = [=[ -- + s = [=[ -- function f ( x ) local a = [[ xuxu @@ -163,11 +198,11 @@ end =( f( 10 ) ) assert( a == b ) =f( 11 ) ]=] -s = string.gsub(s, ' ', '\n\n') -prepfile(s) --- FIXME: Behavior is different for LuaJIT. See the comment above. --- RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) --- checkout("11\n1\t2\n\n") + s = string.gsub(s, ' ', '\n\n') + prepfile(s) + RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out) + checkprogout("11\n1\t2\n\n") +end prepfile[[#comment in 1st line without \n at the end]] RUN("lua %s", prog) -- 2.33.0