summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorChad Versace <chad@chad-versace.us>2011-07-14 13:16:11 -0700
committerChad Versace <chad@chad-versace.us>2011-07-14 14:04:12 -0700
commit97e2b72067fd0da5371a10855b6f066c227eb3a9 (patch)
tree8ab9ecc0a3a60a6a58d85ffc76520f74c53ef8e3 /framework
parentd6cd8747c4653e34b4df228374fb6c4c3645318e (diff)
framework: Raise informative error when parsing a result file in old format
If TestrunResult.parseFile is passed a file in the old, pre-json format, then raise ResultFileInOldFormatError. Signed-off-by: Chad Versace <chad@chad-versace.us>
Diffstat (limited to 'framework')
-rw-r--r--framework/core.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/framework/core.py b/framework/core.py
index f91e92d3..56c78a42 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -34,6 +34,7 @@ import time
import traceback
from log import log
from cStringIO import StringIO
+from textwrap import dedent
from threads import ConcurrentTestPool
import threading
@@ -47,7 +48,8 @@ __all__ = [
'TestProfile',
'Group',
'Test',
- 'testBinDir'
+ 'testBinDir',
+ 'ResultFileInOldFormatError',
]
@@ -131,6 +133,11 @@ class GroupResult(dict):
return root
+class ResultFileInOldFormatError(Exception):
+ def __init__(self, filepath):
+ super(Exception, self).__init__(filepath)
+ self.filepath = filepath
+
class TestrunResult:
def __init__(self):
self.serialized_keys = [
@@ -152,6 +159,14 @@ class TestrunResult:
json.dump(raw_dict, file, indent=4)
def parseFile(self, file):
+ # If file contains the old, custom format, then raise
+ # an informative error.
+ saved_position = file.tell()
+ first_line = file.readline()
+ if first_line.startswith('name:'):
+ raise ResultFileInOldFormatError(file.name)
+ file.seek(saved_position)
+
raw_dict = json.load(file)
# Check that only expected keys were unserialized.