mirror of
https://github.com/littlefs-project/littlefs.git
synced 2026-02-04 20:45:39 +00:00
scripts: test.py/bench.py: Some small tweaks
- Delayed defines/permutations assignment until after generation. Just a bit of code smell. - Expanded all __eq__, __ne__, __lt__, __gt__, etc magic methods, just to minimize surprises in the future.
This commit is contained in:
@ -98,10 +98,6 @@ class BenchCase:
|
||||
|
||||
self.internal = bool(self.in_)
|
||||
|
||||
# figure out defines and build possible permutations
|
||||
self.defines = set()
|
||||
self.permutations = []
|
||||
|
||||
# defines can be a dict or a list or dicts
|
||||
suite_defines = config.pop('suite_defines', {})
|
||||
if not isinstance(suite_defines, list):
|
||||
@ -149,14 +145,17 @@ class BenchCase:
|
||||
else:
|
||||
return [v]
|
||||
|
||||
# build possible permutations
|
||||
# figure out defines and build possible permutations
|
||||
defines__ = set()
|
||||
permutations__ = []
|
||||
for suite_defines_ in suite_defines:
|
||||
self.defines |= suite_defines_.keys()
|
||||
defines__ |= suite_defines_.keys()
|
||||
for defines_ in defines:
|
||||
self.defines |= defines_.keys()
|
||||
self.permutations.append({
|
||||
k: parse_define(v)
|
||||
for k, v in (suite_defines_ | defines_).items()})
|
||||
defines__ |= defines_.keys()
|
||||
permutations__.append({k: parse_define(v)
|
||||
for k, v in (suite_defines_ | defines_).items()})
|
||||
self.defines = defines__
|
||||
self.permutations = permutations__
|
||||
|
||||
for k in config.keys():
|
||||
print('%swarning:%s in %s, found unused key %r' % (
|
||||
@ -169,11 +168,27 @@ class BenchCase:
|
||||
def __repr__(self):
|
||||
return '<BenchCase %s>' % self.name
|
||||
|
||||
# sort by suite, lineno, and name
|
||||
def __eq__(self, other):
|
||||
return ((self.suite, self.lineno, self.name)
|
||||
== (other.suite, other.lineno, other.name))
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __lt__(self, other):
|
||||
# sort by suite, lineno, and name
|
||||
return ((self.suite, self.lineno, self.name)
|
||||
< (other.suite, other.lineno, other.name))
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.__class__.__lt__(other, self)
|
||||
|
||||
def __le__(self, other):
|
||||
return not self.__gt__(other)
|
||||
|
||||
def __ge__(self, other):
|
||||
return not self.__lt__(other)
|
||||
|
||||
def isin(self, path):
|
||||
return (self.in_ is not None
|
||||
and os.path.normpath(self.in_)
|
||||
@ -286,12 +301,27 @@ class BenchSuite:
|
||||
def __repr__(self):
|
||||
return '<BenchSuite %s>' % self.name
|
||||
|
||||
# sort by name
|
||||
#
|
||||
# note we override this with a topological sort during compilation
|
||||
def __eq__(self, other):
|
||||
return self.name == other.name
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __lt__(self, other):
|
||||
# sort by name
|
||||
#
|
||||
# note we override this with a topological sort during compilation
|
||||
return self.name < other.name
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.__class__.__lt__(other, self)
|
||||
|
||||
def __le__(self, other):
|
||||
return not self.__gt__(other)
|
||||
|
||||
def __ge__(self, other):
|
||||
return not self.__lt__(other)
|
||||
|
||||
def isin(self, path):
|
||||
return (self.in_ is not None
|
||||
and os.path.normpath(self.in_)
|
||||
|
||||
@ -104,10 +104,6 @@ class TestCase:
|
||||
config.pop('suite_reentrant', False))
|
||||
self.fuzz = bool(self.fuzz_)
|
||||
|
||||
# figure out defines and build possible permutations
|
||||
self.defines = set()
|
||||
self.permutations = []
|
||||
|
||||
# defines can be a dict or a list or dicts
|
||||
suite_defines = config.pop('suite_defines', {})
|
||||
if not isinstance(suite_defines, list):
|
||||
@ -155,14 +151,17 @@ class TestCase:
|
||||
else:
|
||||
return [v]
|
||||
|
||||
# build possible permutations
|
||||
# figure out defines and build possible permutations
|
||||
defines__ = set()
|
||||
permutations__ = []
|
||||
for suite_defines_ in suite_defines:
|
||||
self.defines |= suite_defines_.keys()
|
||||
defines__ |= suite_defines_.keys()
|
||||
for defines_ in defines:
|
||||
self.defines |= defines_.keys()
|
||||
self.permutations.append({
|
||||
k: parse_define(v)
|
||||
for k, v in (suite_defines_ | defines_).items()})
|
||||
defines__ |= defines_.keys()
|
||||
permutations__.append({k: parse_define(v)
|
||||
for k, v in (suite_defines_ | defines_).items()})
|
||||
self.defines = defines__
|
||||
self.permutations = permutations__
|
||||
|
||||
for k in config.keys():
|
||||
print('%swarning:%s in %s, found unused key %r' % (
|
||||
@ -175,11 +174,27 @@ class TestCase:
|
||||
def __repr__(self):
|
||||
return '<TestCase %s>' % self.name
|
||||
|
||||
# sort by suite, lineno, and name
|
||||
def __eq__(self, other):
|
||||
return ((self.suite, self.lineno, self.name)
|
||||
== (other.suite, other.lineno, other.name))
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __lt__(self, other):
|
||||
# sort by suite, lineno, and name
|
||||
return ((self.suite, self.lineno, self.name)
|
||||
< (other.suite, other.lineno, other.name))
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.__class__.__lt__(other, self)
|
||||
|
||||
def __le__(self, other):
|
||||
return not self.__gt__(other)
|
||||
|
||||
def __ge__(self, other):
|
||||
return not self.__lt__(other)
|
||||
|
||||
def isin(self, path):
|
||||
return (self.in_ is not None
|
||||
and os.path.normpath(self.in_)
|
||||
@ -298,12 +313,27 @@ class TestSuite:
|
||||
def __repr__(self):
|
||||
return '<TestSuite %s>' % self.name
|
||||
|
||||
# sort by name
|
||||
#
|
||||
# note we override this with a topological sort during compilation
|
||||
def __eq__(self, other):
|
||||
return self.name == other.name
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __lt__(self, other):
|
||||
# sort by name
|
||||
#
|
||||
# note we override this with a topological sort during compilation
|
||||
return self.name < other.name
|
||||
|
||||
def __gt__(self, other):
|
||||
return self.__class__.__lt__(other, self)
|
||||
|
||||
def __le__(self, other):
|
||||
return not self.__gt__(other)
|
||||
|
||||
def __ge__(self, other):
|
||||
return not self.__lt__(other)
|
||||
|
||||
def isin(self, path):
|
||||
return (self.in_ is not None
|
||||
and os.path.normpath(self.in_)
|
||||
|
||||
Reference in New Issue
Block a user