File: filter_only_tty.sh

package info (click to toggle)
snoopy 2.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,016 kB
  • sloc: ansic: 7,169; sh: 4,514; makefile: 1,095
file content (45 lines) | stat: -rwxr-xr-x 1,045 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
42
43
44
45
#!/bin/bash



### Configure shell and bootstrap
#
set -e
set -u
. `dirname $BASH_SOURCE`/_bootstrap.sh



### Check if currently running on tty
#
# These do not work correctly:
#   if [[ $- == *i* ]]; then
#   if [ -t 1 ]; then
#
# In $(tty), tty is a program. When test suite is run with -j1, it runs in
# interactive shell. If -j16 is used, then it runs in background.
#
RES="$(tty)" || RES="not-on-tty"   # This || is here to compensate for non-zero exit status.
if [[ $RES == /dev/* ]]; then
    ON_TTY="true"
else
    ON_TTY="false"
fi



### Execute on-tty-dependent check
#
if [ "$ON_TTY" == "true" ]; then
    if $SNOOPY_TEST_CLI run filter   "only_tty" > /dev/null; then
        snoopy_testResult_pass
    else
        snoopy_testResult_fail "only_tty check failed (test is running on an interactive tty)"
    fi
else
    if ! $SNOOPY_TEST_CLI run filter   "only_tty" > /dev/null; then
        snoopy_testResult_pass
    else
        snoopy_testResult_fail "only_tty check failed (test is NOT running on an interactive tty)"
    fi
fi