testing: write profiles on failure

Fixes #7901.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/90930044
diff --git a/doc/go1.3.html b/doc/go1.3.html
index 62a5c0e..60effb2 100644
--- a/doc/go1.3.html
+++ b/doc/go1.3.html
@@ -439,6 +439,7 @@
 <li>
 The <a href="/pkg/testing/"><code>testing</code></a> package now
 diagnoses tests that call <code>panic(nil)</code>, which are almost always erroneous.
+Also, tests now write profiles (if invoked with profiling flags) even on failure.
 </li>
 
 <li>
diff --git a/src/pkg/testing/testing.go b/src/pkg/testing/testing.go
index 2e6d555..8078ba7 100644
--- a/src/pkg/testing/testing.go
+++ b/src/pkg/testing/testing.go
@@ -437,6 +437,7 @@
 	stopAlarm()
 	if !testOk || !exampleOk {
 		fmt.Println("FAIL")
+		after()
 		os.Exit(1)
 	}
 	fmt.Println("PASS")