From 0ef55a91ef9c591cee3a7e1ff0e391cdc32423c3 Mon Sep 17 00:00:00 2001 From: Martin Babinsky Date: Thu, 5 Jan 2017 10:10:06 +0100 Subject: Trim the test runner log to show only pytest failures/errors If we get to the `run-tests` phase, we no longer care about messages from previous steps so we can truncate the log output to only show pytest failures/errors, reducing log size. As a fallback, the previous behaviour to print last 5000 log lines was kept in the case the CI tests fail during setup. Reviewed-By: Stanislav Laznicka Reviewed-By: Fraser Tweedale --- .travis.yml | 3 ++- .travis_run_task.sh | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4f36b82cb..63019749c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: TEST_RUNNER_CONFIG=".test_runner_config.yaml" PEP8_ERROR_LOG="pep8_errors.log" CI_RESULTS_LOG="ci_results_${TRAVIS_BRANCH}.log" + CI_BACKLOG_SIZE=5000 matrix: - TASK_TO_RUN="lint" - TASK_TO_RUN="run-tests" @@ -32,5 +33,5 @@ install: script: - travis_wait 50 ./.travis_run_task.sh after_failure: - - echo "Test runner output:"; tail -n 5000 $CI_RESULTS_LOG + - echo "Test runner output:"; tail -n $CI_BACKLOG_SIZE $CI_RESULTS_LOG - echo "PEP-8 errors:"; cat $PEP8_ERROR_LOG diff --git a/.travis_run_task.sh b/.travis_run_task.sh index a9144b522..9fd1c1cb8 100755 --- a/.travis_run_task.sh +++ b/.travis_run_task.sh @@ -8,6 +8,17 @@ PYTHON="/usr/bin/python${TRAVIS_PYTHON_VERSION}" test_set="" developer_mode_opt="--developer-mode" +function truncate_log_to_test_failures() { + # chop off everything in the CI_RESULTS_LOG preceding pytest error output + # if there are pytest errors in the log + error_fail_regexp='\(=== ERRORS ===\)\|\(=== FAILURES ===\)' + + if grep -e "$error_fail_regexp" $CI_RESULTS_LOG > /dev/null + then + sed -i "/$error_fail_regexp/,\$!d" $CI_RESULTS_LOG + fi +} + if [[ "$TASK_TO_RUN" == "lint" ]] then if [[ "$TRAVIS_EVENT_TYPE" == "pull_request" ]] @@ -35,3 +46,8 @@ ipa-docker-test-runner -l $CI_RESULTS_LOG \ --container-image $TEST_RUNNER_IMAGE \ --git-repo $TRAVIS_BUILD_DIR \ $TASK_TO_RUN $test_set + +if $? +then + truncate_log_to_test_failures +fi -- cgit