Commit f2a77e1b authored by Denis Bilenko's avatar Denis Bilenko

record_results.py: run the test without recording if sqlite3 is not available

parent 7fe3dc91
...@@ -31,7 +31,11 @@ from os.path import abspath, dirname, join, split ...@@ -31,7 +31,11 @@ from os.path import abspath, dirname, join, split
try: try:
import sqlite3 import sqlite3
except ImportError: except ImportError:
try:
import pysqlite2.dbapi2 as sqlite3 import pysqlite2.dbapi2 as sqlite3
except ImportError:
sqlite3 = None
print "sqlite3 not installed, won't record the results in the database"
import warnings import warnings
from greentest import disabled_marker from greentest import disabled_marker
...@@ -46,7 +50,16 @@ def get_results_db(): ...@@ -46,7 +50,16 @@ def get_results_db():
pass pass
return join(path, 'results.db') return join(path, 'results.db')
def record(argv, output, returncode): if sqlite3 is None:
def record(argv, output, returncode):
print output
print 'returncode=%s' % returncode
else:
def record(argv, output, returncode):
print "saving %s bytes of output; returncode=%s" % (len(output), returncode)
path = get_results_db() path = get_results_db()
c = sqlite3.connect(path) c = sqlite3.connect(path)
c.execute('''create table if not exists testresult c.execute('''create table if not exists testresult
...@@ -69,7 +82,6 @@ def main(): ...@@ -69,7 +82,6 @@ def main():
print arg print arg
p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
returncode = p.wait() returncode = p.wait()
print arg, 'finished with code', returncode
output = p.stdout.read() output = p.stdout.read()
if not debug: if not debug:
if returncode==1: if returncode==1:
...@@ -77,7 +89,6 @@ def main(): ...@@ -77,7 +89,6 @@ def main():
elif returncode==8 and disabled_marker in output: elif returncode==8 and disabled_marker in output:
pass pass
else: else:
print "saving %s bytes of output" % len(output)
record(argv, output, returncode) record(argv, output, returncode)
sys.exit(returncode) sys.exit(returncode)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment