From 7eaed558eadc415e382c086d66f1af5281de86ef Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 17 Feb 2026 20:20:16 -0800 Subject: [PATCH] Add test_suite decorator Right now all this does is handle `abort_on_first_failure` but we can extend it to do more. --- check.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/check.py b/check.py index 3eacf5925ca..dfd67743274 100755 --- a/check.py +++ b/check.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import functools import glob import io import os @@ -387,8 +388,6 @@ def run_unittest(): suite = unittest.defaultTestLoader.discover(os.path.dirname(shared.options.binaryen_test)) result = unittest.TextTestRunner(verbosity=2, failfast=shared.options.abort_on_first_failure).run(suite) shared.num_failures += len(result.errors) + len(result.failures) - if shared.options.abort_on_first_failure and shared.num_failures: - raise Exception("unittest failed") @shared.with_pass_debug() @@ -400,8 +399,6 @@ def run_lit(): result = subprocess.run(cmd) if result.returncode != 0: shared.num_failures += 1 - if shared.options.abort_on_first_failure and shared.num_failures: - raise Exception("lit test failed") @shared.with_pass_debug() @@ -413,8 +410,17 @@ def run_gtest(): result = subprocess.run(gtest) if result.returncode != 0: shared.num_failures += 1 + + +def test_suite(name, func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + assert not (shared.options.abort_on_first_failure and shared.num_failures) + result = func(*args, **kwargs) if shared.options.abort_on_first_failure and shared.num_failures: - raise Exception("gtest test failed") + raise Exception(f'test suite failed: {name}') + return result + return wrapper TEST_SUITES = { @@ -437,6 +443,8 @@ def run_gtest(): 'gtest': run_gtest, } +TEST_SUITES = {name: test_suite(name, func) for name, func in TEST_SUITES.items()} + # Run all the tests def main():