Run shape-example-generation under LuaCov

This is ugly, but at least it works. Hopefully...

Signed-off-by: Uli Schlachter <uli.schlachter@informatik.uni-oldenburg.de>
This commit is contained in:
Uli Schlachter 2016-03-17 09:40:16 +01:00
parent 1fff8cc24c
commit 02cdb5103b
4 changed files with 21 additions and 5 deletions

View File

@ -2,7 +2,8 @@
-- This variable is set externally
local build = os.getenv("BUILD_DIRECTORY") or error("$BUILD_DIRECTORY not set")
local lib_dir = build .. "lib/"
local lib_dir = os.getenv("AWESOME_LIB_DIR") or build .. "lib/"
local source = os.getenv("SOURCE_DIRECTORY")
local function escape_pattern(str)
return string.gsub(str, "%W", "%%%1")
@ -17,12 +18,16 @@ return {
-- For things already having the correct path
-- (happens with integration tests)
"^lib/",
-- For the shape-API auto-generated images
source and escape_pattern(source .. "lib/"),
},
-- configuration for luacov-coveralls reporter
coveralls = {
pathcorrect = {
{ escape_pattern(lib_dir), "lib/"},
source and { escape_pattern(source .. "lib/"), "lib/" },
},
},
}

View File

@ -96,4 +96,4 @@ after_success:
# Push updated API docs for relevant branches, e.g. non-PRs builds on master.
- if [ "$BUILD_APIDOC" = "true" ]; then build-utils/travis-apidoc.sh; fi
# Push code coverage information
- if [ "$DO_COVERAGE" = "true" ]; then BUILD_DIRECTORY="$(pwd)/$(readlink build)/" luacov-coveralls --verbose --merge; fi
- if [ "$DO_COVERAGE" = "true" ]; then BUILD_DIRECTORY="$(pwd)/$(readlink build)/" SOURCE_DIRECTORY="$(pwd)/" luacov-coveralls --verbose --merge; fi

View File

@ -5,6 +5,9 @@ set(ENV{LUA_PATH} "${SOURCE_DIR}/lib/?;${SOURCE_DIR}/lib/?.lua;${LUA_PATH_}")
file(MAKE_DIRECTORY "${BUILD_DIR}/doc/images")
set(ENV{BUILD_DIRECTORY} "${BUILD_DIR}/")
set(ENV{AWESOME_LIB_DIR} "${SOURCE_DIR}/lib/")
#
# Shape API
#
@ -17,8 +20,7 @@ foreach (SHAPE_NAME "circle" "arrow" "rounded_rect" "hexagon" "infobubble"
# Generate some SVG for the documentation and load the examples for the doc
execute_process(
COMMAND lua ${SOURCE_DIR}/tests/shape/test-shape.lua ${SHAPE_FILE} ${SHAPE_SVG}
OUTPUT_VARIABLE SHAPE_OUTPUT
COMMAND lua ${SOURCE_DIR}/tests/shape/test-shape.lua ${SHAPE_FILE} ${SHAPE_SVG} ${SOURCE_DIR}/.luacov
ERROR_VARIABLE SHAPE_ERROR
)
@ -45,3 +47,5 @@ foreach (SHAPE_NAME "circle" "arrow" "rounded_rect" "hexagon" "infobubble"
set(SHAPE_${SHAPE_NAME}_EXAMPLE ${SHAPE_COMMENTED})
endforeach()
# vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker

View File

@ -3,7 +3,12 @@
-- it also "prove" that the code examples are all working
local cairo = require( "lgi" ).cairo
local shape = require( "gears.shape" )
local filepath, svgpath = ...
local filepath, svgpath, luacovpath = ...
-- If luacov is available, use it. Else, do nothing.
pcall(function()
require("luacov.runner")(luacovpath)
end)
local function get_surface(p)
local img = cairo.SvgSurface.create(p, 288, 76)
@ -29,3 +34,5 @@ local cr = get_surface(svgpath)
cr:translate(3,3)
loadfile(filepath)(shape, cr, show)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80