From: W. Trevor King Date: Wed, 20 Oct 2010 19:23:16 +0000 (-0400) Subject: Work around missing MPD with a more elaborate pysawsim nosetest hook. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bb2f4c1189e49508f7ce31e9bbd9f09efedad0ec;p=sawsim.git Work around missing MPD with a more elaborate pysawsim nosetest hook. --- diff --git a/misc/hooks/README b/misc/hooks/README index 801e479..d86fa9f 100644 --- a/misc/hooks/README +++ b/misc/hooks/README @@ -8,5 +8,5 @@ See the `Git Community Book`_ for details. #!/bin/sh ./misc/hooks/pre-commit-diff-check || exit 1 # check patch formatting make check || exit 1 # check sawsim execution -nosetests --with-doctest --doctest-tests pysawsim || exit 1 +./misc/hooks/pre-commit-pysawsim-check || exit 1 diff --git a/misc/hooks/pre-commit-pysawsim-check b/misc/hooks/pre-commit-pysawsim-check new file mode 100755 index 0000000..66a409d --- /dev/null +++ b/misc/hooks/pre-commit-pysawsim-check @@ -0,0 +1,26 @@ +#!/bin/sh + +HAS_MPD=$(which mpdallexit 2>/dev/null) + +if [ -n "$HAS_MPD" ]; then + + LOCAL_MPD='' + + mpdtrace >/dev/null 2>&1 + if [ "$?" != 0 ]; then + LOCAL_MPD='1' + mpd & # start an mpd instance + sleep 1 # give mpd some time to start up + fi # otherwise there is an mpd instance already running + + mpiexec -n 1 nosetests --with-doctest --doctest-tests pysawsim || exit 1 + + if [ -n "$LOCAL_MPD" ]; then + mpdallexit + fi + +else # no MPD + + nosetests --with-doctest --doctest-tests pysawsim || exit 1 + +fi diff --git a/pysawsim/manager/mpi.py b/pysawsim/manager/mpi.py index d99f415..0f1b0f8 100644 --- a/pysawsim/manager/mpi.py +++ b/pysawsim/manager/mpi.py @@ -207,7 +207,7 @@ class MPIManager (ThreadManager): ]) if worker_pool == None: worker_pool = MPI.COMM_WORLD.Get_size() - comm = MPI.COMM_SELF.Spawn( + comm = MPI.COMM_SELF.Spawn( # locks with mpich2 if no mpd running sys.executable, args=['-c', spawn_script], maxprocs=worker_pool) rank = comm.Get_rank() assert rank == 0, rank