[seed] Stopgap to get around the broken pipe test thing.



commit 1012762ddfae9d6b33c00d7a10bb07201e499814
Author: Tim Horton <hortont hortont com>
Date:   Wed Apr 15 20:51:28 2009 -0400

    Stopgap to get around the broken pipe test thing.
---
 tests/run-tests.py |   61 +++++++++++++++++++++++++++------------------------
 1 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/tests/run-tests.py b/tests/run-tests.py
index 85a52dd..5eab1af 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -17,39 +17,42 @@ mcwd = os.getcwd()
 
 for f in os.listdir("javascript"):
 	if f.endswith(".js") and not f.endswith("_.js"):
-		rfile = open(mcwd + "/javascript/"+f, "r")
-		test_code = rfile.readlines()
-		test_retval = int(test_code[1].replace("// Returns:","").rstrip().replace("\\n","\n"));
-		test_in = test_code[2].replace("// STDIN:","").rstrip().replace("\\n","\n");
-		test_out = "^" + test_code[3].replace("// STDOUT:","").rstrip().replace("\\n","\n") + "$";
-		test_err = "^" + test_code[4].replace("// STDERR:","").rstrip().replace("\\n","\n") + "$";
+		try:
+			rfile = open(mcwd + "/javascript/"+f, "r")
+			test_code = rfile.readlines()
+			test_retval = int(test_code[1].replace("// Returns:","").rstrip().replace("\\n","\n"));
+			test_in = test_code[2].replace("// STDIN:","").rstrip().replace("\\n","\n");
+			test_out = "^" + test_code[3].replace("// STDOUT:","").rstrip().replace("\\n","\n") + "$";
+			test_err = "^" + test_code[4].replace("// STDERR:","").rstrip().replace("\\n","\n") + "$";
 		
-		p = subprocess.Popen(mcwd + "/javascript/" + f, shell=True,
-							 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
-							 stderr=subprocess.PIPE, close_fds=True,
-							 cwd=mcwd+"/javascript/")
-		(out,err)=(p.stdout, p.stderr)
+			p = subprocess.Popen(mcwd + "/javascript/" + f, shell=True,
+								 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+								 stderr=subprocess.PIPE, close_fds=True,
+								 cwd=mcwd+"/javascript/")
+			(out,err)=(p.stdout, p.stderr)
 		
-		(run_out,run_err)=p.communicate(test_in + "\004")
-		run_out = run_out.rstrip()
-		run_err = run_err.rstrip()
+			(run_out,run_err)=p.communicate(test_in + "\004")
+			run_out = run_out.rstrip()
+			run_err = run_err.rstrip()
 		
-		out.close()
-		err.close()
+			out.close()
+			err.close()
 	
-		if not re.match(test_out,run_out):
-			failed.append([f,test_out,run_out,0,run_err])
-			sys.stdout.write("x")
-		elif not re.match(test_err,run_err):
-			failed.append([f,test_err,run_err,1])
-			sys.stdout.write("x")
-		elif p.returncode != test_retval:
-			failed.append([f,test_retval,p.returncode,2]);
-			sys.stdout.write("x")
-		else:
-			passed.append([f])
-			sys.stdout.write(".")
-		sys.stdout.flush()
+			if not re.match(test_out,run_out):
+				failed.append([f,test_out,run_out,0,run_err])
+				sys.stdout.write("x")
+			elif not re.match(test_err,run_err):
+				failed.append([f,test_err,run_err,1])
+				sys.stdout.write("x")
+			elif p.returncode != test_retval:
+				failed.append([f,test_retval,p.returncode,2]);
+				sys.stdout.write("x")
+			else:
+				passed.append([f])
+				sys.stdout.write(".")
+			sys.stdout.flush()
+		except:
+			print "WARNING: Strange error in " + f + "\n\n"
 
 p = subprocess.Popen(mcwd + "/c/test", shell=True,
 					 stdin=subprocess.PIPE, stdout=subprocess.PIPE,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]