From bb2f4c1189e49508f7ce31e9bbd9f09efedad0ec Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 20 Oct 2010 15:23:16 -0400 Subject: [PATCH] Work around missing MPD with a more elaborate pysawsim nosetest hook. --- misc/hooks/README | 2 +- misc/hooks/pre-commit-pysawsim-check | 26 ++++++++++++++++++++++++++ pysawsim/manager/mpi.py | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100755 misc/hooks/pre-commit-pysawsim-check 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 -- 2.26.2