aboutsummaryrefslogtreecommitdiff
path: root/run_project_tests.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-02-06 16:47:28 -0800
committerDylan Baker <dylan@pnwbakers.com>2020-02-07 09:29:02 -0800
commit3689e49f4eb8cd4a7b1ec396610cdfcecd88a009 (patch)
tree684b3f7052719f39c5b63890c56bcf60f723af28 /run_project_tests.py
parent3ba0073df6014d4b594df052f8e1fa75ce17b20e (diff)
downloadmeson-3689e49f4eb8cd4a7b1ec396610cdfcecd88a009.zip
meson-3689e49f4eb8cd4a7b1ec396610cdfcecd88a009.tar.gz
meson-3689e49f4eb8cd4a7b1ec396610cdfcecd88a009.tar.bz2
run_project_tests: Fix it to actually work
This move the sorting logic into the TestDef class itself, which simplifies sorting them. Additionally it remove overcomplicated sort logic, because python strings are compared character by character, we don't need to do the split and cast to int, we know that realistically a maximum of 4 characters (the first 4 numbers) are going to be compared in most cases.
Diffstat (limited to 'run_project_tests.py')
-rwxr-xr-xrun_project_tests.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/run_project_tests.py b/run_project_tests.py
index 2d18ee0..aac9f9d 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -15,6 +15,7 @@
# limitations under the License.
import typing as T
+import functools
import itertools
import os
import subprocess
@@ -76,6 +77,7 @@ class TestResult:
self.testtime = testtime
+@functools.total_ordering
class TestDef:
def __init__(self, path: Path, name: T.Optional[str], args: T.List[str], skip: bool = False):
self.path = path
@@ -91,6 +93,12 @@ class TestDef:
return '{} ({})'.format(self.path.as_posix(), self.name)
return self.path.as_posix()
+ def __lt__(self, other: T.Any) -> T.Union[bool, type(NotImplemented)]:
+ if isinstance(other, TestDef):
+ # None is not sortable, so replace it with an empty string
+ return (self.path, self.name or '') < (other.path, other.name or '')
+ return NotImplemented
+
class AutoDeletedDir:
def __init__(self, d):
self.dir = d
@@ -492,7 +500,7 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen
return TestResult(validate_install(testdir, install_dir, compiler, builddata.environment),
BuildStep.validate, stdo, stde, mesonlog, cicmds, gen_time, build_time, test_time)
-def gather_tests(testdir: Path) -> T.List[TestDef]:
+def gather_tests(testdir: Path) -> T.Iterator[TestDef]:
tests = [t.name for t in testdir.glob('*') if t.is_dir()]
tests = [t for t in tests if not t.startswith('.')] # Filter non-tests files (dot files, etc)
tests = [TestDef(testdir / t, None, []) for t in tests]
@@ -538,10 +546,7 @@ def gather_tests(testdir: Path) -> T.List[TestDef]:
skip = any([x[1] for x in i])
all_tests += [TestDef(t.path, name, opts, skip)]
- all_tests = [(int(t.path.name.split()[0]), t.name or '', t) for t in all_tests]
- all_tests.sort()
- all_tests = [t[2] for t in all_tests]
- return all_tests
+ return sorted(all_tests)
def have_d_compiler():
if shutil.which("ldc2"):