title: Start server, run tests, stop server
body: <p>I have a Makefile target that looks like the following</p>
  
  <pre><code>integration-test: git-hooks
      java -Djava.library.path=$$(pwd)/test/integration/lib/DynamoDBLocal_lib \
          -Djava.util.logging.config.file=/dev/null \
          -Dorg.eclipse.jetty.LEVEL=WARN \
          -Dlog4j.com.amazonaws.services.dynamodbv2.local.server.LocalDynamoDBServerHandler=OFF \
          -jar $$(pwd)/test/integration/lib/DynamoDBLocal.jar \
          -inMemory \
          -port 8000 &amp;
      sleep 3
      ./node_modules/.bin/mocha --compilers coffee:coffee-script/register \
          --reporter spec \
          test/integration/main.coffee
      ps -ef | grep [D]ynamoDBLocal_lib | awk '{print $$2}' | xargs kill
  </code></pre>
  
  <p>Here's what I'm doing: </p>
  
  <ul>
  <li>the Java command starts a local instance of Amazon's DynamoDB.</li>
  <li>I give it 3 seconds to start</li>
  <li>I run my integration tests</li>
  <li>I kill the database</li>
  </ul>
  
  <p>What I would like is kill the database regardless of the fact that the tests passed or not.
  To do that I suppose I need the exit status of the test command and return that, both if the tests fails or if they succeeded.</p>
  
  <p>What is happening is that if tests pass the database is correctly killed, if the tests fail it's not.</p>
  
  <p>I've read <a href="https://www.gnu.org/software/make/manual/html_node/Errors.html#Errors" rel="nofollow">in the docs</a> that you can prepend a <code>-</code> in front a command to have <code>make</code> ignore it if it produce a non zero exit status, the problem if I do that is that I don't know if the tests failed or not, since <code>$?</code> will always return 0.</p>
  
  <p>What's the usual practice in this scenario? I'm fine in splitting the target in more targets if that solves my issue.</p>
  
  <p>Thank you.</p>