diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-05 16:22:51 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-06 00:10:11 +0300 |
commit | eb4ba34ed3009ee5cec34ed83bab8149e4d6ffc4 (patch) | |
tree | b8629a38f6378cc25cc309a0a9b39f0f8720c10a /.travis/test | |
parent | StatusTracker: handle SIGTERM also (diff) | |
download | vk-scripts-eb4ba34ed3009ee5cec34ed83bab8149e4d6ffc4.tar.gz vk-scripts-eb4ba34ed3009ee5cec34ed83bab8149e4d6ffc4.zip |
Travis: prettier output
Diffstat (limited to '')
-rwxr-xr-x | .travis/test.sh | 22 | ||||
-rwxr-xr-x | .travis/test/mutual_friends.sh | 10 | ||||
-rwxr-xr-x | .travis/test/online_sessions.sh | 31 | ||||
-rwxr-xr-x | .travis/test/show_status.sh | 7 | ||||
-rwxr-xr-x | .travis/test/track_status.sh | 23 |
5 files changed, 49 insertions, 44 deletions
diff --git a/.travis/test.sh b/.travis/test.sh index d48d3f5..83c4efa 100755 --- a/.travis/test.sh +++ b/.travis/test.sh @@ -1,13 +1,23 @@ #!/usr/bin/env bash -# Copyright (c) 2019 Egor Tensin <Egor.Tensin@gmail.com> +# Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com> # This file is part of the "VK scripts" project. # For details, see https://github.com/egor-tensin/vk-scripts. # Distributed under the MIT License. -set -o xtrace +set -o errexit -o nounset -o pipefail -./.travis/test/mutual_friends.sh -./.travis/test/show_status.sh -./.travis/test/track_status.sh -./.travis/test/online_sessions.sh +run_test() { + local arg + echo + echo ====================================================================== + for arg; do + echo -n "$arg " + done + echo + echo ====================================================================== + + python3 -m "$@" +} + +run_test "$@" diff --git a/.travis/test/mutual_friends.sh b/.travis/test/mutual_friends.sh index ebe0c17..ebecf8e 100755 --- a/.travis/test/mutual_friends.sh +++ b/.travis/test/mutual_friends.sh @@ -7,15 +7,13 @@ set -o errexit -o nounset -o pipefail -mutual_friends() { - echo 'Running mutual_friends.py --format csv...' - python3 -m bin.mutual_friends --format csv "$@" - echo 'Running mutual_friends.py --format json...' - python3 -m bin.mutual_friends --format json "$@" +test_users() { + ./.travis/test.sh bin.mutual_friends --format csv "$@" + ./.travis/test.sh bin.mutual_friends --format json "$@" } main() { - mutual_friends kreed58 maxkorzh_official + test_users kreed58 maxkorzh_official } main "$@" diff --git a/.travis/test/online_sessions.sh b/.travis/test/online_sessions.sh index b8a56de..7d26630 100755 --- a/.travis/test/online_sessions.sh +++ b/.travis/test/online_sessions.sh @@ -9,14 +9,7 @@ set -o errexit -o nounset -o pipefail readonly db_path='.travis/test_db.csv' -fix_matplotlib() { - # Get rid of: - # tkinter.TclError: no display name and no $DISPLAY environment variable - mkdir -p -- ~/.config/matplotlib - echo 'backend: Agg' > ~/.config/matplotlib/matplotlibrc -} - -_online_sessions() { +try_output() { local output_path output_path="$( mktemp --dry-run )" @@ -25,8 +18,7 @@ _online_sessions() { trap "$rm_aux_files" RETURN - echo "Running online_sessions.py..." - python3 -m bin.online_sessions "$@" "$db_path" "$output_path" + ./.travis/test.sh bin.online_sessions "$@" "$db_path" "$output_path" if file --brief --dereference --mime -- "$output_path" | grep --quiet -- 'charset=binary$'; then echo 'Output is a binary file, not going to show that' @@ -38,13 +30,20 @@ _online_sessions() { } online_sessions() { - _online_sessions --group-by user --output-format csv - _online_sessions --group-by user --output-format json + try_output --group-by user --output-format csv + try_output --group-by user --output-format json - _online_sessions --group-by user --output-format plot - _online_sessions --group-by hour --output-format plot - _online_sessions --group-by date --output-format plot - _online_sessions --group-by weekday --output-format plot + try_output --group-by user --output-format plot + try_output --group-by hour --output-format plot + try_output --group-by date --output-format plot + try_output --group-by weekday --output-format plot +} + +fix_matplotlib() { + # Get rid of: + # tkinter.TclError: no display name and no $DISPLAY environment variable + mkdir -p -- ~/.config/matplotlib + echo 'backend: Agg' > ~/.config/matplotlib/matplotlibrc } main() { diff --git a/.travis/test/show_status.sh b/.travis/test/show_status.sh index afba9aa..ff0ce47 100755 --- a/.travis/test/show_status.sh +++ b/.travis/test/show_status.sh @@ -7,13 +7,12 @@ set -o errexit -o nounset -o pipefail -show_status() { - echo 'Running show_status.py...' - python3 -m bin.show_status "$@" +test_users() { + ./.travis/test.sh bin.show_status "$@" } main() { - show_status egor.tensin + test_users egor.tensin } main "$@" diff --git a/.travis/test/track_status.sh b/.travis/test/track_status.sh index afdfea1..2b3e001 100755 --- a/.travis/test/track_status.sh +++ b/.travis/test/track_status.sh @@ -7,33 +7,32 @@ set -o errexit -o nounset -o pipefail -track_status() { +test_users() { local log_path log_path="$( mktemp )" - echo "Log file path: $log_path" - local db_path db_path="$( mktemp --dry-run )" - echo "DB file path: $db_path" local rm_aux_files rm_aux_files="$( printf -- 'rm -f -- %q %q' "$log_path" "$db_path" )" - trap "$rm_aux_files" RETURN - echo 'Running track_status.py...' - python3 -m bin.track_status "$@" --log "$log_path" --format csv --output "$db_path" & + ./.travis/test.sh bin.track_status "$@" --log "$log_path" --format csv --output "$db_path" & local pid="$!" - echo "Its PID is $pid" - local timeout=15 + sleep 3 + echo "Log file path: $log_path" + echo "DB file path: $db_path" + echo "PID: $pid" + + local timeout=10 echo "Sleeping for $timeout seconds..." sleep "$timeout" echo 'Terminating track_status.py...' - kill -SIGINT "$pid" + kill "$pid" echo 'Waiting for track_status.py to terminate...' - wait "$pid" + wait "$pid" || true echo "Log file:" cat "$log_path" @@ -42,7 +41,7 @@ track_status() { } main() { - track_status egor.tensin + test_users egor.tensin } main "$@" |