File: btest-ask-update

package info (click to toggle)
btest 0.72-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,208 kB
  • sloc: python: 2,187; sh: 547; makefile: 165; xml: 12; awk: 1
file content (41 lines) | stat: -rwxr-xr-x 1,145 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/env bash
#
# Helper script that asks whether the user wants to update a baseline.
#
# Return code:
#
# 0: Yes, update and continue.
# 1: No, don't update but continue.
# 200: No, don't update and abort.

while true; do
    printf "\033[0K" >>/dev/tty # Delete any augmented output.
    echo " failed" >>/dev/tty
    echo ">> Type 'c' to continue, 'd' to see diagnostics, 'u' to update baseline, and 'a' to abort." >/dev/tty

    read -r -s -n 1 key </dev/tty

    case $key in
        [uU])
            echo ">> Updating baseline ..." >/dev/tty
            exit 0
            ;;
        [cC])
            echo ">> Continuing ..." >/dev/tty
            exit 1
            ;;
        [aA])
            echo ">> Aborting ..." >/dev/tty
            exit 200
            ;;

        [dD])
            if [ "$TEST_DIAGNOSTICS" != "" ] && [ "$TEST_DIAGNOSTICS" != "/dev/stdout" ]; then
                less -S "$TEST_DIAGNOSTICS" </dev/tty >/dev/tty
            else
                echo "Do not have diagnostics." >/dev/tty
            fi
            ;;
        *) echo ">> Answer not recognized, try again ..." >/dev/tty ;;
    esac
done