diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2012-11-25 13:04:38 -0800 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2012-11-25 13:04:38 -0800 |
commit | d4a7a216d99df8b3d9bfdc5436e768a8c1fab5ca (patch) | |
tree | 4f2d6bf71f757f70eab5da97088383cc824aaafc | |
parent | 147b7f7a2672c6ccee97f662f089e48682653952 (diff) |
Actually creating a run in the database
A couple fields are placeholders for now, but meh :)
-rw-r--r-- | framework/database.py | 56 | ||||
-rwxr-xr-x | programs/run.py | 17 |
2 files changed, 42 insertions, 31 deletions
diff --git a/framework/database.py b/framework/database.py index 9ab2983..b441ad5 100644 --- a/framework/database.py +++ b/framework/database.py @@ -22,33 +22,39 @@ # import apsw import sys +import time import os.path as path import xdg.BaseDirectory as xdg -__all__ = ['load'] +__all__ = ['ResultDatabase'] -def load(config): - '''Load the results database, creating it if it doesn't exist. - - Will exit the program if it fails.''' - try: - connection = apsw.Connection(config['options']['database']) - cursor = connection.cursor() +class ResultDatabase: + def __init__(self, config): + '''Load the results database, creating it if it doesn't exist. - cursor.execute('''CREATE TABLE IF NOT EXISTS runs - (date INTEGER, - name TEXT, - driver TEXT, - sysinfo TEXT)''') - cursor.execute('''CREATE TABLE IF NOT EXISTS results - (run_id INTEGER, - test_name TEXT, - command TEXT, - result TEXT, - return_code INTEGER, - errors TEXT, - output TEXT)''') - return cursor - except OSError as e: - print('error: could not open results database', str(e), '\n') - sys.exit(0) + Will exit the program if it fails.''' + try: + self.connection = apsw.Connection(config['options']['database']) + cursor = self.connection.cursor() + + cursor.execute('''CREATE TABLE IF NOT EXISTS runs + (date INTEGER PRIMARY KEY, + name TEXT, + driver TEXT, + sysinfo TEXT)''') + cursor.execute('''CREATE TABLE IF NOT EXISTS results + (run_id INTEGER, + test_name TEXT, + command TEXT, + result TEXT, + return_code INTEGER, + errors TEXT, + output TEXT)''') + except OSError as e: + print('error: could not open results database', str(e), '\n') + sys.exit(0) + + def createRun(self, name, driver, sysinfo): + cursor = self.connection.cursor() + date = int(time.time()) + cursor.execute('INSERT INTO runs values(?,?,?,?)', (date, name, driver, sysinfo)) diff --git a/programs/run.py b/programs/run.py index 4d542f7..b92b91d 100755 --- a/programs/run.py +++ b/programs/run.py @@ -31,7 +31,7 @@ import os import os.path as path import sys -import framework.database +from framework.database import ResultDatabase import suites def parseArguments(argv, config): @@ -57,6 +57,7 @@ def parseArguments(argv, config): p.add_argument('-r', '--results', action='store', dest='database', metavar='<results database>', help='Specify an alternate result database (defaults to ~/.local/share/robyn/results.db))') + p.add_argument('name', metavar='<name of test run>') p.add_argument('suites', nargs='+') options = p.parse_args(argv) @@ -68,14 +69,18 @@ def parseArguments(argv, config): return options def main(argv, config): - options = parseArguments(argv, config) - framework.database.load(config) - tests = suites.loadTestLists(config, options.suites) + args = parseArguments(argv, config) - for test in sorted(tests['oglconform'].keys()): - print(test) + tests = suites.loadTestLists(config, args.suites) + + #for test in sorted(tests['oglconform'].keys()): + #print(test) + + db = ResultDatabase(config) # Create test run in database + db.createRun(args.name, 'driver', 'system') + # Populate results with "not run yet" # Resume |