Skip to content

Commit db83ce2

Browse files
committed
file-existance check for "cache load" attempt
1 parent 0bb4b9a commit db83ce2

1 file changed

Lines changed: 26 additions & 22 deletions

File tree

tools/Python/mctest/mctest.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,30 @@ def save(self, infolder):
9595
text = json.dumps(self.get_json_repr(), indent=2)
9696
f = open(join(infolder, self.get_display_name()) + ".json", 'w').write(text)
9797
def load(self,testnb=0):
98-
jsonfile=os.path.join(os.path.dirname(self.localfile),self.get_display_name()+'.json')
99-
f = open(jsonfile, "r", encoding="utf-8")
100-
obj = json.load(f)
101-
# # Populate test
102-
self.displayname=obj['displayname']
103-
self.sourcefile=obj['sourcefile']
104-
self.localfile=obj['localfile']
105-
self.instrname=obj['instrname']
106-
self.testnb=obj['testnb']
107-
self.parvals=obj['parvals']
108-
self.detector=obj['detector']
109-
self.targetval=obj['targetval']
110-
self.testval=obj['testval']
111-
self.linted=obj['linted']
112-
self.compiled=obj['compiled']
113-
self.compiletime=obj['compiletime']
114-
self.didrun=obj['didrun']
115-
self.runtime=obj['runtime']
116-
self.errmsg=obj['errmsg']
117-
98+
jsonfile=pathlib.Path(os.path.join(os.path.dirname(self.localfile),self.get_display_name()+'.json'))
99+
if jsonfile.is_file():
100+
f = open(jsonfile, "r", encoding="utf-8")
101+
obj = json.load(f)
102+
# # Populate test
103+
self.displayname=obj['displayname']
104+
self.sourcefile=obj['sourcefile']
105+
self.localfile=obj['localfile']
106+
self.instrname=obj['instrname']
107+
self.testnb=obj['testnb']
108+
self.parvals=obj['parvals']
109+
self.detector=obj['detector']
110+
self.targetval=obj['targetval']
111+
self.testval=obj['testval']
112+
self.linted=obj['linted']
113+
self.compiled=obj['compiled']
114+
self.compiletime=obj['compiletime']
115+
self.didrun=obj['didrun']
116+
self.runtime=obj['runtime']
117+
self.errmsg=obj['errmsg']
118+
return True
119+
else:
120+
return False
121+
118122
def get_display_name(self):
119123
if self.testnb > 1:
120124
return self.instrname + "_%d" % self.testnb
@@ -251,8 +255,8 @@ def mccode_test(branchdir, testdir, limitinstrs=None, instrfilter=None, compfilt
251255
populated=[]
252256
for t in instrtests:
253257
if t.testnb >= 0:
254-
t.load(t.testnb)
255-
populated.append(t)
258+
if t.load(t.testnb)==True:
259+
populated.append(t)
256260
tests = tests + populated
257261
pass
258262

0 commit comments

Comments
 (0)