title: How do I detect if the test run was successful in a Team Build 2013 Post-Test script?
body: <p>I have a build configuration in TFS 2013 that produces versioned build artifacts. This build uses the out of the box process template workflow. I want to destroy the build artifacts in the event that unit tests fail leaving only the log files. I have a Post-Test powershell script. How do I detect the test failure in this script?</p>
  
  <p>Here is the relevant cleanup method in my post-test script:</p>
  
  <pre><code>function Clean-Files($dir){
      if (Test-Path -path $dir) { rmdir $dir\* -recurse -force -exclude logs,"$NewVersion" }
      if(0 -eq 1) { rmdir $dir\* -recurse -force -exclude logs }
  }
  Clean-Files "$Env:TF_BUILD_BINARIESDIRECTORY\"
  </code></pre>
  
  <p>How do I tests for test success in the function?</p>