From be78aeae4c429d7d68af3a3e1b0cf8e52fcff160 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 20 Aug 2019 13:42:26 -0300 Subject: Default for warnings changed to "off" Warnings are mostly a tool to help developers (e.g., by showing hidden error messages); regular users usually don't need to see them. --- testes/all.lua | 5 +++-- testes/coroutine.lua | 1 + testes/gc.lua | 2 +- testes/locals.lua | 1 + testes/main.lua | 11 +++++++---- 5 files changed, 13 insertions(+), 7 deletions(-) (limited to 'testes') diff --git a/testes/all.lua b/testes/all.lua index 42809b9a..db074dd8 100644 --- a/testes/all.lua +++ b/testes/all.lua @@ -5,8 +5,8 @@ local version = "Lua 5.4" if _VERSION ~= version then - warn("This test suite is for ", version, - ", not for ", _VERSION, "\nExiting tests") + io.stderr:write("This test suite is for ", version, + ", not for ", _VERSION, "\nExiting tests") return end @@ -210,6 +210,7 @@ if #msgs > 0 then end print("(there should be two warnings now)") +warn("@on") warn("#This is ", "an expected", " warning") warn("@off") warn("******** THIS WARNING SHOULD NOT APPEAR **********") diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 4fc23261..79bbf2ea 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua @@ -163,6 +163,7 @@ do assert(not X and coroutine.status(co) == "dead") -- error closing a coroutine + warn("@on") local x = 0 co = coroutine.create(function() local y = func2close(function (self,err) diff --git a/testes/gc.lua b/testes/gc.lua index 34854d6f..bb4e3493 100644 --- a/testes/gc.lua +++ b/testes/gc.lua @@ -369,7 +369,7 @@ if T then s[n] = i end - warn("@store") + warn("@on"); warn("@store") collectgarbage() assert(string.find(_WARN, "error in __gc metamethod")) assert(string.match(_WARN, "@(.-)@") == "expected"); _WARN = nil diff --git a/testes/locals.lua b/testes/locals.lua index b4de523d..58ad18cc 100644 --- a/testes/locals.lua +++ b/testes/locals.lua @@ -313,6 +313,7 @@ local function checkwarn (msg) end end +warn("@on") do print("testing errors in __close") diff --git a/testes/main.lua b/testes/main.lua index 5d2652cb..de14a088 100644 --- a/testes/main.lua +++ b/testes/main.lua @@ -221,8 +221,11 @@ assert(string.find(getoutput(), "error calling 'print'")) RUN('echo "io.stderr:write(1000)\ncont" | lua -e "require\'debug\'.debug()" 2> %s', out) checkout("lua_debug> 1000lua_debug> ") --- test warnings -RUN('echo "io.stderr:write(1); warn[[XXX]]" | lua -q 2> %s', out) + +print("testing warnings") + +-- no warnings by default +RUN('echo "io.stderr:write(1); warn[[XXX]]" | lua 2> %s', out) checkout("1") prepfile[[ @@ -236,7 +239,7 @@ warn("", "@on") -- again, no control, real warning warn("@on") -- keep it "started" warn("Z", "Z", "Z") -- common warning ]] -RUN('lua %s 2> %s', prog, out) +RUN('lua -W %s 2> %s', prog, out) checkout[[ Lua warning: @offXXX@off Lua warning: @on @@ -250,7 +253,7 @@ warn("@allow") u1 = setmetatable({}, {__gc = function () error("XYZ") end}) u2 = setmetatable({}, {__gc = function () error("ZYX") end}) ]] -RUN('lua %s 2> %s', prog, out) +RUN('lua -W %s 2> %s', prog, out) checkprogout("ZYX)\nXYZ)\n") -- cgit v1.2.3-55-g6feb