dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git

testsuite.sh (1227B)


      1 #!/bin/sh
      2 
      3 MOD="" # CTRL+g
      4 ESC="" # \e
      5 DVTM="./dvtm"
      6 export DVTM_EDITOR="vis"
      7 LOG="dvtm.log"
      8 TEST_LOG="$0.log"
      9 UTF8_TEST_URL="http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt"
     10 
     11 [ ! -z "$1" ] && DVTM="$1"
     12 [ ! -x "$DVTM" ] && echo "usage: $0 path-to-dvtm-binary" && exit 1
     13 
     14 dvtm_input() {
     15 	printf "$1"
     16 }
     17 
     18 dvtm_cmd() {
     19 	printf "${MOD}$1"
     20 	sleep 1
     21 }
     22 
     23 sh_cmd() {
     24 	printf "$1\n"
     25 	sleep 1
     26 }
     27 
     28 test_copymode() { # requires wget, diff, vis
     29 	local FILENAME="UTF-8-demo.txt"
     30 	local COPY="$FILENAME.copy"
     31 	[ ! -e "$FILENAME" ] && (wget "$UTF8_TEST_URL" -O "$FILENAME" > /dev/null 2>&1 || return 1)
     32 	sleep 1
     33 	sh_cmd "cat $FILENAME"
     34 	dvtm_cmd 'e'
     35 	dvtm_input "?UTF-8 encoded\n"
     36 	dvtm_input '^kvG1k$'
     37 	dvtm_input ":wq!\n"
     38 	sleep 1
     39 	sh_cmd "cat <<'EOF' > $COPY"
     40 	dvtm_cmd 'p'
     41 	sh_cmd 'EOF'
     42 	while [ ! -r "$COPY" ]; do sleep 1; done;
     43 	dvtm_input "exit\n"
     44 	diff -u "$FILENAME" "$COPY" 1>&2
     45 	local RESULT=$?
     46 	rm -f "$COPY"
     47 	return $RESULT
     48 }
     49 
     50 if ! which vis > /dev/null 2>&1 ; then
     51 	echo "vis not found, skiping copymode test"
     52 	exit 0
     53 fi
     54 
     55 {
     56 	echo "Testing $DVTM" 1>&2
     57 	$DVTM -v 1>&2
     58 	test_copymode && echo "copymode: OK" 1>&2 || echo "copymode: FAIL" 1>&2;
     59 } 2> "$TEST_LOG" | $DVTM -m ^g 2> $LOG
     60 
     61 cat "$TEST_LOG" && rm "$TEST_LOG" $LOG