File: test-ls

package info (click to toggle)
nmh 1.6-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,204 kB
  • ctags: 3,851
  • sloc: ansic: 48,922; sh: 16,422; makefile: 559; perl: 509; lex: 402; awk: 74
file content (88 lines) | stat: -rwxr-xr-x 1,884 bytes parent folder | download | duplicates (7)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
######################################################
#
# Test that whatnow's "ls" copes with directory names
# which have spaces and quotes in them (see bug #23319)
#
######################################################

set -e

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname "$0"`/../..
    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
fi

. "$MH_OBJ_DIR/test/common.sh"

setup_test

if dpkg-architecture -earmel || dpkg-architecture -earmhf; then
    test_skip "This test mysteriously fails on ARM boxes, skipping".
fi

# Set TERM to get consistent output.
TERM=dumb; export TERM

SPDIR="$MH_TEST_DIR/foo's bar"
rm -rf "$SPDIR"
mkdir "$SPDIR"
cd "$SPDIR"
touch baz boz

expectederr=$MH_TEST_DIR/$$.expectederr
actualerr=$MH_TEST_DIR/$$.actualerr
expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual

#
# Handle different output depending on readline version
#

set +e
whatnowtest=`echo cd | whatnow -prompt ''`
set -e

case ${whatnowtest} in
    cd) cat > "$expected" <<EOF
baz
boz
ls
EOF
    ;;
    "") cat > "$expected" <<EOF
baz
boz
EOF
    ;;
    *) echo "Unknown response to whatnow readline test"
    echo "Response is: ${whatnowtest}"
    exit 1
    ;;
esac

cat > $expectederr <<EOF
EOF

# NB use of sort as the order of output of ls is not guaranteed
echo 'ls' | run_prog whatnow -noedit -prompt '' 2> "$actualerr" | \
	sort > "$actual"

check "$expectederr" "$actualerr" 'keep first'
check "$expected" "$actual" 'keep first'

# Check with SHELL unset.  This won't reveal any problems if
# /bin/sh sets SHELL, which bash does.
unset SHELL

echo 'ls' | run_prog whatnow -noedit -prompt '' 2> "$actualerr" | \
	sort > "$actual"

check "$expectederr" "$actualerr"
check "$expected" "$actual"

# On some platforms, need to be out of $SPDIR in order to remove it.
cd "$MH_TEST_DIR"
test ${failed:-0} -eq 0  &&  rm -r "$SPDIR"

exit $failed