summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-08-29 00:48:39 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-08-29 00:48:39 +0000
commit8253cc047de523fd2097e4d85417316ff9a37ad5 (patch)
treeaebb560a5ab50501e7075925221f4d9382e428fc /utils
parentaee279dad51c0ac10360973509197c9e5f39f4b0 (diff)
downloadllvm-8253cc047de523fd2097e4d85417316ff9a37ad5.tar.gz
llvm-8253cc047de523fd2097e4d85417316ff9a37ad5.tar.bz2
llvm-8253cc047de523fd2097e4d85417316ff9a37ad5.tar.xz
[lit] Change lit.Test.ResultCode to be unique across pickling.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189549 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/lit/lit/Test.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils/lit/lit/Test.py b/utils/lit/lit/Test.py
index 59ca6943e7..05cae99a2f 100644
--- a/utils/lit/lit/Test.py
+++ b/utils/lit/lit/Test.py
@@ -5,6 +5,17 @@ import os
class ResultCode(object):
"""Test result codes."""
+ # We override __new__ and __getnewargs__ to ensure that pickling still
+ # provides unique ResultCode objects in any particular instance.
+ _instances = {}
+ def __new__(cls, name, isFailure):
+ res = cls._instances.get(name)
+ if res is None:
+ cls._instances[name] = res = super(ResultCode, cls).__new__(cls)
+ return res
+ def __getnewargs__(self):
+ return (self.name, self.isFailure)
+
def __init__(self, name, isFailure):
self.name = name
self.isFailure = isFailure