[hackers] [st] [patch] Differentiate Delete from Meta-Delete (like rxvt-unicode)

2018-09-09 Thread markweston

From 9df9679d84b08602902c6aad3742cf4b57ceadcb Mon Sep 17 00:00:00 2001
From: Mark-Weston 
Date: Sun, 9 Sep 2018 15:34:52 +0300
Subject: [PATCH] Differentiate between Delete and Meta-Delete

---
 config.def.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/config.def.h b/config.def.h
index 82b1b09..071c58e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -266,6 +266,8 @@ static Key key[] = {
{ XK_KP_Delete, ControlMask,"\033[3;5~",+1,0},
{ XK_KP_Delete, ShiftMask,  "\033[2K",  -1,0},
{ XK_KP_Delete, ShiftMask,  "\033[3;2~",+1,0},
+   { XK_KP_Delete, Mod1Mask,   "\033\033[P",   -1,0},
+   { XK_KP_Delete, Mod1Mask,   "\033\033[3~",  +1,0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[P",   -1,0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~",  +1,0},
{ XK_KP_Multiply,   XK_ANY_MOD, "\033Oj",   +2,0},
@@ -334,6 +336,8 @@ static Key key[] = {
{ XK_Delete,ControlMask,"\033[3;5~",+1,0},
{ XK_Delete,ShiftMask,  "\033[2K",  -1,0},
{ XK_Delete,ShiftMask,  "\033[3;2~",+1,0},
+   { XK_Delete,Mod1Mask,   "\033\033[P",   -1,0},
+   { XK_Delete,Mod1Mask,   "\033\033[3~",  +1,0},
{ XK_Delete,XK_ANY_MOD, "\033[P",   -1,0},
{ XK_Delete,XK_ANY_MOD, "\033[3~",  +1,0},
{ XK_BackSpace, XK_NO_MOD,  "\177",  0,0},
--
2.18.0



[hackers][sbase][PATCH] testing: add first shell-based tests

2018-09-09 Thread Silvan Jegen
We add some shell helper functions to test the expected output of sbase
tools. In addition to the helper functions themselves we add some tests
for 'dirname'.
---
Hi

I fixed some of the issues pointed out by Mattias and made the tests
runnable from the Makefile.

Let me know if there is a chance that we can get some shell-based testing
like this into sbase.


 Makefile |  6 +-
 tests/dirname.test   | 20 
 tests/runalltests|  5 +
 tests/test-common.sh | 37 +
 4 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100755 tests/dirname.test
 create mode 100755 tests/runalltests
 create mode 100644 tests/test-common.sh

diff --git a/Makefile b/Makefile
index 0e421e7..9ddd873 100644
--- a/Makefile
+++ b/Makefile
@@ -274,4 +274,8 @@ clean:
rm -f $(BIN) $(OBJ) $(LIB) sbase-box sbase-$(VERSION).tar.gz
rm -f getconf.h
 
-.PHONY: all install uninstall dist sbase-box sbase-box-install 
sbase-box-uninstall clean
+testing:
+   @cd tests/; \
+   ./runalltests
+
+.PHONY: all install uninstall dist sbase-box sbase-box-install 
sbase-box-uninstall clean testing
diff --git a/tests/dirname.test b/tests/dirname.test
new file mode 100755
index 000..3bc45ca
--- /dev/null
+++ b/tests/dirname.test
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+. ./test-common.sh
+
+#"test name"   "command to execute" "expected output"
+check_stdout "dirname-noarg"   "../dirname" "" && \
+check_stderr "dirname-noarg-stderr" "../dirname" "usage: ../dirname path\n" && 
\
+check_stdout "dirname-non-existing" "../dirname a b c" "" && \
+check_stdout "dirname-slash" "../dirname /" "/\n" && \
+check_stdout "dirname-dashes-slash" "../dirname -- /" "/\n" && \
+check_stdout "dirname-dashes-slash-a" "../dirname -- /a" "/\n"  && \
+check_stdout "dirname-doublequotes" "../dirname \"\"" ".\n" && \
+check_stdout "dirname-slashes" "../dirname ///" "/\n" && \
+check_stdout "dirname-a/b" "../dirname a/b" "a\n" && \
+check_stdout "dirname-a/b/" "../dirname a/b/" "a\n" && \
+check_stdout "dirname-a/b//" "../dirname a/b//" "a\n" && \
+check_stdout "dirname-a" "../dirname a" ".\n" && \
+check_stdout "dirname-a/" "../dirname a/" ".\n" && \
+check_stdout "dirname-/a/b/c" "../dirname /a/b/c" "/a/b\n" && \
+check_stdout "dirname-//a/b/c" "../dirname //a/b/c" "//a/b\n"
diff --git a/tests/runalltests b/tests/runalltests
new file mode 100755
index 000..4cf7933
--- /dev/null
+++ b/tests/runalltests
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+for testfile in $(find -name '*.test' -type f); do
+   $testfile
+done
diff --git a/tests/test-common.sh b/tests/test-common.sh
new file mode 100644
index 000..e12fc78
--- /dev/null
+++ b/tests/test-common.sh
@@ -0,0 +1,37 @@
+check_output() {
+   testname=$1
+   cmdtorun=$2
+   expectedOutput=$3
+   usestdout=$4
+   expOutFile=$(mktemp)
+   actualOutFile=$(mktemp)
+   ret=0
+
+   printf "$expectedOutput" > $expOutFile
+   if [ $usestdout -eq 1 ]; then
+   eval $cmdtorun > $actualOutFile 2> /dev/null
+   else
+   eval $cmdtorun 2> $actualOutFile 1> /dev/null
+   fi
+
+   cmp $expOutFile $actualOutFile  2>&1 > /dev/null
+   if [ $? -eq 1 ]; then
+   printf "$testname:\n"
+   printf "\tWanted:\n"
+   cat $expOutFile
+   printf "\n\tGot:\n"
+   cat $actualOutFile
+   ret=1
+   fi
+
+   rm $expOutFile $actualOutFile
+   return $ret
+}
+
+check_stdout() {
+   check_output "$1" "$2" "$3" 1
+}
+
+check_stderr() {
+   check_output "$1" "$2" "$3" 0
+}
-- 
2.18.0