Index: Jenkinsfile
===================================================================
--- Jenkinsfile	(revision 7f8b7409e1e8dfb7ac736a0639e9ce936ae60b78)
+++ Jenkinsfile	(revision 76c5d6efe4fe6508f86076308dba66cf251718e6)
@@ -1,26 +1,64 @@
 
 
-//checkout the source code and clean the repo
-stage 'Checkout'
-node {
-	checkout scm
-	sh 'git clean -dfq'
-}
+node ('master'){
 
+	def err = null
+	def stage_name
+	def log_needed = false
+	currentBuild.result = "SUCCESS"
 
-stage 'Build'
-node ('master'){
 	try {
-		//configure the conpilation
-		//Don't remove outputs for the clean and configure unless errors are present
-		sh 'make clean > /dev/null'
-		sh 'CC=gcc-4.9 CXX=g++-4.9 ./configure > /dev/null'
-		sh 'make -j 8'
-		email("SUCCESS", false)
 
-	//something happen, this build is a failure
-	} catch (Exception e) {
-		email("FAILURE", true)
-		throw e;
+		stage 'Checkout'
+
+			//checkout the source code and clean the repo
+			checkout scm
+			sh 'git clean -dfq'
+
+		stage 'Build'
+
+			stage_name = 'Build'
+
+			//configure the conpilation
+			//Don't remove outputs for the clean and configure unless errors are present
+			sh 'make clean > /dev/null'
+			sh 'CC=gcc-4.9 CXX=g++-4.9 ./configure > /dev/null'
+			sh 'make -j 8'
+
+		stage 'Test'
+
+			stage_name = 'Test'
+
+			dir ('src/examples') {
+				sh './runTests.sh'
+			}
+
+		stage 'Cleanup'
+
+			email("SUCCESS", false)
+	}
+
+	catch (Exception caughtError) {
+		err = caughtError
+		log_needed = false
+		currentBuild.result = "FAILURE"
+
+		switch(stage_name) {
+			case 'Test' :
+				currentBuild.result = "TEST FAILURE"
+				break
+			default :
+				break
+		}
+	}
+
+	finally {
+		//Send email with final results
+		email(currentBuild.result, log_needed)
+
+		/* Must re-throw exception to propagate error */
+		if (err) {
+			throw err
+		}
 	}
 }
Index: src/examples/runTests.sh
===================================================================
--- src/examples/runTests.sh	(revision 7f8b7409e1e8dfb7ac736a0639e9ce936ae60b78)
+++ src/examples/runTests.sh	(revision 76c5d6efe4fe6508f86076308dba66cf251718e6)
@@ -36,4 +36,6 @@
 make clean > /dev/null 2>&1
 
+ret_val=0
+
 for test in $tests; do
 	echo -n "    $test" | tee -a $logfile
@@ -41,4 +43,5 @@
 	# build, skipping to next test on error
 	if ! make -j 8 $test > tests/$test.make.txt 2>&1; then
+		ret_val=1
 		echo -e "\tFAILED with build error:" | tee -a $logfile
 		cat tests/$test.make.txt | tee -a $logfile
@@ -50,4 +53,5 @@
 	./$test < tests/$test.in.txt > tests/$test.run.txt 2>&1
 	if ! diff tests/$test.out.txt tests/$test.run.txt > tests/$test.diff.txt; then
+		ret_val=1
 		echo -e "\tFAILED with output mismatch:" | tee -a $logfile
 		cat tests/$test.diff.txt | tee -a $logfile
@@ -58,2 +62,4 @@
 	echo -e "\tPASSED" | tee -a $logfile
 done
+
+exit $((ret_val))
