aboutsummaryrefslogtreecommitdiff
path: root/ci/common
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-03-31 16:02:53 +0300
committerZyX <kp-pav@yandex.ru>2017-03-31 16:06:17 +0300
commit2bf9d36ccd59f12e3895c885e8cf17e620bf191b (patch)
treed97b0806a79c1b6e55586c123966770027ad4cad /ci/common
parent4d0f90f94db6040841b9987d02a021b785cfe0f3 (diff)
downloadrneovim-2bf9d36ccd59f12e3895c885e8cf17e620bf191b.tar.gz
rneovim-2bf9d36ccd59f12e3895c885e8cf17e620bf191b.tar.bz2
rneovim-2bf9d36ccd59f12e3895c885e8cf17e620bf191b.zip
ci: Refactor CI scripts
1. CI_TARGET now determines which run_${CI_TARGET}.sh script to use. Defaults to `tests`. 2. Build no longer halts on the first failing suit: e.g. if functional tests failed it will continue with unit tests, etc. 3. All ${MAKE_CMD} occurrences moved to `top_make` function, added `build_make` as an alias to `make -C build` (`"${MAKE_CMD}" -C "${BUILD_DIR}"`) which is too verbose. `suite.sh` was copied from powerline (tests/common.sh file), assumes running with POSIX shells (and actually uses dash in powerline). Then some convenience functions were added (run_test and below).
Diffstat (limited to 'ci/common')
-rw-r--r--ci/common/build.sh16
-rw-r--r--ci/common/suite.sh55
-rw-r--r--ci/common/test.sh8
3 files changed, 72 insertions, 7 deletions
diff --git a/ci/common/build.sh b/ci/common/build.sh
index 44087513ee..19c23bdda8 100644
--- a/ci/common/build.sh
+++ b/ci/common/build.sh
@@ -1,3 +1,11 @@
+top_make() {
+ "${MAKE_CMD}" "$@"
+}
+
+build_make() {
+ top_make -C "${BUILD_DIR}" "$@"
+}
+
build_deps() {
if [[ "${BUILD_32BIT}" == ON ]]; then
DEPS_CMAKE_FLAGS="${DEPS_CMAKE_FLAGS} ${CMAKE_FLAGS_32BIT}"
@@ -30,7 +38,7 @@ build_deps() {
echo "Configuring with '${DEPS_CMAKE_FLAGS}'."
CC= cmake ${DEPS_CMAKE_FLAGS} "${TRAVIS_BUILD_DIR}/third-party/"
- if ! ${MAKE_CMD}; then
+ if ! top_make; then
exit 1
fi
@@ -53,18 +61,18 @@ prepare_build() {
build_nvim() {
echo "Building nvim."
- if ! ${MAKE_CMD} nvim; then
+ if ! top_make nvim; then
exit 1
fi
if [ "$CLANG_SANITIZER" != "TSAN" ]; then
echo "Building libnvim."
- if ! ${MAKE_CMD} libnvim; then
+ if ! top_make libnvim; then
exit 1
fi
echo "Building nvim-test."
- if ! ${MAKE_CMD} nvim-test; then
+ if ! top_make nvim-test; then
exit 1
fi
fi
diff --git a/ci/common/suite.sh b/ci/common/suite.sh
new file mode 100644
index 0000000000..ad7c30708f
--- /dev/null
+++ b/ci/common/suite.sh
@@ -0,0 +1,55 @@
+FAILED=0
+
+FAIL_SUMMARY=""
+
+enter_suite() {
+ local suite_name="$1"
+ export NVIM_TEST_CURRENT_SUITE="${NVIM_TEST_CURRENT_SUITE}/$suite_name"
+}
+
+exit_suite() {
+ if test $FAILED -ne 0 ; then
+ echo "Suite ${NVIM_TEST_CURRENT_SUITE} failed, summary:"
+ echo "${FAIL_SUMMARY}"
+ fi
+ export NVIM_TEST_CURRENT_SUITE="${NVIM_TEST_CURRENT_SUITE%/*}"
+ if test "x$1" != "x--continue" ; then
+ exit $FAILED
+ fi
+}
+
+fail() {
+ local allow_failure=
+ if test "x$1" = "x--allow-failure" ; then
+ shift
+ allow_failure=A
+ fi
+ local test_name="$1"
+ local fail_char="$allow_failure$2"
+ local message="$3"
+
+ : ${fail_char:=F}
+ : ${message:=Test $test_name failed}
+
+ local full_msg="$fail_char $NVIM_TEST_CURRENT_SUITE|$test_name :: $message"
+ FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}"
+ echo "Failed: $full_msg"
+ if test "x$allow_failure" = "x" ; then
+ FAILED=1
+ fi
+}
+
+run_test() {
+ local cmd="$1"
+ shift
+ local test_name="$1"
+ : ${test_name:=$cmd}
+ shift
+ if ! eval "$cmd" ; then
+ fail "${test_name}" "$@"
+ fi
+}
+
+succeeded() {
+ return $FAILED
+}
diff --git a/ci/common/test.sh b/ci/common/test.sh
index b28e46a4df..4936992cfd 100644
--- a/ci/common/test.sh
+++ b/ci/common/test.sh
@@ -1,3 +1,5 @@
+source "${CI_DIR}/common/build.sh"
+
print_core() {
local app="$1"
local core="$2"
@@ -75,7 +77,7 @@ asan_check() {
run_unittests() {
ulimit -c unlimited
- if ! ${MAKE_CMD} -C "${BUILD_DIR}" unittest ; then
+ if ! build_make unittest ; then
check_core_dumps "$(which luajit)"
exit 1
fi
@@ -84,7 +86,7 @@ run_unittests() {
run_functionaltests() {
ulimit -c unlimited
- if ! ${MAKE_CMD} -C "${BUILD_DIR}" ${FUNCTIONALTEST}; then
+ if ! build_make ${FUNCTIONALTEST}; then
asan_check "${LOG_DIR}"
valgrind_check "${LOG_DIR}"
check_core_dumps
@@ -110,7 +112,7 @@ run_oldtests() {
}
install_nvim() {
- ${MAKE_CMD} -C "${BUILD_DIR}" install
+ build_make install
"${INSTALL_PREFIX}/bin/nvim" --version
"${INSTALL_PREFIX}/bin/nvim" -u NONE -e -c ':help' -c ':qall' || {