← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3707: various fixes and improvements in checkTests

 

------------------------------------------------------------
revno: 3707
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
timestamp: Thu 2013-08-29 12:30:31 +0200
message:
  various fixes and improvements in checkTests
modified:
  scripts/checks-and-tests/checks/README
  scripts/checks-and-tests/checks/checkGravity.py
  scripts/checks-and-tests/checks/checkList.py
  scripts/checks-and-tests/checks/checkTestDummy.py
  scripts/checks-and-tests/checks/checkTestTriax.py
  scripts/checks-and-tests/checks/checkWirePM.py


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'scripts/checks-and-tests/checks/README'
--- scripts/checks-and-tests/checks/README	2012-03-13 09:51:32 +0000
+++ scripts/checks-and-tests/checks/README	2013-08-29 10:30:31 +0000
@@ -15,3 +15,5 @@
 7. Users are encouraged to add their own scripts into the scripts/test/checks/ folder. Discussion of some specific checktests design in users question is welcome.
 
 8. A check test should never need more than a few seconds to run. If your typical script needs more, try and reduce the number of element or the number of steps.
+
+9. Failures are reported via a global variable "resultStatus", which should be ONLY INCREMENTED in a checkTests, never assigned to (resultStatus+=1 is ok, resultStatus=1 is bad), else the script would erase the history of the checkTests coming before it.

=== modified file 'scripts/checks-and-tests/checks/checkGravity.py'
--- scripts/checks-and-tests/checks/checkGravity.py	2012-03-13 09:51:32 +0000
+++ scripts/checks-and-tests/checks/checkGravity.py	2013-08-29 10:30:31 +0000
@@ -69,8 +69,6 @@
 def getCurrentVel(inVel=0):
   t = O.time+O.dt
   return inVel + g*t
-  
-resultStatus=0
 
 def warningMessagePos(inVel, y_pos, y_pos_need):
   print "The body with the initial velocity %.3f, has an y-position %.3f, but it should be %.3f" % (inVel, y_pos, y_pos_need)

=== modified file 'scripts/checks-and-tests/checks/checkList.py'
--- scripts/checks-and-tests/checks/checkList.py	2012-03-13 09:51:32 +0000
+++ scripts/checks-and-tests/checks/checkList.py	2013-08-29 10:30:31 +0000
@@ -4,23 +4,25 @@
 
 scriptsToRun=os.listdir(checksPath)
 resultStatus = 0
+nFailed=0
 for script in scriptsToRun:
 	if (script[len(script)-3:]==".py" and not(script=="checkList.py")):
 		try:
 	 		print "###################################"
 			print "running: ",script
 			execfile(checksPath+"/"+script)
-			if (resultStatus):
+			if (resultStatus>nFailed):
 				print "Status: FAILURE!!!"
+				nFailed=resultStatus
 			else:
 				print "Status: success"
 			print "___________________________________"
 		except:
 			print script," failure"
 		O.reset()
-		
-if (resultStatus):
-	print "Some tests are failed!"
+		print 	resultStatus	
+if (resultStatus>0):
+	print resultStatus, " tests are failed"
 	sys.exit(1)
 else:
 	sys.exit(0)

=== modified file 'scripts/checks-and-tests/checks/checkTestDummy.py'
--- scripts/checks-and-tests/checks/checkTestDummy.py	2012-04-13 16:27:00 +0000
+++ scripts/checks-and-tests/checks/checkTestDummy.py	2013-08-29 10:30:31 +0000
@@ -5,3 +5,10 @@
 import math,os,sys
 print 'checkTest mechanism'
 
+#Typical structure of a checkTest:
+
+#do something and get a result...
+
+if 0: #put a condition on the result here, is it the expected result? else:
+	print "Dummy failed (we know it will not happen here, you get the idea)." 
+	resultStatus+=1

=== modified file 'scripts/checks-and-tests/checks/checkTestTriax.py'
--- scripts/checks-and-tests/checks/checkTestTriax.py	2012-04-13 16:27:00 +0000
+++ scripts/checks-and-tests/checks/checkTestTriax.py	2013-08-29 10:30:31 +0000
@@ -24,6 +24,9 @@
 if abs((O.engines[4].stress(1)[0]-50058.7)/50058.7)>tolerance :
 	print "Triaxial checkTest: difference on confining stress"
 	errors+=1
+	
+if (errors):
+	resultStatus +=1	#Test is failed
 
 if (errors):
 	resultStatus +=1	#Test is failed

=== modified file 'scripts/checks-and-tests/checks/checkWirePM.py'
--- scripts/checks-and-tests/checks/checkWirePM.py	2013-06-25 03:07:32 +0000
+++ scripts/checks-and-tests/checks/checkWirePM.py	2013-08-29 10:30:31 +0000
@@ -3,7 +3,6 @@
 # Check test version for WirePM tensile test
 
 tolerance=0.01
-resultStatus=0
 errors=0
 
 #### define parameters for the net