Merge pull request #763 from psychon/luacov-shapes

Run shape-example-generation under LuaCov
This commit is contained in:
Emmanuel Lepage Vallée 2016-03-17 16:48:50 -04:00
commit 951e0309f5
4 changed files with 21 additions and 5 deletions

View File

@ -2,7 +2,8 @@
-- This variable is set externally -- This variable is set externally
local build = os.getenv("BUILD_DIRECTORY") or error("$BUILD_DIRECTORY not set") 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) local function escape_pattern(str)
return string.gsub(str, "%W", "%%%1") return string.gsub(str, "%W", "%%%1")
@ -17,12 +18,16 @@ return {
-- For things already having the correct path -- For things already having the correct path
-- (happens with integration tests) -- (happens with integration tests)
"^lib/", "^lib/",
-- For the shape-API auto-generated images
source and escape_pattern(source .. "lib/"),
}, },
-- configuration for luacov-coveralls reporter -- configuration for luacov-coveralls reporter
coveralls = { coveralls = {
pathcorrect = { pathcorrect = {
{ escape_pattern(lib_dir), "lib/"}, { 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. # 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 - if [ "$BUILD_APIDOC" = "true" ]; then build-utils/travis-apidoc.sh; fi
# Push code coverage information # 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") file(MAKE_DIRECTORY "${BUILD_DIR}/doc/images")
set(ENV{BUILD_DIRECTORY} "${BUILD_DIR}/")
set(ENV{AWESOME_LIB_DIR} "${SOURCE_DIR}/lib/")
# #
# Shape API # 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 # Generate some SVG for the documentation and load the examples for the doc
execute_process( execute_process(
COMMAND lua ${SOURCE_DIR}/tests/shape/test-shape.lua ${SHAPE_FILE} ${SHAPE_SVG} COMMAND lua ${SOURCE_DIR}/tests/shape/test-shape.lua ${SHAPE_FILE} ${SHAPE_SVG} ${SOURCE_DIR}/.luacov
OUTPUT_VARIABLE SHAPE_OUTPUT
ERROR_VARIABLE SHAPE_ERROR ERROR_VARIABLE SHAPE_ERROR
) )
@ -45,3 +47,5 @@ foreach (SHAPE_NAME "circle" "arrow" "rounded_rect" "hexagon" "infobubble"
set(SHAPE_${SHAPE_NAME}_EXAMPLE ${SHAPE_COMMENTED}) set(SHAPE_${SHAPE_NAME}_EXAMPLE ${SHAPE_COMMENTED})
endforeach() 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 -- it also "prove" that the code examples are all working
local cairo = require( "lgi" ).cairo local cairo = require( "lgi" ).cairo
local shape = require( "gears.shape" ) 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 function get_surface(p)
local img = cairo.SvgSurface.create(p, 288, 76) local img = cairo.SvgSurface.create(p, 288, 76)
@ -29,3 +34,5 @@ local cr = get_surface(svgpath)
cr:translate(3,3) cr:translate(3,3)
loadfile(filepath)(shape, cr, show) loadfile(filepath)(shape, cr, show)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80