[PATCH 0/9] test: (hopefully) better test prerequisites

Tomi Ollila tomi.ollila at iki.fi
Thu Nov 17 04:20:19 PST 2011


On Thu, 17 Nov 2011 01:14:07 -0800, Jameson Graef Rollins <jrollins at finestructure.net> wrote:
> 
> However, when I tried to test the tests with the patch applied I ran
> into one problem.  If I try to run the test suite with dtach
> uninstalled, it looks like I'm experiencing a hang on
> emacs_deliver_message call.  I wonder if either emacs_deliver_message or
> test_emacs is not doing the right thing in the case of no dtach.  I
> think emacs_deliver_message should somehow not require dtach, since it's
> not actually testing any display stuff, but because it's currently using
> test_emacs, it is somehow implicitly depending on it.  Any thoughts on
> how to fix that?

Quick thought

mk_skip_test_emacs () 
{ test_emacs () 
  { 
	echo SKIPPED
        false
  }
  test_emacs
}

mk_run_test_emacs () 
{ test_emacs () 
  {
	emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"
  }
  test_emacs
}

test_emacs ()
{
        which dtach >/dev/null 2>&1 || { mk_skip_test_emacs; return; }
        which emacs >/dev/null 2>&1 || { mk_skip_test_emacs; return; }
        which emacsclient >/dev/null 2>&1 || { mk_skip_test_emacs; return; }

        EMACS_SERVER="notmuch-test-suite-$$"
	# start a detached session with an emacs server
	# user's TERM is given to dtach which assumes a minimally
	# VT100-compatible terminal -- and emacs inherits that
	TERM=$ORIGINAL_TERM dtach -n "$TMP_DIRECTORY/emacs-dtach-socket.$$" \
		sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \
			--no-window-system \
			--eval '(setq server-name \"$EMACS_SERVER\")' \
			--eval '(server-start)' \
			--eval '(orphan-watchdog $$)'" ||
                        { mk_skip_test_emacs; return; }
	# wait until the emacs server is up
        for _ in 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 20 1 2 3 4 5 6 7 8 9 30
        do 
        	if test_emacs '()' 2>/dev/null
                then
                        mk_run_test_emacs
                        return
                fi
        done
        mk_skip_test_emacs
}

I.e. dynamically, at run-time, re-create test_emacs function...

> 
> jamie.

Tomi


More information about the notmuch mailing list