]> git.notmuchmail.org Git - notmuch/blobdiff - test/test-lib.sh
test: fix wrong SKIP messages
[notmuch] / test / test-lib.sh
index 098d69da347cffc689cb986761421f3ad2444250..1067316dbb3f2b9ad1fd8c65d52cf3d9c3ca916a 100644 (file)
@@ -104,11 +104,15 @@ unset CDPATH
 
 unset GREP_OPTIONS
 
+# For lib/open.cc:_load_key_file
+unset XDG_CONFIG_HOME
+
 # For emacsclient
 unset ALTERNATE_EDITOR
 
 # for reproducibility
 unset EMAIL
+unset NAME
 
 add_gnupg_home ()
 {
@@ -697,12 +701,25 @@ notmuch_built_with_sanitize ()
     sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'
 }
 
-notmuch_passwd_sanitize ()
+notmuch_passwd_sanitize()
 {
-    local user=$(id -un)
-    local fqdn=$(hostname -f)
-    local full_name=$(getent passwd $user | cut -d: -f 5 | cut -d, -f1)
-    sed -e "s/$user/USERNAME/" -e "s/$fqdn/FQDN/" -e "s/$full_name/USER_FULL_NAME/"
+    ${NOTMUCH_PYTHON} -c'
+import os, sys, pwd, socket
+
+pw = pwd.getpwuid(os.getuid())
+user = pw.pw_name
+name = pw.pw_gecos.partition(",")[0]
+fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0, socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
+
+for l in sys.stdin:
+    if user:
+        l = l.replace(user, "USERNAME")
+    if fqdn:
+        l = l.replace(fqdn, "FQDN").replace(".(none)","")
+    if name:
+        l = l.replace(name, "USER_FULL_NAME")
+    sys.stdout.write(l)
+'
 }
 
 notmuch_config_sanitize ()
@@ -902,7 +919,7 @@ test_expect_success () {
                test_run_ "$1"
                run_ret="$?"
                # test_run_ may update missing external prerequisites
-               test_check_missing_external_prereqs_ "$@" ||
+               test_check_missing_external_prereqs_ "$test_subtest_name" ||
                if [ "$run_ret" = 0 -a "$eval_ret" = 0 ]
                then
                        test_ok_
@@ -926,7 +943,7 @@ test_expect_code () {
                test_run_ "$2"
                run_ret="$?"
                # test_run_ may update missing external prerequisites,
-               test_check_missing_external_prereqs_ "$@" ||
+               test_check_missing_external_prereqs_ "$test_subtest_name" ||
                if [ "$run_ret" = 0 -a "$eval_ret" = "$1" ]
                then
                        test_ok_