Merge remote-tracking branch 'origin/master' into cmake-args

This commit is contained in:
Daniel Hahler 2019-01-12 15:37:59 +01:00
commit 1535934ef9
6 changed files with 69 additions and 54 deletions

View File

@ -10,6 +10,7 @@ end
return { return {
statsfile = build .. "/luacov.stats.out", statsfile = build .. "/luacov.stats.out",
reportfile = build .. "/luacov.report.out",
include = { include = {
escape_pattern(source) .. "/.+", escape_pattern(source) .. "/.+",

View File

@ -1,5 +1,4 @@
sudo: required dist: xenial
dist: trusty
language: c language: c
# Build only master and stable branches. Other branches go through PRs. # Build only master and stable branches. Other branches go through PRs.
@ -11,8 +10,7 @@ branches:
env: env:
matrix: matrix:
- LUA=5.2 LUANAME=lua5.2 DO_COVERAGE=coveralls - LUA=5.2 LUANAME=lua5.2 DO_COVERAGE=coveralls
# Lua 5.3 isn't available in Ubuntu Trusty, so some magic below installs it. - LUA=5.3 LUANAME=lua5.3 DO_COVERAGE=codecov
- LUA=5.3 LUANAME=lua5.3 LUALIBRARY=/usr/lib/liblua.so DO_COVERAGE=codecov
# 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.5 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.5 TEST_PREV_COMMITS=1
# Note: luarocks does not work with Lua 5.0. # Note: luarocks does not work with Lua 5.0.
@ -55,20 +53,9 @@ install:
make && sudo make install) make && sudo make 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.
- | - |
set -e set -e
if [[ "$LUA" == "5.3" ]]; then if [[ "$LUANAME" == "luajit-2.0" ]]; then
(echo '#!/bin/sh' ; echo 'set -x' ; echo 'gcc -shared -Wl,--no-undefined -o "$@" -ldl -lm') > /tmp/myar
chmod a+x /tmp/myar
(cd /tmp
wget http://www.lua.org/ftp/lua-5.3.4.tar.gz -O lua.tar.gz
tar -xvzf lua.tar.gz
cd lua-5.3.*/src \
&& make SYSCFLAGS="-DLUA_USE_LINUX -ULUA_COMPAT_5_2 -DLUA_USE_APICHECK -Dlua_assert=assert" SYSLIBS="-Wl,-E -ldl -lreadline" LUA_A=liblua.so MYCFLAGS="-fPIC" RANLIB=: AR="/tmp/myar" liblua.so \
&& cd .. \
&& sudo make INSTALL_TOP=/usr/ INSTALL_INC=${LUAINCLUDE} TO_LIB=liblua.so linux install)
elif [[ "$LUANAME" == "luajit-2.0" ]]; then
(wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz -O- | tar xzf - -C /tmp (wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz -O- | tar xzf - -C /tmp
cd /tmp/LuaJIT-* cd /tmp/LuaJIT-*
sudo make install PREFIX=/usr) sudo make install PREFIX=/usr)
@ -77,12 +64,15 @@ install:
if [ ! -e "/usr/bin/lua" ]; then sudo ln -s /usr/bin/luajit /usr/bin/lua; fi if [ ! -e "/usr/bin/lua" ]; then sudo ln -s /usr/bin/luajit /usr/bin/lua; fi
else else
sudo apt-get install -y lib${LUANAME}-dev ${LUANAME} ${INSTALL_PKGS} sudo apt-get install -y lib${LUANAME}-dev ${LUANAME} ${INSTALL_PKGS}
# lua5.3 does not install /usr/bin/lua, but lua5.1/lua5.2 do.
if [ ! -e "/usr/bin/lua" ]; then sudo ln -s /usr/bin/${LUANAME} /usr/bin/lua; fi
fi fi
- lua -v
# Install luarocks (for the selected Lua version). # Install luarocks (for the selected Lua version).
- | - |
travis_retry wget https://github.com/luarocks/luarocks/archive/v2.4.2.tar.gz travis_retry wget https://github.com/luarocks/luarocks/archive/v3.0.4.tar.gz
tar xf v2.4.2.tar.gz -C /tmp tar xf v3.0.4.tar.gz -C /tmp
(cd /tmp/luarocks-* \ (cd /tmp/luarocks-* \
&& ./configure --lua-version=$LUA --with-lua-include=${LUAINCLUDE} ${LUAROCKS_ARGS} \ && ./configure --lua-version=$LUA --with-lua-include=${LUAINCLUDE} ${LUAROCKS_ARGS} \
&& make build \ && make build \
@ -126,8 +116,8 @@ install:
if [ "$DO_COVERAGE" = "codecov" ]; then if [ "$DO_COVERAGE" = "codecov" ]; then
test -f build/luacov.stats.out || { echo 'build/luacov.stats.out does not exist.'; return 1; } test -f build/luacov.stats.out || { echo 'build/luacov.stats.out does not exist.'; return 1; }
luacov || return 1 luacov || return 1
travis_retry bash /tmp/codecov-bash -X gcov -X coveragepy -c -F "$1,${LUANAME//./}" || return 1 travis_retry bash /tmp/codecov-bash -f build/luacov.report.out -X gcov -X coveragepy -F "$1,${LUANAME//./}" || return 1
rm build/luacov.stats.out rm build/luacov.report.out build/luacov.stats.out
fi fi
return 0 return 0
} }
@ -135,7 +125,28 @@ install:
do_codecov_gcov() { do_codecov_gcov() {
echo "== do_codecov_gcov in $PWD: $*: ==" echo "== do_codecov_gcov in $PWD: $*: =="
if [ "$DO_COVERAGE" = "codecov" ]; then if [ "$DO_COVERAGE" = "codecov" ]; then
travis_retry bash /tmp/codecov-bash -X coveragepy -c -F "$1" || return 1 # Report coverage for each .gcno file separately.
# gcov will create .gcov files for the same source (e.g. for
# globalconf.h from awesome.c.gcno and event.c.gcno).
i=0
set -x
(
cd build
find -path "*/lgi-check.dir" -prune -o \( -name '*.gcno' -print \) | while read -r gcno; do
gcov -pb "$gcno"
mkdir gcov.$(( ++i ))
mv *.gcov "gcov.$i"
# Delete any files for /usr.
# They are not relevant and might cause "Invalid path part" errors
# with Code Climate.
find "gcov.$i" -maxdepth 1 -type f -name '#usr#*.gcov' -delete
done
# Upload to Codecov.
travis_retry bash /tmp/codecov-bash -X gcov -X coveragepy -F "$1,${LUANAME//./}"
)
fi fi
return 0 return 0
} }
@ -194,11 +205,12 @@ script:
&& make) && make)
do_codecov samples do_codecov samples
make check-unit-coverage || exit 1 make check-unit || exit 1
do_codecov unittests do_codecov unittests
make check-integration || exit 1 make check-integration || exit 1
make check-themes || exit 1
do_codecov functionaltests do_codecov functionaltests
make check-themes || exit 1
do_codecov themes
do_codecov_gcov c_code do_codecov_gcov c_code
travis_fold_end travis_fold_end
@ -234,6 +246,7 @@ 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 CMAKE_ARGS+="-D DO_COVERAGE=0"; then if ! make all check CMAKE_ARGS+="-D DO_COVERAGE=0"; then
failed="$failed $commit" failed="$failed $commit"
fi fi

View File

@ -38,8 +38,6 @@ include_directories(
${AWESOME_REQUIRED_INCLUDE_DIRS} ${AWESOME_REQUIRED_INCLUDE_DIRS}
${AWESOME_OPTIONAL_INCLUDE_DIRS}) ${AWESOME_OPTIONAL_INCLUDE_DIRS})
set(CHECK_TARGETS check-integration)
set(AWE_ICON_DIR ${SOURCE_DIR}/icons) set(AWE_ICON_DIR ${SOURCE_DIR}/icons)
set(AWE_THEMES_DIR ${SOURCE_DIR}/themes) set(AWE_THEMES_DIR ${SOURCE_DIR}/themes)
@ -397,23 +395,28 @@ endif()
# }}} # }}}
# {{{ Tests # {{{ Tests
add_custom_target(check DEPENDS check-integration)
add_executable(test-gravity tests/test-gravity.c) add_executable(test-gravity tests/test-gravity.c)
target_link_libraries(test-gravity target_link_libraries(test-gravity
${AWESOME_COMMON_REQUIRED_LDFLAGS} ${AWESOME_REQUIRED_LDFLAGS}) ${AWESOME_COMMON_REQUIRED_LDFLAGS} ${AWESOME_REQUIRED_LDFLAGS})
if(DO_COVERAGE)
set(TESTS_RUN_ENV DO_COVERAGE=1)
endif()
add_custom_target(check-integration add_custom_target(check-integration
${CMAKE_COMMAND} -E env CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}' ./tests/run.sh \$\${TEST_RUN_ARGS:--W} ${CMAKE_COMMAND} -E env CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}' ${TESTS_RUN_ENV} ./tests/run.sh \$\${TEST_RUN_ARGS:--W}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running integration tests" COMMENT "Running integration tests"
DEPENDS ${PROJECT_AWE_NAME} DEPENDS ${PROJECT_AWE_NAME}
USES_TERMINAL) USES_TERMINAL)
add_dependencies(check-integration test-gravity) add_dependencies(check-integration test-gravity)
add_custom_target(check-themes add_custom_target(check-themes
${CMAKE_COMMAND} -E env CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}' ./tests/themes/run.sh ${CMAKE_COMMAND} -E env CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}' ${TESTS_RUN_ENV} ./tests/themes/run.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Testing themes" COMMENT "Testing themes"
USES_TERMINAL USES_TERMINAL
DEPENDS generated_icons generate_awesomerc ${PROJECT_AWE_NAME}) DEPENDS generated_icons generate_awesomerc ${PROJECT_AWE_NAME})
list(APPEND CHECK_TARGETS check-themes) add_dependencies(check check-themes)
add_custom_target(check-requires add_custom_target(check-requires
lua "${CMAKE_SOURCE_DIR}/build-utils/check_for_invalid_requires.lua" lua "${CMAKE_SOURCE_DIR}/build-utils/check_for_invalid_requires.lua"
@ -424,25 +427,23 @@ add_custom_target(check-requires
list(APPEND CHECK_QA_TARGETS check-requires) list(APPEND CHECK_QA_TARGETS check-requires)
a_find_program(BUSTED_EXECUTABLE busted FALSE) a_find_program(BUSTED_EXECUTABLE busted FALSE)
if(BUSTED_EXECUTABLE) if(BUSTED_EXECUTABLE)
# Keep the arguments in sync with the version below! if(DO_COVERAGE)
set(BUSTED_ARGS "--coverage")
else()
set(BUSTED_ARGS)
endif()
add_custom_target(check-unit add_custom_target(check-unit
${BUSTED_EXECUTABLE} COMMAND ${BUSTED_EXECUTABLE} ${BUSTED_ARGS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running unit tests" COMMENT "Running unit tests"
VERBATIM) VERBATIM)
list(APPEND CHECK_TARGETS check-unit)
# Same as above, but with --coverage argument
add_custom_target(check-unit-coverage
${BUSTED_EXECUTABLE} "--coverage"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running unit tests under LuaCov"
VERBATIM)
else() else()
add_custom_target(check-unit true add_custom_target(check-unit true
COMMENT "Skipping check-unit, since busted was not found" COMMENT "Skipping check-unit, since busted was not found (during configuration)"
VERBATIM) VERBATIM)
endif() endif()
add_dependencies(check check-unit)
a_find_program(LUACHECK_EXECUTABLE luacheck FALSE) a_find_program(LUACHECK_EXECUTABLE luacheck FALSE)
if(LUACHECK_EXECUTABLE) if(LUACHECK_EXECUTABLE)
add_custom_target(luacheck add_custom_target(luacheck
@ -453,7 +454,7 @@ if(LUACHECK_EXECUTABLE)
list(APPEND CHECK_QA_TARGETS luacheck) list(APPEND CHECK_QA_TARGETS luacheck)
endif() endif()
add_custom_target(check-qa DEPENDS ${CHECK_QA_TARGETS}) add_custom_target(check-qa DEPENDS ${CHECK_QA_TARGETS})
add_custom_target(check DEPENDS ${CHECK_TARGETS} check-qa) add_dependencies(check check-qa check-examples)
# }}} # }}}
INCLUDE(${CMAKE_SOURCE_DIR}/Packaging.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/Packaging.cmake)

View File

@ -5,12 +5,14 @@ else
ECHO=@: ECHO=@:
endif endif
TARGETS=awesome
BUILDDIR=build BUILDDIR=build
all: $(TARGETS) ; # Run "make" in $(BUILDDIR) by default.
# This is required to generate all files already, which should not be generated
$(TARGETS): cmake-build # with "(sudo) make install" only later.
cmake-build: $(BUILDDIR)/Makefile
$(ECHO) "Building…"
$(MAKE) -C $(BUILDDIR)
# Run CMake always with CMAKE_ARGS defined. # Run CMake always with CMAKE_ARGS defined.
ifdef CMAKE_ARGS ifdef CMAKE_ARGS
@ -24,10 +26,6 @@ $(BUILDDIR)/Makefile:
$(ECHO) "Running cmake…" $(ECHO) "Running cmake…"
cd $(BUILDDIR) && cmake $(CMAKE_ARGS) "$(CURDIR)" cd $(BUILDDIR) && cmake $(CMAKE_ARGS) "$(CURDIR)"
cmake-build: $(BUILDDIR)/Makefile
$(ECHO) "Building…"
$(MAKE) -C $(BUILDDIR)
tags: tags:
git ls-files | xargs ctags git ls-files | xargs ctags

View File

@ -3,6 +3,8 @@
# Test all themes. # Test all themes.
# This should be run via `make check-themes` (or manually from the build # This should be run via `make check-themes` (or manually from the build
# directory). # directory).
#
# It uses tests/run.sh internally, which handles coverage.
set -e set -e

View File

@ -17,12 +17,12 @@ then
then then
if [ "$A_RERUN" = "" ] if [ "$A_RERUN" = "" ]
then then
A_RERUN="no" exec $AWESOME_RLWRAP $0 "$@" A_RERUN="no" exec "$AWESOME_RLWRAP" "$0" "$@"
fi fi
READ_CMD="read" READ_ARGS=""
else else
# No rlwrap: use bash's readline. # No rlwrap: use bash's readline.
READ_CMD="read -e" READ_ARGS="-e"
fi fi
fi fi
@ -76,13 +76,13 @@ then
fi fi
done done
# run arguments # run arguments
for arg in "$ARGS" ; do for arg in "${ARGS[@]}"; do
a_dbus_send "$arg" a_dbus_send "$arg"
done done
elif [ -t 0 ] elif [ -t 0 ]
then then
FATAL_ERRORS=0 FATAL_ERRORS=0
while $READ_CMD -p "awesome# " -r line while read $READ_ARGS -p "awesome# " -r line
do do
if [ "$line" = "" ]; then if [ "$line" = "" ]; then
continue continue