mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-07 16:12:47 +00:00
scripts: Switched to sorted sets for result notes
God, I wish Python had an OrderedSet. This is a fix for duplicate "cycle detected" notes when using -t/--hot. This mix of merging both _hot_notes and _notes in the HotResult class is tricky when the underlying container is a list. The order is unlikely to be guaranteed anyways, when different results with different notes are folded. And if we ever want more control over the order of notes in result scripts we can always change this back later.
This commit is contained in:
@@ -717,9 +717,9 @@ def table(Result, results, diff_results=None, *,
|
||||
self = HotResult._make(r)
|
||||
self._hot_i = i
|
||||
self._hot_children = children if children is not None else []
|
||||
self._hot_notes = notes if notes is not None else []
|
||||
self._hot_notes = notes if notes is not None else set()
|
||||
if hasattr(Result_, '_notes'):
|
||||
self._hot_notes.extend(getattr(r, r._notes))
|
||||
self._hot_notes.update(getattr(r, r._notes))
|
||||
return self
|
||||
|
||||
def __add__(self, other):
|
||||
@@ -729,7 +729,7 @@ def table(Result, results, diff_results=None, *,
|
||||
else other._hot_i if self._hot_i is None
|
||||
else min(self._hot_i, other._hot_i),
|
||||
self._hot_children + other._hot_children,
|
||||
self._hot_notes + other._hot_notes)
|
||||
self._hot_notes | other._hot_notes)
|
||||
|
||||
results_ = []
|
||||
for r in results:
|
||||
@@ -756,7 +756,7 @@ def table(Result, results, diff_results=None, *,
|
||||
# found a cycle?
|
||||
if (detect_cycles
|
||||
and tuple(getattr(r, k) for k in Result._by) in seen):
|
||||
hot_[-1]._hot_notes.append('cycle detected')
|
||||
hot_[-1]._hot_notes.add('cycle detected')
|
||||
return
|
||||
|
||||
# recurse?
|
||||
@@ -912,7 +912,7 @@ def table(Result, results, diff_results=None, *,
|
||||
getattr(diff_r, k, None)))))
|
||||
# append any notes
|
||||
if hasattr(Result, '_notes') and r is not None:
|
||||
notes = getattr(r, Result._notes)
|
||||
notes = sorted(getattr(r, Result._notes))
|
||||
if isinstance(entry[-1], tuple):
|
||||
entry[-1] = (entry[-1][0], entry[-1][1] + notes)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user