tests/examples/CMakeLists.txt: invoke luacov with `lua` directly

This commit is contained in:
Daniel Hahler 2017-01-04 20:26:46 +01:00
parent 2aca0871cd
commit eacc49243b
2 changed files with 14 additions and 12 deletions

View File

@ -24,7 +24,7 @@ else()
set(TOP_SOURCE_DIR ${CMAKE_SOURCE_DIR}) set(TOP_SOURCE_DIR ${CMAKE_SOURCE_DIR})
endif() endif()
if ($ENV{DO_COVERAGE}) if (DEFINED ENV{DO_COVERAGE} AND NOT $ENV{DO_COVERAGE} STREQUAL "0")
execute_process( execute_process(
COMMAND lua -e "require('luacov.runner')('${TOP_SOURCE_DIR}/.luacov')" COMMAND lua -e "require('luacov.runner')('${TOP_SOURCE_DIR}/.luacov')"
RESULT_VARIABLE TEST_RESULT RESULT_VARIABLE TEST_RESULT
@ -34,6 +34,9 @@ if ($ENV{DO_COVERAGE})
message(${TEST_ERROR}) message(${TEST_ERROR})
message(FATAL_ERROR "Failed to run luacov.runner.") message(FATAL_ERROR "Failed to run luacov.runner.")
endif() endif()
set(LUA_COV_RUNNER lua "-erequire('luacov.runner')('${TOP_SOURCE_DIR}/.luacov')")
else()
set(LUA_COV_RUNNER lua)
endif() endif()
# Add the main awesome lua libraries. # Add the main awesome lua libraries.
@ -174,15 +177,19 @@ function(run_test test_path namespace escaped_content)
# SVG is preferred, but PNG is better suited for some tests, like bitmap # SVG is preferred, but PNG is better suited for some tests, like bitmap
# patterns. # patterns.
execute_process( execute_process(
COMMAND lua ${template} ${test_path} ${IMAGE_PATH} COMMAND ${LUA_COV_RUNNER} ${template} ${test_path} ${IMAGE_PATH}
RESULT_VARIABLE TEST_RESULT
OUTPUT_VARIABLE TEST_OUTPUT OUTPUT_VARIABLE TEST_OUTPUT
ERROR_VARIABLE TEST_ERROR ERROR_VARIABLE TEST_ERROR
) )
if (TEST_RESULT OR NOT TEST_ERROR STREQUAL "")
# If there is something on stderr, exit. message("Result: ${TEST_RESULT}")
if (NOT TEST_ERROR STREQUAL "") if (NOT TEST_OUTPUT STREQUAL "")
message("${TEST_OUTPUT}") message("Output: ${TEST_OUTPUT}")
message("${TEST_ERROR}") endif()
if (NOT TEST_ERROR STREQUAL "")
message("Error: ${TEST_ERROR}")
endif()
if (STRICT_TESTS) if (STRICT_TESTS)
message(FATAL_ERROR ${test_path} " An example test failed, aborting.") message(FATAL_ERROR ${test_path} " An example test failed, aborting.")
endif() endif()

View File

@ -14,11 +14,6 @@ return function(_, _)
-- Force luacheck to be silent about setting those as unused globals -- Force luacheck to be silent about setting those as unused globals
assert(awesome and root and tag and screen and client and mouse) assert(awesome and root and tag and screen and client and mouse)
-- If luacov is available, use it. Else, do nothing.
if (os.getenv('DO_COVERAGE') or '0') ~= '0' then
require('luacov.runner')(os.getenv('SOURCE_DIRECTORY')..'/.luacov')
end
-- Silence debug warnings -- Silence debug warnings
require("gears.debug").print_warning = function() end require("gears.debug").print_warning = function() end
end end