]> git.notmuchmail.org Git - notmuch/blobdiff - test/test-lib.sh
test: fix passwd_sanitize()
[notmuch] / test / test-lib.sh
index fc176af8db153c35fe5b6483f0d2dd7494b79c91..e13797a75a358b458c52c10332f672fcd6265337 100644 (file)
@@ -104,9 +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
+
 add_gnupg_home ()
 {
     [ -e "${GNUPGHOME}/gpg.conf" ] && return
@@ -694,6 +700,27 @@ notmuch_built_with_sanitize ()
     sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/'
 }
 
+notmuch_passwd_sanitize()
+{
+    ${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.getfqdn()
+
+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 ()
 {
     notmuch_dir_sanitize | notmuch_built_with_sanitize
@@ -1117,7 +1144,7 @@ notmuch_with_shim () {
     base_name="$1"
     shift
     shim_file="${base_name}.so"
-    LD_PRELOAD=./${shim_file}${LD_PRELOAD:+:$LD_PRELOAD} notmuch-shared "$@"
+    LD_PRELOAD=${LD_PRELOAD:+:$LD_PRELOAD}:./${shim_file} notmuch-shared "$@"
 }
 
 # Creates a script that counts how much time it is executed and calls