From 17ecb60c58237fa4a68b95d0ef9b0a48fe0b2c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dundar=20G=C3=B6c?= Date: Fri, 4 Mar 2022 16:22:33 +0100 Subject: [PATCH 1/5] ci: remove fail character from fail function --- ci/common/suite.sh | 6 ++---- ci/common/test.sh | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ci/common/suite.sh b/ci/common/suite.sh index 5110e22ec2..a903f972a9 100644 --- a/ci/common/suite.sh +++ b/ci/common/suite.sh @@ -29,13 +29,11 @@ exit_suite() { fail() { local test_name="$1" - local fail_char="$2" - local message="$3" + local message="$2" - : ${fail_char:=F} : ${message:=Test $test_name failed} - local full_msg="$fail_char $NVIM_TEST_CURRENT_SUITE|$test_name :: $message" + local full_msg="$NVIM_TEST_CURRENT_SUITE|$test_name :: $message" FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" echo "${full_msg}" >> "${FAIL_SUMMARY_FILE}" echo "Failed: $full_msg" diff --git a/ci/common/test.sh b/ci/common/test.sh index f211a2e7aa..65125cd036 100644 --- a/ci/common/test.sh +++ b/ci/common/test.sh @@ -51,7 +51,7 @@ check_core_dumps() { fi done if test "$app" != quiet ; then - fail 'cores' E 'Core dumps found' + fail 'cores' 'Core dumps found' fi } @@ -72,7 +72,7 @@ check_logs() { rm "${log}" done if test -n "${err}" ; then - fail 'logs' E 'Runtime errors detected.' + fail 'logs' 'Runtime errors detected.' fi } @@ -89,7 +89,7 @@ check_sanitizer() { run_unittests() {( ulimit -c unlimited || true if ! build_make unittest ; then - fail 'unittests' F 'Unit tests failed' + fail 'unittests' 'Unit tests failed' fi submit_coverage unittest check_core_dumps "$(command -v luajit)" @@ -98,7 +98,7 @@ run_unittests() {( run_functionaltests() {( ulimit -c unlimited || true if ! build_make ${FUNCTIONALTEST}; then - fail 'functionaltests' F 'Functional tests failed' + fail 'functionaltests' 'Functional tests failed' fi submit_coverage functionaltest check_sanitizer "${LOG_DIR}" @@ -110,7 +110,7 @@ run_oldtests() {( ulimit -c unlimited || true if ! make oldtest; then reset - fail 'oldtests' F 'Legacy tests failed' + fail 'oldtests' 'Legacy tests failed' fi submit_coverage oldtest check_sanitizer "${LOG_DIR}" @@ -129,18 +129,17 @@ check_runtime_files() {( # Prefer failing the build over using more robust construct because files # with IFS are not welcome. if ! test -e "$file" ; then - fail "$test_name" E \ - "It appears that $file is only a part of the file name" + fail "$test_name" "It appears that $file is only a part of the file name" fi if ! test "$tst" "$INSTALL_PREFIX/share/nvim/runtime/$file" ; then - fail "$test_name" F "$(printf "$message" "$file")" + fail "$test_name" "$(printf "$message" "$file")" fi done )} install_nvim() {( if ! build_make install ; then - fail 'install' E 'make install failed' + fail 'install' 'make install failed' exit_suite fi @@ -148,7 +147,7 @@ install_nvim() {( if ! "${INSTALL_PREFIX}/bin/nvim" -u NONE -e -c ':help' -c ':qall' ; then echo "Running ':help' in the installed nvim failed." echo "Maybe the helptags have not been generated properly." - fail 'help' F 'Failed running :help' + fail 'help' 'Failed running :help' fi # Check that all runtime files were installed @@ -169,6 +168,6 @@ install_nvim() {( local genvimsynf=syntax/vim/generated.vim local gpat='syn keyword vimFuncName .*eval' if ! grep -q "$gpat" "${INSTALL_PREFIX}/share/nvim/runtime/$genvimsynf" ; then - fail 'funcnames' F "It appears that $genvimsynf does not contain $gpat." + fail 'funcnames' "It appears that $genvimsynf does not contain $gpat." fi )} From fbcbd1d05e2d51dda159d78d99e67b6041182321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dundar=20G=C3=B6c?= Date: Fri, 4 Mar 2022 16:27:57 +0100 Subject: [PATCH 2/5] ci: remove variable NVIM_TEST_CURRENT_SUITE We always know where in the test we are anyway, it's just needless repetition. --- ci/common/suite.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ci/common/suite.sh b/ci/common/suite.sh index a903f972a9..5b524efd15 100644 --- a/ci/common/suite.sh +++ b/ci/common/suite.sh @@ -14,16 +14,13 @@ FAIL_SUMMARY_FILE="$BUILD_DIR/.test_errors" enter_suite() { FAILED=0 rm -f "${END_MARKER}" - 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 "Test failed, summary:" echo "${FAIL_SUMMARY}" fi - export NVIM_TEST_CURRENT_SUITE="${NVIM_TEST_CURRENT_SUITE%/*}" FAILED=0 } @@ -33,7 +30,7 @@ fail() { : ${message:=Test $test_name failed} - local full_msg="$NVIM_TEST_CURRENT_SUITE|$test_name :: $message" + local full_msg="$test_name :: $message" FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" echo "${full_msg}" >> "${FAIL_SUMMARY_FILE}" echo "Failed: $full_msg" @@ -67,8 +64,7 @@ run_suite() { local command="$1" local suite_name="$2" - enter_suite "$suite_name" + enter_suite eval "$command" || fail "$suite_name" exit_suite } - From 7a0fd7a288827e26bf65279a05b952b057b31d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dundar=20G=C3=B6c?= Date: Fri, 4 Mar 2022 16:51:38 +0100 Subject: [PATCH 3/5] ci: remove variable FAIL_SUMMARY On GitHub Actions it just repeats the summary that is shown just after. When run outside of GitHub Actions it erroneously shows the summary of the previous suites. --- ci/common/suite.sh | 24 +----------------------- ci/common/test.sh | 2 +- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/ci/common/suite.sh b/ci/common/suite.sh index 5b524efd15..7951f8ce27 100644 --- a/ci/common/suite.sh +++ b/ci/common/suite.sh @@ -1,9 +1,3 @@ -# HACK: get newline for use in strings given that "\n" and $'' do not work. -NL="$(printf '\nE')" -NL="${NL%E}" - -FAIL_SUMMARY="" - # Test success marker. If END_MARKER file exists, we know that all tests # finished. If FAIL_SUMMARY_FILE exists we know that some tests failed, this # file will contain information about failed tests. Build is considered @@ -11,19 +5,6 @@ FAIL_SUMMARY="" END_MARKER="$BUILD_DIR/.tests_finished" FAIL_SUMMARY_FILE="$BUILD_DIR/.test_errors" -enter_suite() { - FAILED=0 - rm -f "${END_MARKER}" -} - -exit_suite() { - if test $FAILED -ne 0 ; then - echo "Test failed, summary:" - echo "${FAIL_SUMMARY}" - fi - FAILED=0 -} - fail() { local test_name="$1" local message="$2" @@ -31,10 +12,8 @@ fail() { : ${message:=Test $test_name failed} local full_msg="$test_name :: $message" - FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" echo "${full_msg}" >> "${FAIL_SUMMARY_FILE}" echo "Failed: $full_msg" - FAILED=1 } ended_successfully() { @@ -64,7 +43,6 @@ run_suite() { local command="$1" local suite_name="$2" - enter_suite + rm -f "${END_MARKER}" eval "$command" || fail "$suite_name" - exit_suite } diff --git a/ci/common/test.sh b/ci/common/test.sh index 65125cd036..3df24cf3b0 100644 --- a/ci/common/test.sh +++ b/ci/common/test.sh @@ -140,7 +140,7 @@ check_runtime_files() {( install_nvim() {( if ! build_make install ; then fail 'install' 'make install failed' - exit_suite + exit 1 fi "${INSTALL_PREFIX}/bin/nvim" --version From d47714d87c0ea082568fb9f59a579381253bf179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dundar=20G=C3=B6c?= Date: Sat, 5 Mar 2022 15:40:20 +0100 Subject: [PATCH 4/5] ci: remove function run_suite --- ci/common/suite.sh | 8 -------- ci/run_lint.sh | 22 ++++++++++++---------- ci/run_tests.sh | 21 +++++++++++---------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/ci/common/suite.sh b/ci/common/suite.sh index 7951f8ce27..c0c470dce1 100644 --- a/ci/common/suite.sh +++ b/ci/common/suite.sh @@ -38,11 +38,3 @@ end_tests() { touch "${END_MARKER}" ended_successfully } - -run_suite() { - local command="$1" - local suite_name="$2" - - rm -f "${END_MARKER}" - eval "$command" || fail "$suite_name" -} diff --git a/ci/run_lint.sh b/ci/run_lint.sh index 2fea7a40c0..d9869c2756 100755 --- a/ci/run_lint.sh +++ b/ci/run_lint.sh @@ -8,30 +8,32 @@ CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${CI_DIR}/common/build.sh" source "${CI_DIR}/common/suite.sh" +rm -f "$END_MARKER" + if [[ "$GITHUB_ACTIONS" != "true" ]]; then - run_suite 'make clint-full' 'clint' - run_suite 'make lualint' 'lualint' - run_suite 'make pylint' 'pylint' - run_suite 'make shlint' 'shlint' - run_suite 'make check-single-includes' 'single-includes' + make clint-full || fail 'clint' + make lualint || fail 'lualint' + make pylint || fail 'pylint' + make shlint || fail 'shlint' + make check-single-includes || fail 'single-includes' end_tests else case "$1" in clint) - run_suite 'make clint-full' 'clint' + make clint-full || fail 'clint' ;; lualint) - run_suite 'make lualint' 'lualint' + make lualint || fail 'lualint' ;; pylint) - run_suite 'make pylint' 'pylint' + make pylint || fail 'pylint' ;; shlint) - run_suite 'make shlint' 'shlint' + make shlint || fail 'shlint' ;; single-includes) - run_suite 'make check-single-includes' 'single-includes' + make check-single-includes || fail 'single-includes' ;; *) :;; diff --git a/ci/run_tests.sh b/ci/run_tests.sh index ae85246ab6..a121d28902 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -8,38 +8,39 @@ source "${CI_DIR}/common/build.sh" source "${CI_DIR}/common/test.sh" source "${CI_DIR}/common/suite.sh" +rm -f "$END_MARKER" if [[ "$GITHUB_ACTIONS" != "true" ]]; then - run_suite 'build_nvim' 'build' + build_nvim || fail 'build' if test "$CLANG_SANITIZER" != "TSAN"; then # Additional threads are only created when the builtin UI starts, which # doesn't happen in the unit/functional tests if test "${FUNCTIONALTEST}" != "functionaltest-lua"; then - run_suite run_unittests unittests + run_unittests || fail 'unittests' fi - run_suite run_functionaltests functionaltests + run_functionaltests || fail 'functionaltests' fi - run_suite run_oldtests oldtests - run_suite install_nvim install_nvim + run_oldtests || fail 'oldtests' + install_nvim || fail 'install_nvim' end_tests else case "$1" in build) - run_suite 'build_nvim' 'build' + build_nvim || fail 'build' ;; unittests) - run_suite 'run_unittests' 'unittests' + run_unittests || fail 'unittests' ;; functionaltests) - run_suite 'run_functionaltests' 'functionaltests' + run_functionaltests || fail 'functionaltests' ;; oldtests) - run_suite 'run_oldtests' 'oldtests' + run_oldtests || fail 'oldtests' ;; install_nvim) - run_suite 'install_nvim' 'install_nvim' + install_nvim || fail 'install_nvim' ;; *) :;; From 815ba835a3486e103b0718e722c5cb5bf633a864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dundar=20G=C3=B6c?= Date: Sat, 5 Mar 2022 18:07:46 +0100 Subject: [PATCH 5/5] ci: refactor and simplify CI process --- .github/workflows/ci.yml | 12 ++++++------ ci/common/test.sh | 6 +++--- ci/run_lint.sh | 39 ++++++++++---------------------------- ci/run_tests.sh | 41 +++++++++++++--------------------------- 4 files changed, 32 insertions(+), 66 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41a22af538..ea3185d2a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,11 +80,11 @@ jobs: run: ./ci/before_script.sh - name: Build nvim - run: ./ci/run_tests.sh build + run: ./ci/run_tests.sh build_nvim - if: "!cancelled()" - name: clint - run: ./ci/run_lint.sh clint + name: clint-full + run: ./ci/run_lint.sh clint-full - if: "!cancelled()" name: lualint @@ -99,8 +99,8 @@ jobs: run: ./ci/run_lint.sh shlint - if: "!cancelled()" - name: single-includes - run: ./ci/run_lint.sh single-includes + name: check-single-includes + run: ./ci/run_lint.sh check-single-includes - name: Cache dependencies run: ./ci/before_cache.sh @@ -201,7 +201,7 @@ jobs: run: ./ci/before_script.sh - name: Build - run: ./ci/run_tests.sh build + run: ./ci/run_tests.sh build_nvim - if: matrix.flavor != 'tsan' && matrix.flavor != 'functionaltest-lua' && !cancelled() name: Unittests diff --git a/ci/common/test.sh b/ci/common/test.sh index 3df24cf3b0..7db39a0e5f 100644 --- a/ci/common/test.sh +++ b/ci/common/test.sh @@ -86,7 +86,7 @@ check_sanitizer() { fi } -run_unittests() {( +unittests() {( ulimit -c unlimited || true if ! build_make unittest ; then fail 'unittests' 'Unit tests failed' @@ -95,7 +95,7 @@ run_unittests() {( check_core_dumps "$(command -v luajit)" )} -run_functionaltests() {( +functionaltests() {( ulimit -c unlimited || true if ! build_make ${FUNCTIONALTEST}; then fail 'functionaltests' 'Functional tests failed' @@ -106,7 +106,7 @@ run_functionaltests() {( check_core_dumps )} -run_oldtests() {( +oldtests() {( ulimit -c unlimited || true if ! make oldtest; then reset diff --git a/ci/run_lint.sh b/ci/run_lint.sh index d9869c2756..3a524b4ed6 100755 --- a/ci/run_lint.sh +++ b/ci/run_lint.sh @@ -10,34 +10,15 @@ source "${CI_DIR}/common/suite.sh" rm -f "$END_MARKER" -if [[ "$GITHUB_ACTIONS" != "true" ]]; then - make clint-full || fail 'clint' - make lualint || fail 'lualint' - make pylint || fail 'pylint' - make shlint || fail 'shlint' - make check-single-includes || fail 'single-includes' - - end_tests +# Run all tests if no input argument is given +if (($# == 0)); then + tests=('clint-full' 'lualint' 'pylint' 'shlint' 'check-single-includes') else - case "$1" in - clint) - make clint-full || fail 'clint' - ;; - lualint) - make lualint || fail 'lualint' - ;; - pylint) - make pylint || fail 'pylint' - ;; - shlint) - make shlint || fail 'shlint' - ;; - single-includes) - make check-single-includes || fail 'single-includes' - ;; - *) - :;; - esac - - end_tests + tests=("$@") fi + +for i in "${tests[@]}"; do + make "$i" || fail "$i" +done + +end_tests diff --git a/ci/run_tests.sh b/ci/run_tests.sh index a121d28902..23460b682e 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -10,41 +10,26 @@ source "${CI_DIR}/common/suite.sh" rm -f "$END_MARKER" -if [[ "$GITHUB_ACTIONS" != "true" ]]; then - build_nvim || fail 'build' +# Run all tests (with some caveats) if no input argument is given +if (($# == 0)); then + tests=('build_nvim') if test "$CLANG_SANITIZER" != "TSAN"; then # Additional threads are only created when the builtin UI starts, which # doesn't happen in the unit/functional tests if test "${FUNCTIONALTEST}" != "functionaltest-lua"; then - run_unittests || fail 'unittests' + tests+=('unittests') fi - run_functionaltests || fail 'functionaltests' + tests+=('functionaltests') fi - run_oldtests || fail 'oldtests' - install_nvim || fail 'install_nvim' - end_tests + tests+=('oldtests' 'install_nvim') else - case "$1" in - build) - build_nvim || fail 'build' - ;; - unittests) - run_unittests || fail 'unittests' - ;; - functionaltests) - run_functionaltests || fail 'functionaltests' - ;; - oldtests) - run_oldtests || fail 'oldtests' - ;; - install_nvim) - install_nvim || fail 'install_nvim' - ;; - *) - :;; - esac - - end_tests + tests=("$@") fi + +for i in "${tests[@]}"; do + eval "$i" || fail "$i" +done + +end_tests