Merge pull request #1239 from Elv13/drill_speed_holes

Improve the CI accuracy and maybe its speed
This commit is contained in:
Daniel Hahler 2017-01-08 22:13:44 +01:00 committed by GitHub
commit 902a5c5e78
10 changed files with 219 additions and 162 deletions

21
.luacov
View File

@ -1,33 +1,26 @@
-- Configuration file for LuaCov -- Configuration file for LuaCov
-- This variable is set externally -- This variable is set externally
local build = os.getenv("BUILD_DIRECTORY") or error("$BUILD_DIRECTORY not set") local source = os.getenv("SOURCE_DIRECTORY") or os.getenv('PWD')
local lib_dir = os.getenv("AWESOME_LIB_DIR") or build .. "lib/" local build = os.getenv("BUILD_DIRECTORY") or (source .. "/build")
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")
end end
return { return {
statsfile = build .. "luacov.stats.out", statsfile = build .. "/luacov.stats.out",
include = { include = {
escape_pattern(lib_dir) .. ".+", escape_pattern(source) .. "/.+",
-- Relative paths (to source/build dir).
-- 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 -- configuration for luacov-coveralls reporter
coveralls = { coveralls = {
pathcorrect = { pathcorrect = {
{ escape_pattern(lib_dir), "lib/"}, { escape_pattern(source .. '/'), ''},
source and { escape_pattern(source .. "lib/"), "lib/" },
}, },
}, },
} }

View File

@ -10,13 +10,13 @@ branches:
env: env:
matrix: matrix:
- LUA=5.2 DO_CHECKQA=1 LUANAME=lua5.2 BUILD_APIDOC=true DO_COVERAGE=coveralls - LUA=5.2 DO_CHECKQA=1 LUANAME=lua5.2 DO_COVERAGE=coveralls
# luajit: installed from source. # luajit: installed from source.
- LUA=5.1 LUANAME=luajit-2.0 LUALIBRARY=/usr/lib/libluajit-5.1.so LUAROCKS_ARGS=--lua-suffix=jit-2.0.4 TEST_PREV_COMMITS=1 - LUA=5.1 LUANAME=luajit-2.0 LUALIBRARY=/usr/lib/libluajit-5.1.so LUAROCKS_ARGS=--lua-suffix=jit-2.0.4 TEST_PREV_COMMITS=1
# Note: luarocks does not work with Lua 5.0. # Note: luarocks does not work with Lua 5.0.
- LUA=5.1 LUANAME=lua5.1 BUILD_IN_DIR=/tmp/awesome-build - LUA=5.1 LUANAME=lua5.1 BUILD_IN_DIR=/tmp/awesome-build
# Lua 5.2 with older lgi and screen size not divisible by 2. # Lua 5.2 with older lgi and screen size not divisible by 2.
- LUA=5.2 LUANAME=lua5.2 LGIVER=0.8.0 TESTS_SCREEN_SIZE=1921x1079 - LUA=5.2 LUANAME=lua5.2 LGIVER=0.8.0 TESTS_SCREEN_SIZE=1921x1079 BUILD_APIDOC=true
# Lua 5.3 isn't available in Ubuntu Trusty, so some magic below installs it. # Lua 5.3 isn't available in Ubuntu Trusty, so some magic below installs it.
- LUA=5.3 LUANAME=lua5.3 LUALIBRARY=/usr/lib/liblua.so DO_COVERAGE=codecov - LUA=5.3 LUANAME=lua5.3 LUALIBRARY=/usr/lib/liblua.so DO_COVERAGE=codecov
global: global:
@ -24,6 +24,7 @@ env:
- secure: "R/HYDclnws1I1+v9Yjt+RKa4CsFhbBT9tiwE3EfPhEj2KCYX4sFRMxuZvLf5sq0XWdrQaPhQ54fgAZGr3f054JKRXcTB0g9J6nhSHz9kIjPh446gafUhEeDQcZRwM/MeCWiwFIkiZm6smYoDFE9JTWu6quNV+lQ4kcVDOp2ibEc=" - secure: "R/HYDclnws1I1+v9Yjt+RKa4CsFhbBT9tiwE3EfPhEj2KCYX4sFRMxuZvLf5sq0XWdrQaPhQ54fgAZGr3f054JKRXcTB0g9J6nhSHz9kIjPh446gafUhEeDQcZRwM/MeCWiwFIkiZm6smYoDFE9JTWu6quNV+lQ4kcVDOp2ibEc="
before_install: before_install:
- if [ "$BUILD_APIDOC" = true ] && [ -n "$DO_COVERAGE" ]; then echo "BUILD_APIDOC and DO_COVERAGE are not meant to be used together." >&2; exit 1; fi
- if [ -z $LUAINCLUDE ]; then LUAINCLUDE=/usr/include/${LUANAME}; fi - if [ -z $LUAINCLUDE ]; then LUAINCLUDE=/usr/include/${LUANAME}; fi
- if [ -z $LUALIBRARY ]; then LUALIBRARY=/usr/lib/x86_64-linux-gnu/lib${LUANAME}.so; fi - if [ -z $LUALIBRARY ]; then LUALIBRARY=/usr/lib/x86_64-linux-gnu/lib${LUANAME}.so; fi
- cmake --version - cmake --version
@ -49,7 +50,7 @@ install:
# Install Lua (per env). # Install Lua (per env).
# Note that Lua 5.3 is installed manually, because it is not available in Ubuntu Trusty. # Note that Lua 5.3 is installed manually, because it is not available in Ubuntu Trusty.
- | - |
set -ev set -e
if [[ "$LUA" == "5.3" ]]; then if [[ "$LUA" == "5.3" ]]; then
wget http://www.lua.org/ftp/lua-5.3.3.tar.gz -O lua.tar.gz wget http://www.lua.org/ftp/lua-5.3.3.tar.gz -O lua.tar.gz
tar -xvzf lua.tar.gz tar -xvzf lua.tar.gz
@ -89,23 +90,28 @@ install:
- if [ "$DO_CHECKQA" = 1 ]; then travis_retry sudo luarocks install luacheck; fi - if [ "$DO_CHECKQA" = 1 ]; then travis_retry sudo luarocks install luacheck; fi
# Install ldoc for building docs. # Install ldoc for building docs.
- travis_retry sudo luarocks install ldoc - |
- travis_retry sudo luarocks install lua-discount if [ "$BUILD_APIDOC" = "true" ]; then
travis_retry sudo luarocks install ldoc
travis_retry sudo luarocks install lua-discount
fi
# Install dependencies for code coverage testing. # Install dependencies for code coverage testing.
- if [ "$DO_COVERAGE" = "" ]; then export DO_COVERAGE=0; fi - if [ "$DO_COVERAGE" = "" ]; then export DO_COVERAGE=0; fi
- if [ "$DO_COVERAGE" != "0" ]; then sudo luarocks install luacov 0.11.0-1; fi - if [ "$DO_COVERAGE" != "0" ]; then sudo luarocks install luacov 0.12.0-1; fi
- if [ "$DO_COVERAGE" = "coveralls" ]; then sudo luarocks install luacov-coveralls; fi - if [ "$DO_COVERAGE" = "coveralls" ]; then sudo luarocks install luacov-coveralls; fi
# Determine custom version. # Determine custom version.
- export AWESOME_VERSION="${TRAVIS_BRANCH}-g$(git rev-parse --short HEAD)" - export AWESOME_VERSION="${TRAVIS_BRANCH}-g$(git rev-parse --short HEAD)"
- 'if [ "$TRAVIS_PULL_REQUEST" != false ]; then AWESOME_VERSION="${AWESOME_VERSION}-PR${TRAVIS_PULL_REQUEST}"; fi' - 'if [ "$TRAVIS_PULL_REQUEST" != false ]; then AWESOME_VERSION="${AWESOME_VERSION}-PR${TRAVIS_PULL_REQUEST}"; fi'
# function for codecov support # function for codecov support
- travis_retry wget -O /tmp/codecov-bash https://codecov.io/bash - if [ "$DO_COVERAGE" = "codecov" ]; then travis_retry wget -O /tmp/codecov-bash https://codecov.io/bash; fi
- | - |
do_codecov() { do_codecov() {
echo "== do_codecov in $PWD: $*: build/luacov.stats.out: =="
if [ "$DO_COVERAGE" = "codecov" ]; then if [ "$DO_COVERAGE" = "codecov" ]; then
(cd build && luacov) || return 1 test -f build/luacov.stats.out || { echo 'build/luacov.stats.out does not exist.'; return 1; }
luacov || return 1
travis_retry bash /tmp/codecov-bash -X coveragepy -c -F "$1" || return 1 travis_retry bash /tmp/codecov-bash -X coveragepy -c -F "$1" || return 1
rm build/luacov.stats.out rm build/luacov.stats.out
fi fi
@ -130,9 +136,9 @@ install:
return $result return $result
} }
script: script:
- export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION -D DO_COVERAGE=${DO_COVERAGE} -DSTRICT_TESTS=true" - export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION -DSTRICT_TESTS=true"
- | - |
set -ev set -e
if [ -n "$BUILD_IN_DIR" ]; then if [ -n "$BUILD_IN_DIR" ]; then
# Explicitly remove the Makefile to not build from the src dir accidentally. # Explicitly remove the Makefile to not build from the src dir accidentally.
rm Makefile rm Makefile
@ -147,20 +153,22 @@ script:
travis_run_in_fold "make.install" sudo env PATH=$PATH make install travis_run_in_fold "make.install" sudo env PATH=$PATH make install
awesome --version awesome --version
fi fi
- |
if [ "$TRAVIS_TEST_RESULT" = 0 ]; then
do_codecov samples
fi
# Run check-unit{,-coverage} and check-integration. # Run check-unit{,-coverage} and check-integration.
- | - |
set -ev set -ex
if [ "$TRAVIS_TEST_RESULT" = 0 ]; then if [ "$TRAVIS_TEST_RESULT" = 0 ]; then
if [ "$DO_COVERAGE" != "0" ]; then if [ "$DO_COVERAGE" != "0" ]; then
travis_fold_start "DO_COVERAGE" travis_fold_start "DO_COVERAGE"
# Run tests/examples explicitly.
(mkdir -p tests/examples/build \
&& cd tests/examples/build \
&& cmake $CMAKE_ARGS ..)
do_codecov samples
(make check-unit-coverage \ (make check-unit-coverage \
&& do_codecov unittests \ && do_codecov unittests \
&& sed -i "1 i\\require('luacov.runner')('"$PWD"/.luacov')" build/awesomerc.lua \ && tests/run.sh \
&& BUILD_DIRECTORY="" tests/run.sh \
&& do_codecov functionaltests) && do_codecov functionaltests)
ret=$? ret=$?
travis_fold_end travis_fold_end
@ -176,7 +184,7 @@ script:
travis_run_in_fold "make.check-qa" make check-qa travis_run_in_fold "make.check-qa" make check-qa
fi fi
- | - |
set -ev set -e
if [ "$TEST_PREV_COMMITS" = 1 ] && ! [ "$TRAVIS_PULL_REQUEST" = false ]; then if [ "$TEST_PREV_COMMITS" = 1 ] && ! [ "$TRAVIS_PULL_REQUEST" = false ]; then
# Check each commit separately (to make git-bisect less annoying). # Check each commit separately (to make git-bisect less annoying).
# Fix Travis' commit range (https://github.com/travis-ci/travis-ci/issues/4596). # Fix Travis' commit range (https://github.com/travis-ci/travis-ci/issues/4596).
@ -195,13 +203,18 @@ script:
echo "Testing commit $commit" echo "Testing commit $commit"
git checkout "$commit" git checkout "$commit"
git --no-pager show --stat git --no-pager show --stat
if ! make all check; then if ! DO_COVERAGE=0 make all check; then
failed="$failed $commit" failed="$failed $commit"
fi fi
travis_fold_end travis_fold_end
done done
git checkout -qf FETCH_HEAD
if [ -n "$failed" ]; then if [ -n "$failed" ]; then
echo "Checks failed for these commits:$failed" echo "Checks failed for these commits:"
for c in $commits; do
git log -1 --pretty="%h %s (%an, %ad)" "$c"
done
false false
fi fi
fi fi
@ -210,4 +223,9 @@ 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" = "coveralls" ]; then BUILD_DIRECTORY="$(pwd)/$(readlink build)/" SOURCE_DIRECTORY="$(pwd)/" luacov-coveralls --verbose --merge; fi - |
set -e
if [ "$DO_COVERAGE" = "coveralls" ]; then
test -f build/luacov.stats.out || { echo 'build/luacov.stats.out does not exist.'; return 1; }
luacov-coveralls --verbose --merge
fi

View File

@ -389,7 +389,7 @@ if(BUSTED_EXECUTABLE)
# Keep the arguments in sync with the version below! # Keep the arguments in sync with the version below!
add_custom_target(check-unit ALL add_custom_target(check-unit ALL
${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua" ${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua"
"--lpath=${CMAKE_BINARY_DIR}/lib/?.lua;${CMAKE_BINARY_DIR}/lib/?/init.lua;spec/?.lua" "--lpath=lib/?.lua;lib/?/init.lua;spec/?.lua"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running unit tests" COMMENT "Running unit tests"
VERBATIM) VERBATIM)
@ -397,9 +397,8 @@ if(BUSTED_EXECUTABLE)
# Same as above, but with --coverage argument # Same as above, but with --coverage argument
add_custom_target(check-unit-coverage add_custom_target(check-unit-coverage
"BUILD_DIRECTORY=${CMAKE_BINARY_DIR}/"
${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua" ${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua"
"--lpath=${CMAKE_BINARY_DIR}/lib/?.lua;${CMAKE_BINARY_DIR}/lib/?/init.lua;spec/?.lua" "--lpath=lib/?.lua;lib/?/init.lua;spec/?.lua"
"--coverage" "--coverage"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running unit tests under LuaCov" COMMENT "Running unit tests under LuaCov"

View File

@ -12,6 +12,9 @@ option(WITH_DBUS "build with D-BUS" ON)
option(GENERATE_MANPAGES "generate manpages" ON) option(GENERATE_MANPAGES "generate manpages" ON)
option(COMPRESS_MANPAGES "compress manpages" ON) option(COMPRESS_MANPAGES "compress manpages" ON)
option(GENERATE_DOC "generate API documentation" ON) option(GENERATE_DOC "generate API documentation" ON)
if (GENERATE_DOC AND ENV{DO_COVERAGE})
message(STATUS "Not generating API documentation with DO_COVERAGE")
endif()
# {{{ Endianness # {{{ Endianness
include(TestBigEndian) include(TestBigEndian)
@ -37,18 +40,26 @@ a_find_program(GIT_EXECUTABLE git FALSE)
a_find_program(ASCIIDOC_EXECUTABLE asciidoc FALSE) a_find_program(ASCIIDOC_EXECUTABLE asciidoc FALSE)
a_find_program(XMLTO_EXECUTABLE xmlto FALSE) a_find_program(XMLTO_EXECUTABLE xmlto FALSE)
a_find_program(GZIP_EXECUTABLE gzip FALSE) a_find_program(GZIP_EXECUTABLE gzip FALSE)
# lua documentation # Lua documentation
a_find_program(LDOC_EXECUTABLE ldoc FALSE) if(GENERATE_DOC)
if(NOT LDOC_EXECUTABLE) a_find_program(LDOC_EXECUTABLE ldoc FALSE)
a_find_program(LDOC_EXECUTABLE ldoc.lua FALSE) if(NOT LDOC_EXECUTABLE)
endif() a_find_program(LDOC_EXECUTABLE ldoc.lua FALSE)
if(LDOC_EXECUTABLE)
execute_process(COMMAND sh -c "${LDOC_EXECUTABLE} --sadly-ldoc-has-no-version-option 2>&1 | grep ' vs 1.4.5'"
OUTPUT_VARIABLE LDOC_VERSION_RESULT)
if(NOT LDOC_VERSION_RESULT STREQUAL "")
message(WARNING "Ignoring LDoc, because version 1.4.5 is known to be broken")
unset(LDOC_EXECUTABLE CACHE)
endif() endif()
if(LDOC_EXECUTABLE)
execute_process(COMMAND sh -c "${LDOC_EXECUTABLE} --sadly-ldoc-has-no-version-option 2>&1 | grep ' vs 1.4.5'"
OUTPUT_VARIABLE LDOC_VERSION_RESULT)
if(NOT LDOC_VERSION_RESULT STREQUAL "")
message(WARNING "Ignoring LDoc, because version 1.4.5 is known to be broken")
unset(LDOC_EXECUTABLE CACHE)
endif()
endif()
if(NOT LDOC_EXECUTABLE)
message(STATUS "Not generating API documentation. Missing: ldoc.")
set(GENERATE_DOC OFF)
endif()
else()
message(STATUS "Not generating API documentation.")
endif() endif()
# theme graphics # theme graphics
a_find_program(CONVERT_EXECUTABLE convert TRUE) a_find_program(CONVERT_EXECUTABLE convert TRUE)
@ -75,13 +86,6 @@ if(GENERATE_MANPAGES)
set(GENERATE_MANPAGES OFF) set(GENERATE_MANPAGES OFF)
endif() endif()
endif() endif()
if(GENERATE_DOC)
if(NOT LDOC_EXECUTABLE)
message(STATUS "Not generating API documentation. Missing: ldoc")
set(GENERATE_DOC OFF)
endif()
endif()
# }}} # }}}
# {{{ Version stamp # {{{ Version stamp
@ -318,7 +322,6 @@ set(AWESOME_ICON_PATH ${AWESOME_DATA_PATH}/icons)
set(AWESOME_THEMES_PATH ${AWESOME_DATA_PATH}/themes) set(AWESOME_THEMES_PATH ${AWESOME_DATA_PATH}/themes)
# }}} # }}}
if(GENERATE_DOC) if(GENERATE_DOC)
# Load the common documentation # Load the common documentation
include(docs/load_ldoc.cmake) include(docs/load_ldoc.cmake)
@ -333,19 +336,25 @@ if(GENERATE_DOC)
endif() endif()
# {{{ Configure files # {{{ Configure files
file(GLOB awesome_c_configure_files RELATIVE ${SOURCE_DIR} file(GLOB awesome_base_c_configure_files RELATIVE ${SOURCE_DIR}
${SOURCE_DIR}/*.c ${SOURCE_DIR}/*.c
${SOURCE_DIR}/*.h ${SOURCE_DIR}/*.h)
file(GLOB awesome_c_configure_files RELATIVE ${SOURCE_DIR}
${SOURCE_DIR}/common/*.c ${SOURCE_DIR}/common/*.c
${SOURCE_DIR}/common/*.h ${SOURCE_DIR}/common/*.h
${SOURCE_DIR}/objects/*.c ${SOURCE_DIR}/objects/*.c
${SOURCE_DIR}/objects/*.h) ${SOURCE_DIR}/objects/*.h)
file(GLOB_RECURSE awesome_lua_configure_files RELATIVE ${SOURCE_DIR} file(GLOB_RECURSE awesome_lua_configure_files RELATIVE ${SOURCE_DIR}
${SOURCE_DIR}/lib/*.lua ${SOURCE_DIR}/lib/*.lua)
file(GLOB_RECURSE awesome_theme_configure_files RELATIVE ${SOURCE_DIR}
${SOURCE_DIR}/themes/*/*.lua) ${SOURCE_DIR}/themes/*/*.lua)
set(AWESOME_CONFIGURE_FILES set(AWESOME_CONFIGURE_FILES
${awesome_c_configure_files} ${awesome_base_c_configure_files}
${awesome_lua_configure_files} ${awesome_theme_configure_files}
config.h config.h
docs/config.ld docs/config.ld
awesome-version-internal.h) awesome-version-internal.h)
@ -356,6 +365,33 @@ foreach(file ${AWESOME_CONFIGURE_FILES})
ESCAPE_QUOTES ESCAPE_QUOTES
@ONLY) @ONLY)
endforeach() endforeach()
set(AWESOME_CONFIGURE_COPYONLY_WITHCOV_FILES
${awesome_c_configure_files}
${awesome_lua_configure_files}
)
if(DO_COVERAGE)
foreach(file ${AWESOME_CONFIGURE_COPYONLY_WITHCOV_FILES})
configure_file(${SOURCE_DIR}/${file}
${BUILD_DIR}/${file}
COPYONLY)
endforeach()
# There is no way to avoid that one
configure_file(${SOURCE_DIR}/lib/awful/util.lua
${BUILD_DIR}/lib/awful/util.lua
ESCAPE_QUOTES
@ONLY)
else()
foreach(file ${AWESOME_CONFIGURE_COPYONLY_WITHCOV_FILES})
configure_file(${SOURCE_DIR}/${file}
${BUILD_DIR}/${file}
ESCAPE_QUOTES
@ONLY)
endforeach()
endif()
#}}} #}}}
# {{{ Generate some aggregated documentation from lua script # {{{ Generate some aggregated documentation from lua script
@ -391,14 +427,4 @@ foreach(file ${AWESOME_ADDITIONAL_FILES})
endforeach() endforeach()
#}}} #}}}
# The examples coverage need to be done again after the configure_file has
# inserted the additional code. Otherwise, the result will be off, rendering
# the coverage useless as a tool to track untested code.
if(GENERATE_DOC AND DO_COVERAGE)
message(STATUS "Running tests again with coverage")
set(USE_LCOV 1)
include(tests/examples/CMakeLists.txt)
endif()
# vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker

View File

@ -200,13 +200,13 @@ end
--- Get the path to the directory where themes are installed. --- Get the path to the directory where themes are installed.
-- @return A string with the requested path with a slash at the end. -- @return A string with the requested path with a slash at the end.
function util.get_themes_dir() function util.get_themes_dir()
return "@AWESOME_THEMES_PATH@" .. "/" return (os.getenv('AWESOME_THEMES_PATH') or "@AWESOME_THEMES_PATH@") .. "/"
end end
--- Get the path to the directory where our icons are installed. --- Get the path to the directory where our icons are installed.
-- @return A string with the requested path with a slash at the end. -- @return A string with the requested path with a slash at the end.
function util.get_awesome_icon_dir() function util.get_awesome_icon_dir()
return "@AWESOME_ICON_PATH@" .. "/" return (os.getenv('AWESOME_ICON_PATH') or "@AWESOME_ICON_PATH@") .. "/"
end end
--- Get the user's config or cache dir. --- Get the user's config or cache dir.

View File

@ -8,8 +8,8 @@ local string = string
local icon_theme = require("menubar.icon_theme") local icon_theme = require("menubar.icon_theme")
local base_directories = { local base_directories = {
os.getenv("PWD") .. "/spec/menubar/icons", (os.getenv("SOURCE_DIRECTORY") or '.') .. "/spec/menubar/icons",
os.getenv("PWD") .. "/icons" (os.getenv("SOURCE_DIRECTORY") or '.') .. "/icons"
} }
describe("menubar.icon_theme find_icon_path", function() describe("menubar.icon_theme find_icon_path", function()

View File

@ -14,20 +14,45 @@ cmake_minimum_required(VERSION 3.0.0)
# Get and update the LUA_PATH so the scripts can be executed without Awesome. # Get and update the LUA_PATH so the scripts can be executed without Awesome.
execute_process(COMMAND lua -e print\(package.path\) OUTPUT_VARIABLE "LUA_PATH_") execute_process(COMMAND lua -e print\(package.path\) OUTPUT_VARIABLE "LUA_PATH_")
# Make sure the system can be called from the test directory
if(NOT SOURCE_DIR AND ${CMAKE_CURRENT_SOURCE_DIR} MATCHES "/tests/examples")
get_filename_component(TOP_SOURCE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE)
# Used by .luacov.
set(ENV{SOURCE_DIRECTORY} ${TOP_SOURCE_DIR})
else()
set(TOP_SOURCE_DIR ${CMAKE_SOURCE_DIR})
endif()
if (DEFINED ENV{DO_COVERAGE} AND NOT $ENV{DO_COVERAGE} STREQUAL "0")
execute_process(
COMMAND lua -e "require('luacov.runner')('${TOP_SOURCE_DIR}/.luacov')"
RESULT_VARIABLE TEST_RESULT
ERROR_VARIABLE TEST_ERROR
ERROR_STRIP_TRAILING_WHITESPACE)
if (TEST_RESULT OR NOT TEST_ERROR STREQUAL "")
message(${TEST_ERROR})
message(FATAL_ERROR "Failed to run luacov.runner.")
endif()
set(LUA_COV_RUNNER lua "-erequire('luacov.runner')('${TOP_SOURCE_DIR}/.luacov')")
else()
set(LUA_COV_RUNNER lua)
endif()
# Add the main awesome lua libraries. # Add the main awesome lua libraries.
set(LUA_PATH2_ "\ set(LUA_PATH2_ "\
${CMAKE_SOURCE_DIR}/lib/?.lua;\ ${TOP_SOURCE_DIR}/lib/?.lua;\
${CMAKE_SOURCE_DIR}/lib/?/init.lua;\ ${TOP_SOURCE_DIR}/lib/?/init.lua;\
${CMAKE_SOURCE_DIR}/lib/?;\ ${TOP_SOURCE_DIR}/lib/?;\
${CMAKE_SOURCE_DIR}/themes/?.lua;\ ${TOP_SOURCE_DIR}/themes/?.lua;\
${CMAKE_SOURCE_DIR}/themes/?;" ${TOP_SOURCE_DIR}/themes/?;"
) )
# Add the C API shims. # Add the C API shims.
set(LUA_PATH3_ "\ set(LUA_PATH3_ "\
${CMAKE_SOURCE_DIR}/tests/examples/shims/?.lua;\ ${TOP_SOURCE_DIR}/tests/examples/shims/?.lua;\
${CMAKE_SOURCE_DIR}/tests/examples/shims/?/init.lua;\ ${TOP_SOURCE_DIR}/tests/examples/shims/?/init.lua;\
${CMAKE_SOURCE_DIR}/tests/examples/shims/?;" ${TOP_SOURCE_DIR}/tests/examples/shims/?;"
) )
# Done in 3 variables to avoid CMake from implicitly converting into a list. # Done in 3 variables to avoid CMake from implicitly converting into a list.
@ -133,7 +158,7 @@ endfunction()
# Get the namespace of a file. # Get the namespace of a file.
function(get_namespace result_variable file) function(get_namespace result_variable file)
get_filename_component(path "${file}" DIRECTORY) get_filename_component(path "${file}" DIRECTORY)
string(LENGTH "${SOURCE_DIR}/tests/examples" prefix_length) string(LENGTH "${TOP_SOURCE_DIR}/tests/examples" prefix_length)
string(REPLACE "/" "_" namespace "${path}") string(REPLACE "/" "_" namespace "${path}")
string(SUBSTRING "${namespace}" "${prefix_length}" -1 namespace) string(SUBSTRING "${namespace}" "${prefix_length}" -1 namespace)
@ -148,24 +173,23 @@ function(run_test test_path namespace escaped_content)
get_filename_component(${test_path} TEST_FILE_NAME NAME) get_filename_component(${test_path} TEST_FILE_NAME NAME)
set(IMAGE_PATH "${IMAGE_DIR}/AUTOGEN${namespace}_${TEST_FILE_NAME}") set(IMAGE_PATH "${IMAGE_DIR}/AUTOGEN${namespace}_${TEST_FILE_NAME}")
# Use the example testing as coverage source.
if (USE_LCOV)
set(LCOV_PATH ${SOURCE_DIR}/.luacov)
endif()
# Execute the script, leave the image extension decision to the test. # Execute the script, leave the image extension decision to the test.
# 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} ${LCOV_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()
@ -231,12 +255,12 @@ endfunction()
# Find and run all test files. # Find and run all test files.
file(GLOB_RECURSE test_files LIST_DIRECTORIES false file(GLOB_RECURSE test_files LIST_DIRECTORIES false
"${SOURCE_DIR}/tests/examples/*.lua") "${TOP_SOURCE_DIR}/tests/examples/*.lua")
foreach(file ${test_files}) foreach(file ${test_files})
if ((NOT "${file}" MATCHES ".*/shims/.*") if ((NOT "${file}" MATCHES ".*/shims/.*")
AND (NOT "${file}" MATCHES ".*/template.lua")) AND (NOT "${file}" MATCHES ".*/template.lua"))
file(RELATIVE_PATH relative_file "${SOURCE_DIR}" "${file}") file(RELATIVE_PATH relative_file "${TOP_SOURCE_DIR}" "${file}")
message(STATUS "Running ${relative_file}...") message(STATUS "Running ${relative_file}...")
# Get the file name without the extension. # Get the file name without the extension.

View File

@ -1,4 +1,4 @@
return function(_, _, luacovpath) return function(_, _)
-- Set the global shims -- Set the global shims
-- luacheck: globals awesome root tag screen client mouse drawin button -- luacheck: globals awesome root tag screen client mouse drawin button
@ -14,11 +14,6 @@ return function(_, _, luacovpath)
-- 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.
pcall(function()
require("luacov.runner")(luacovpath)
end)
-- Silence debug warnings -- Silence debug warnings
require("gears.debug").print_warning = function() end require("gears.debug").print_warning = function() end
end end

View File

@ -22,8 +22,8 @@ fi
# Change to file's dir (POSIXly). # Change to file's dir (POSIXly).
cd -P -- "$(dirname -- "$0")" cd -P -- "$(dirname -- "$0")"
this_dir=$PWD this_dir="$PWD"
source_dir="$PWD/.." source_dir="${this_dir%/*}"
# Either the build dir is passed in $CMAKE_BINARY_DIR or we guess based on $PWD # Either the build dir is passed in $CMAKE_BINARY_DIR or we guess based on $PWD
build_dir="$CMAKE_BINARY_DIR" build_dir="$CMAKE_BINARY_DIR"
@ -59,7 +59,6 @@ if ! [ -x "$AWESOME" ]; then
echo "$AWESOME is not executable." >&2 echo "$AWESOME is not executable." >&2
exit 1 exit 1
fi fi
RC_FILE=$build_dir/awesomerc.lua
AWESOME_CLIENT="$source_dir/utils/awesome-client" AWESOME_CLIENT="$source_dir/utils/awesome-client"
D=:5 D=:5
SIZE="${TESTS_SCREEN_SIZE:-1024x768}" SIZE="${TESTS_SCREEN_SIZE:-1024x768}"
@ -90,6 +89,9 @@ cleanup() {
for p in $awesome_pid $xserver_pid; do for p in $awesome_pid $xserver_pid; do
kill -TERM "$p" 2>/dev/null || true kill -TERM "$p" 2>/dev/null || true
done done
if [ -n "$DO_COVERAGE" ] && [ "$DO_COVERAGE" != 0 ]; then
mv "$RC_FILE.coverage.bak" "$RC_FILE"
fi
rm -rf "$tmp_files" || true rm -rf "$tmp_files" || true
} }
trap "cleanup" 0 2 3 15 trap "cleanup" 0 2 3 15
@ -160,26 +162,22 @@ wait_until_success "setup xrdb" "printf 'Xft.dpi: 96
# Use a separate D-Bus session; sets $DBUS_SESSION_BUS_PID. # Use a separate D-Bus session; sets $DBUS_SESSION_BUS_PID.
eval "$(DISPLAY="$D" dbus-launch --sh-syntax --exit-with-session)" eval "$(DISPLAY="$D" dbus-launch --sh-syntax --exit-with-session)"
# Not in Travis? RC_FILE=${source_dir}/awesomerc.lua
if [ "$CI" != true ]; then export AWESOME_THEMES_PATH="$source_dir/themes"
# Prepare a config file pointing to a working theme export AWESOME_ICON_PATH="$source_dir/icons"
# Handle old filename of config files (useful for git-bisect).
if [ -f "$source_dir/awesomerc.lua.in" ]; then # Inject coverage runner to RC file, which will be restored on exit/cleanup.
SED_IN=.in if [ -n "$DO_COVERAGE" ] && [ "$DO_COVERAGE" != 0 ]; then
fi cp -a "$RC_FILE" "$RC_FILE.coverage.bak"
RC_FILE=$tmp_files/awesomerc.lua sed -i "1 s~^~require('luacov.runner')('$source_dir/.luacov'); \0~" "$RC_FILE"
THEME_FILE=$tmp_files/theme.lua
sed -e "s:.*beautiful.init(.*default/theme.lua.*:beautiful.init('$THEME_FILE'):" "$source_dir/awesomerc.lua$SED_IN" > "$RC_FILE"
sed -e "s:@AWESOME_THEMES_PATH@/default/titlebar:$build_dir/themes/default/titlebar:" \
-e "s:@AWESOME_THEMES_PATH@:$source_dir/themes/:" \
-e "s:@AWESOME_ICON_PATH@:$source_dir/icons:" "$source_dir/themes/default/theme.lua$SED_IN" > "$THEME_FILE"
fi fi
# Start awesome. # Start awesome.
start_awesome() { start_awesome() {
cd "$build_dir" cd "$build_dir"
# Kill awesome after $timeout_stale seconds (e.g. for errors during test setup). # Kill awesome after $timeout_stale seconds (e.g. for errors during test setup).
DISPLAY="$D" timeout "$timeout_stale" "$AWESOME" -c "$RC_FILE" "${awesome_options[@]}" > "$awesome_log" 2>&1 & # SOURCE_DIRECTORY is used by .luacov.
DISPLAY="$D" SOURCE_DIRECTORY="$source_dir" timeout "$timeout_stale" "$AWESOME" -c "$RC_FILE" "${awesome_options[@]}" > "$awesome_log" 2>&1 &
awesome_pid=$! awesome_pid=$!
cd - >/dev/null cd - >/dev/null

View File

@ -4,6 +4,10 @@
local theme = {} local theme = {}
local util = require('awful.util')
local themes_path = util.get_themes_dir()
local icon_path = util.get_awesome_icon_dir()
theme.font = "sans 8" theme.font = "sans 8"
theme.bg_normal = "#222222" theme.bg_normal = "#222222"
@ -35,13 +39,13 @@ theme.border_marked = "#91231c"
--theme.taglist_bg_focus = "#ff0000" --theme.taglist_bg_focus = "#ff0000"
-- Display the taglist squares -- Display the taglist squares
theme.taglist_squares_sel = "@AWESOME_THEMES_PATH@/default/taglist/squarefw.png" theme.taglist_squares_sel = themes_path.."default/taglist/squarefw.png"
theme.taglist_squares_unsel = "@AWESOME_THEMES_PATH@/default/taglist/squarew.png" theme.taglist_squares_unsel = themes_path.."default/taglist/squarew.png"
-- Variables set for theming the menu: -- Variables set for theming the menu:
-- menu_[bg|fg]_[normal|focus] -- menu_[bg|fg]_[normal|focus]
-- menu_[border_color|border_width] -- menu_[border_color|border_width]
theme.menu_submenu_icon = "@AWESOME_THEMES_PATH@/default/submenu.png" theme.menu_submenu_icon = themes_path.."default/submenu.png"
theme.menu_height = 15 theme.menu_height = 15
theme.menu_width = 100 theme.menu_width = 100
@ -51,53 +55,53 @@ theme.menu_width = 100
--theme.bg_widget = "#cc0000" --theme.bg_widget = "#cc0000"
-- Define the image to load -- Define the image to load
theme.titlebar_close_button_normal = "@AWESOME_THEMES_PATH@/default/titlebar/close_normal.png" theme.titlebar_close_button_normal = themes_path.."default/titlebar/close_normal.png"
theme.titlebar_close_button_focus = "@AWESOME_THEMES_PATH@/default/titlebar/close_focus.png" theme.titlebar_close_button_focus = themes_path.."default/titlebar/close_focus.png"
theme.titlebar_minimize_button_normal = "@AWESOME_THEMES_PATH@/default/titlebar/minimize_normal.png" theme.titlebar_minimize_button_normal = themes_path.."default/titlebar/minimize_normal.png"
theme.titlebar_minimize_button_focus = "@AWESOME_THEMES_PATH@/default/titlebar/minimize_focus.png" theme.titlebar_minimize_button_focus = themes_path.."default/titlebar/minimize_focus.png"
theme.titlebar_ontop_button_normal_inactive = "@AWESOME_THEMES_PATH@/default/titlebar/ontop_normal_inactive.png" theme.titlebar_ontop_button_normal_inactive = themes_path.."default/titlebar/ontop_normal_inactive.png"
theme.titlebar_ontop_button_focus_inactive = "@AWESOME_THEMES_PATH@/default/titlebar/ontop_focus_inactive.png" theme.titlebar_ontop_button_focus_inactive = themes_path.."default/titlebar/ontop_focus_inactive.png"
theme.titlebar_ontop_button_normal_active = "@AWESOME_THEMES_PATH@/default/titlebar/ontop_normal_active.png" theme.titlebar_ontop_button_normal_active = themes_path.."default/titlebar/ontop_normal_active.png"
theme.titlebar_ontop_button_focus_active = "@AWESOME_THEMES_PATH@/default/titlebar/ontop_focus_active.png" theme.titlebar_ontop_button_focus_active = themes_path.."default/titlebar/ontop_focus_active.png"
theme.titlebar_sticky_button_normal_inactive = "@AWESOME_THEMES_PATH@/default/titlebar/sticky_normal_inactive.png" theme.titlebar_sticky_button_normal_inactive = themes_path.."default/titlebar/sticky_normal_inactive.png"
theme.titlebar_sticky_button_focus_inactive = "@AWESOME_THEMES_PATH@/default/titlebar/sticky_focus_inactive.png" theme.titlebar_sticky_button_focus_inactive = themes_path.."default/titlebar/sticky_focus_inactive.png"
theme.titlebar_sticky_button_normal_active = "@AWESOME_THEMES_PATH@/default/titlebar/sticky_normal_active.png" theme.titlebar_sticky_button_normal_active = themes_path.."default/titlebar/sticky_normal_active.png"
theme.titlebar_sticky_button_focus_active = "@AWESOME_THEMES_PATH@/default/titlebar/sticky_focus_active.png" theme.titlebar_sticky_button_focus_active = themes_path.."default/titlebar/sticky_focus_active.png"
theme.titlebar_floating_button_normal_inactive = "@AWESOME_THEMES_PATH@/default/titlebar/floating_normal_inactive.png" theme.titlebar_floating_button_normal_inactive = themes_path.."default/titlebar/floating_normal_inactive.png"
theme.titlebar_floating_button_focus_inactive = "@AWESOME_THEMES_PATH@/default/titlebar/floating_focus_inactive.png" theme.titlebar_floating_button_focus_inactive = themes_path.."default/titlebar/floating_focus_inactive.png"
theme.titlebar_floating_button_normal_active = "@AWESOME_THEMES_PATH@/default/titlebar/floating_normal_active.png" theme.titlebar_floating_button_normal_active = themes_path.."default/titlebar/floating_normal_active.png"
theme.titlebar_floating_button_focus_active = "@AWESOME_THEMES_PATH@/default/titlebar/floating_focus_active.png" theme.titlebar_floating_button_focus_active = themes_path.."default/titlebar/floating_focus_active.png"
theme.titlebar_maximized_button_normal_inactive = "@AWESOME_THEMES_PATH@/default/titlebar/maximized_normal_inactive.png" theme.titlebar_maximized_button_normal_inactive = themes_path.."default/titlebar/maximized_normal_inactive.png"
theme.titlebar_maximized_button_focus_inactive = "@AWESOME_THEMES_PATH@/default/titlebar/maximized_focus_inactive.png" theme.titlebar_maximized_button_focus_inactive = themes_path.."default/titlebar/maximized_focus_inactive.png"
theme.titlebar_maximized_button_normal_active = "@AWESOME_THEMES_PATH@/default/titlebar/maximized_normal_active.png" theme.titlebar_maximized_button_normal_active = themes_path.."default/titlebar/maximized_normal_active.png"
theme.titlebar_maximized_button_focus_active = "@AWESOME_THEMES_PATH@/default/titlebar/maximized_focus_active.png" theme.titlebar_maximized_button_focus_active = themes_path.."default/titlebar/maximized_focus_active.png"
theme.wallpaper = "@AWESOME_THEMES_PATH@/default/background.png" theme.wallpaper = themes_path.."default/background.png"
-- You can use your own layout icons like this: -- You can use your own layout icons like this:
theme.layout_fairh = "@AWESOME_THEMES_PATH@/default/layouts/fairhw.png" theme.layout_fairh = themes_path.."default/layouts/fairhw.png"
theme.layout_fairv = "@AWESOME_THEMES_PATH@/default/layouts/fairvw.png" theme.layout_fairv = themes_path.."default/layouts/fairvw.png"
theme.layout_floating = "@AWESOME_THEMES_PATH@/default/layouts/floatingw.png" theme.layout_floating = themes_path.."default/layouts/floatingw.png"
theme.layout_magnifier = "@AWESOME_THEMES_PATH@/default/layouts/magnifierw.png" theme.layout_magnifier = themes_path.."default/layouts/magnifierw.png"
theme.layout_max = "@AWESOME_THEMES_PATH@/default/layouts/maxw.png" theme.layout_max = themes_path.."default/layouts/maxw.png"
theme.layout_fullscreen = "@AWESOME_THEMES_PATH@/default/layouts/fullscreenw.png" theme.layout_fullscreen = themes_path.."default/layouts/fullscreenw.png"
theme.layout_tilebottom = "@AWESOME_THEMES_PATH@/default/layouts/tilebottomw.png" theme.layout_tilebottom = themes_path.."default/layouts/tilebottomw.png"
theme.layout_tileleft = "@AWESOME_THEMES_PATH@/default/layouts/tileleftw.png" theme.layout_tileleft = themes_path.."default/layouts/tileleftw.png"
theme.layout_tile = "@AWESOME_THEMES_PATH@/default/layouts/tilew.png" theme.layout_tile = themes_path.."default/layouts/tilew.png"
theme.layout_tiletop = "@AWESOME_THEMES_PATH@/default/layouts/tiletopw.png" theme.layout_tiletop = themes_path.."default/layouts/tiletopw.png"
theme.layout_spiral = "@AWESOME_THEMES_PATH@/default/layouts/spiralw.png" theme.layout_spiral = themes_path.."default/layouts/spiralw.png"
theme.layout_dwindle = "@AWESOME_THEMES_PATH@/default/layouts/dwindlew.png" theme.layout_dwindle = themes_path.."default/layouts/dwindlew.png"
theme.layout_cornernw = "@AWESOME_THEMES_PATH@/default/layouts/cornernww.png" theme.layout_cornernw = themes_path.."default/layouts/cornernww.png"
theme.layout_cornerne = "@AWESOME_THEMES_PATH@/default/layouts/cornernew.png" theme.layout_cornerne = themes_path.."default/layouts/cornernew.png"
theme.layout_cornersw = "@AWESOME_THEMES_PATH@/default/layouts/cornersww.png" theme.layout_cornersw = themes_path.."default/layouts/cornersww.png"
theme.layout_cornerse = "@AWESOME_THEMES_PATH@/default/layouts/cornersew.png" theme.layout_cornerse = themes_path.."default/layouts/cornersew.png"
theme.awesome_icon = "@AWESOME_ICON_PATH@/awesome16.png" theme.awesome_icon = icon_path.."awesome16.png"
-- Define the icon theme for application icons. If not set then the icons -- Define the icon theme for application icons. If not set then the icons
-- from /usr/share/icons and /usr/share/icons/hicolor will be used. -- from /usr/share/icons and /usr/share/icons/hicolor will be used.