Skip to content

Commit

Permalink
Fixes #92, fantom failures reapearing (fixed earlier).
Browse files Browse the repository at this point in the history
  • Loading branch information
tarpas committed Mar 30, 2018
1 parent d6871de commit 0a7c810
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_write_read_data2(self, testdir):
td = CoreTestmonData(testdir.tmpdir.strpath, 'default')
td.lastfailed = ['n1']
td.write_data()
td.set_dependencies('n1', n1_node_data, )
td.set_dependencies('n1', n1_node_data, [])
td2 = CoreTestmonData(testdir.tmpdir.strpath, 'default')
td2.read_data()
assert td2.node_data['n1'] == n1_node_data
Expand Down
4 changes: 2 additions & 2 deletions test/test_testmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def track_it(testdir, func):
testmon_data.read_source()
testmon.start()
func()
testmon.stop_and_save(testmon_data, testdir.tmpdir.strpath, 'testnode')
testmon.stop_and_save(testmon_data, testdir.tmpdir.strpath, 'testnode', [])
return testmon_data._fetch_node_data()[0]['testnode']


Expand Down Expand Up @@ -164,7 +164,7 @@ def test_add():

reprec = testdir.inline_run("--testmon", "-v")
res = reprec.countoutcomes()
assert tuple(res) == (1, 0, 0), res
assert tuple(res) == (0, 0, 0), res

def test_tlf(self, testdir):
testdir.makepyfile(test_a="""
Expand Down
9 changes: 5 additions & 4 deletions testmon/testmon_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def start(self):
def stop(self):
self.cov.stop()

def stop_and_save(self, testmon_data, rootdir, nodeid, result=[]):
def stop_and_save(self, testmon_data, rootdir, nodeid, result):
self.stop()
if hasattr(self, 'sub_cov_file'):
self.cov.combine()
Expand Down Expand Up @@ -294,7 +294,8 @@ def init_tables(self):
variant TEXT,
name TEXT,
result TEXT,
failed BIT
failed BIT,
UNIQUE (variant, name)
)
""")
self.connection.execute("""
Expand Down Expand Up @@ -345,15 +346,15 @@ def get_nodedata(self, nodeid, coverage_data, rootdir):
result[relfilename] = checksum_coverage(self.source_tree.get_file(relfilename).blocks, [1])
return result

def set_dependencies(self, nodeid, nodedata, result=[]):
def set_dependencies(self, nodeid, nodedata, result=None):
with self.connection as con:
outcome = bool([True for r in result if r.get('outcome') == u'failed'])
cursor = con.cursor()
cursor.execute("INSERT OR REPLACE INTO "
"node "
"(variant, name, result, failed) "
"VALUES (?, ?, ?, ?)",
(self.variant, nodeid, json.dumps(result) if outcome else '', outcome))
(self.variant, nodeid, json.dumps(result) if outcome else '[]', outcome))
con.executemany("INSERT INTO node_file VALUES (?, ?, ?)",
[(cursor.lastrowid, filename, checksums_to_blob(nodedata[filename])) for filename in
nodedata])
Expand Down

0 comments on commit 0a7c810

Please sign in to comment.