summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2012-11-30 00:10:32 -0800
committerKenneth Graunke <kenneth@whitecape.org>2012-11-30 00:10:32 -0800
commit49e088c9bd3bfce1b2a2ba4a41d376e988333c5a (patch)
tree228393435ce0ef3b1ca740d31bde598fc3e475ac
parenta4ca942fd52434aa8d490eca1c509889bdd0d9bb (diff)
Properly take the union of columns, rather than the intersection...
Sadly, SQLite can't do outer joins, so we can't actually use SQL to do this like we should. Sheesh.
-rw-r--r--framework/database.py31
-rwxr-xr-xprograms/report.py23
2 files changed, 25 insertions, 29 deletions
diff --git a/framework/database.py b/framework/database.py
index 9c63aaa..5cc0950 100644
--- a/framework/database.py
+++ b/framework/database.py
@@ -85,31 +85,8 @@ class ResultDatabase:
c = self.connection.cursor()
c.execute('UPDATE results SET command = ?, result = ?, return_code = ?, errors = ?, output = ? WHERE run_name = ? AND test_name = ? AND result IS NULL', (' '.join(command), result['status'], result['exitcode'], result['err'], result['out'], run, name))
- def getResults(self, runs):
+ def getResults(self, run):
c = self.connection.cursor()
-
- # Build self-join query to get results. This awful code generates:
- #
- # SELECT R0.test_name, R0.result, R1.result, R2.result FROM
- # (SELECT test_name, result FROM results WHERE run_name = 'foo') R0
- # INNER JOIN
- # (SELECT test_name, result FROM results WHERE run_name = 'bar') R1
- # USING (test_name)
- # INNER JOIN
- # (SELECT test_name, result FROM results WHERE run_name = 'quux') R2
- # USING (test_name)
-
- subselects = ['(SELECT test_name, result FROM results WHERE run_name = ?) R%d' % i for i in range(len(runs))]
- query = ' '.join(['SELECT R0.test_name,',
- ', '.join('R%d.result' % i for i in range(len(runs))),
- 'FROM', subselects[0],
- ' '.join([' INNER JOIN ' + s + ' USING (test_name) ' for s in subselects[1:]])])
-
- xs = c.execute(query, runs)
-
- # Convert (name, s1, s2, s3) to {name: (s1, s2, s3)}
- results = {}
- for x in xs:
- results[x[0]] = x[1:]
-
- return results
+ query = 'SELECT test_name, result FROM results WHERE run_name = ?'
+ xs = c.execute(query, [run])
+ return dict(xs)
diff --git a/programs/report.py b/programs/report.py
index 7cca268..a7bce2c 100755
--- a/programs/report.py
+++ b/programs/report.py
@@ -198,6 +198,26 @@ def writeSummaryHtml(run_names, results, reportDir):
##### Main program
#############################################################################
+def getCombinedResults(db, run_names):
+ # Sadly, SQLite can't do full outer joins, so we have to query the results
+ # for each run individually and reassemble them here.
+ individual_results = dict([(run, db.getResults(run)) for run in run_names])
+
+ # Get a set containing all test names (in slash-separated form).
+ # Some runs may have more tests than others; take the union.
+ test_names = set()
+ for run in run_names:
+ test_names |= set(individual_results[run].keys())
+
+ results = {}
+ for test in test_names:
+ results[test] = []
+ for run in run_names:
+ results[test].append(individual_results[run].get(test, None))
+
+ return results
+
+
def parseArguments(argv, config):
p = ArgumentParser(prog='robyn report', description='A GPU test runner')
p.add_argument('-o', '--output', default='summary',
@@ -217,9 +237,8 @@ def main(argv, config):
os.makedirs(reportDir)
run_names = list(args.runs)
- results = db.getResults(run_names)
- #print(results)
+ results = getCombinedResults(db, run_names)
# XXX: write detail pages