Silence warnings in examples (#944)

There was a problem that the examples were considered to have failed as soon as
they produced any kind of output, but there were legitimate cases of warnings
being printed that triggered these checks. Commit 4819be4f4f used a
regular expression to detect and ignore this warnings.

This commit reverts the above commit and instead silences the warnings by
monkey-patching the function that prints the warnings into a no-op.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-06-07 22:57:01 +02:00 committed by Daniel Hahler
parent efb8e65b15
commit ffe64727fe
7 changed files with 19 additions and 28 deletions

View File

@ -106,32 +106,6 @@ function(escape_code path escaped_content pre_header post_header)
set(${post_header} ${example_post_header} PARENT_SCOPE) set(${post_header} ${example_post_header} PARENT_SCOPE)
endfunction() endfunction()
# Only gears.debug.print_warning are allowed on stderr, everything else will
# trigger a build failure to catch regressions and problem early.
function(check_for_problems stderr result)
# If there is nothing to check, return
if (TEST_ERROR STREQUAL "")
set(${result} 0 PARENT_SCOPE)
return()
endif()
string(REGEX REPLACE "\n" ";" error_lines "${stderr}")
foreach (LINE ${error_lines})
# gears.debug.print_warning lines look like:
# yyyy-mm-dd hh:mm:ss W: message content
if (NOT ${LINE} MATCHES "^[0-9 :-]+ W:")
set(${result} 1 PARENT_SCOPE)
return()
endif()
endforeach()
set(${result} 0 PARENT_SCOPE)
endfunction()
# Execute a lua file. # Execute a lua file.
function(run_test test_path namespace template escaped_content) function(run_test test_path namespace template escaped_content)
@ -159,8 +133,7 @@ function(run_test test_path namespace template escaped_content)
) )
# If there is something on stderr, exit # If there is something on stderr, exit
check_for_problems("${TEST_ERROR}" problems_found) if (NOT TEST_ERROR STREQUAL "")
if (${problems_found})
message("${TEST_OUTPUT}") message("${TEST_OUTPUT}")
message("${TEST_ERROR}") message("${TEST_ERROR}")
message(FATAL_ERROR ${test_path} " A test failed, bye") message(FATAL_ERROR ${test_path} " A test failed, bye")

View File

@ -22,6 +22,9 @@ pcall(function()
require("luacov.runner")(luacovpath) require("luacov.runner")(luacovpath)
end) end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
local color = require( "gears.color" ) local color = require( "gears.color" )
local shape = require( "gears.shape" ) local shape = require( "gears.shape" )
local beautiful = require( "beautiful" ) local beautiful = require( "beautiful" )

View File

@ -10,6 +10,9 @@ pcall(function()
require("luacov.runner")(luacovpath) require("luacov.runner")(luacovpath)
end) end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
local function get_surface(p) local function get_surface(p)
local img = cairo.SvgSurface.create(p, 288, 76) local img = cairo.SvgSurface.create(p, 288, 76)
return cairo.Context(img) return cairo.Context(img)

View File

@ -15,5 +15,8 @@ pcall(function()
require("luacov.runner")(luacovpath) require("luacov.runner")(luacovpath)
end) end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
-- Execute the test -- Execute the test
loadfile(file_path)() loadfile(file_path)()

View File

@ -21,6 +21,9 @@ pcall(function()
require("luacov.runner")(luacovpath) require("luacov.runner")(luacovpath)
end) end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
-- Let the test request a size and file format -- Let the test request a size and file format
local before, after = loadfile(file_path)() local before, after = loadfile(file_path)()

View File

@ -21,6 +21,9 @@ pcall(function()
require("luacov.runner")(luacovpath) require("luacov.runner")(luacovpath)
end) end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
-- Create a generic rectangle widget to show layout disposition -- Create a generic rectangle widget to show layout disposition
local function generic_widget(text) local function generic_widget(text)
return { return {

View File

@ -19,6 +19,9 @@ pcall(function()
require("luacov.runner")(luacovpath) require("luacov.runner")(luacovpath)
end) end)
-- Silence debug warnings
require("gears.debug").print_warning = function() end
-- This is the main widget the tests will use as top level -- This is the main widget the tests will use as top level
local container = wibox.layout.fixed.vertical() local container = wibox.layout.fixed.vertical()