Work around missing MPD with a more elaborate pysawsim nosetest hook.
authorW. Trevor King <wking@drexel.edu>
Wed, 20 Oct 2010 19:23:16 +0000 (15:23 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 20 Oct 2010 19:23:16 +0000 (15:23 -0400)
misc/hooks/README
misc/hooks/pre-commit-pysawsim-check [new file with mode: 0755]
pysawsim/manager/mpi.py

index 801e4799c94b9a7561c632e692493fb28a4ca773..d86fa9fccabc1d96a55aaea219d8fce37f2ccf40 100644 (file)
@@ -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
 </file>
diff --git a/misc/hooks/pre-commit-pysawsim-check b/misc/hooks/pre-commit-pysawsim-check
new file mode 100755 (executable)
index 0000000..66a409d
--- /dev/null
@@ -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
index d99f4156dd13464f5c54130717fee922e8182f2a..0f1b0f841659cf647c386ded8967b39134bef74a 100644 (file)
@@ -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