From 379ae8ccfb4e565cb11ffd6524463410530940ce Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 19 Jul 2025 16:41:07 +0200 Subject: [PATCH] Add helper script to run tests --- run_tests.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 run_tests.py diff --git a/run_tests.py b/run_tests.py new file mode 100755 index 00000000..f72ce9c7 --- /dev/null +++ b/run_tests.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +"""Run novelWriter Tests.""" + +import argparse +import os +import subprocess +import sys + +if __name__ == "__main__": + """Parse command line options and run the commands.""" + parser = argparse.ArgumentParser(usage="run_tests.py [--flags]") + parser.add_argument("-o", action="store_true", help="Run off screen") + parser.add_argument("-r", action="store_true", help="Generate reports") + parser.add_argument("-t", action="store_true", help="Generate terminal report") + parser.add_argument("-m", help="Test modules") + parser.add_argument("-k", help="Test filters") + + args = parser.parse_args() + + env = os.environ.copy() + cmd = [sys.executable, "-m", "pytest", "-vv"] + + if args.o: + env["QT_QPA_PLATFORM"] = "offscreen" + if args.r or args.t: + cmd += ["--cov=novelwriter"] + if args.r: + cmd += ["--cov-report=xml", "--cov-report=html"] + if args.t: + cmd += ["--cov-report=term"] + if args.m: + cmd += ["-m", args.m] + if args.k: + cmd += ["-k", args.k] + + subprocess.call(cmd, env=env)