mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
Meta: Add test command to ladybird.py
This commit is contained in:
parent
c9624d5118
commit
c51abfb2ca
Notes:
github-actions[bot]
2025-05-21 17:37:06 +00:00
Author: https://github.com/ayeteadoe
Commit: c51abfb2ca
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4742
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/R-Goc
Reviewed-by: https://github.com/trflynn89
1 changed files with 37 additions and 0 deletions
|
@ -86,6 +86,11 @@ def main(platform):
|
||||||
build_parser.add_argument('args', nargs=argparse.REMAINDER,
|
build_parser.add_argument('args', nargs=argparse.REMAINDER,
|
||||||
help='Additional arguments passed through to the build system')
|
help='Additional arguments passed through to the build system')
|
||||||
|
|
||||||
|
test_parser = subparsers.add_parser(
|
||||||
|
'test', help='Runs the unit tests on the build host', parents=[preset_parser, compiler_parser])
|
||||||
|
test_parser.add_argument('--pattern', required=False,
|
||||||
|
help='Limits the tests that are ran to those that match the regex pattern')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
kwargs = vars(args)
|
kwargs = vars(args)
|
||||||
command = kwargs.pop('command', None)
|
command = kwargs.pop('command', None)
|
||||||
|
@ -104,6 +109,10 @@ def main(platform):
|
||||||
if command == 'build':
|
if command == 'build':
|
||||||
build_dir = _configure_main(platform, **kwargs)
|
build_dir = _configure_main(platform, **kwargs)
|
||||||
_build_main(build_dir, **kwargs)
|
_build_main(build_dir, **kwargs)
|
||||||
|
elif command == 'test':
|
||||||
|
build_dir = _configure_main(platform, **kwargs)
|
||||||
|
_build_main(build_dir)
|
||||||
|
_test_main(build_dir, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def _configure_main(platform, **kwargs):
|
def _configure_main(platform, **kwargs):
|
||||||
|
@ -292,6 +301,34 @@ def _build_main(build_dir, **kwargs):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def _test_main(build_dir, **kwargs):
|
||||||
|
build_preset = kwargs.get('preset')
|
||||||
|
test_args = [
|
||||||
|
'ctest',
|
||||||
|
'--preset',
|
||||||
|
build_preset,
|
||||||
|
'--output-on-failure',
|
||||||
|
'--test-dir',
|
||||||
|
str(build_dir),
|
||||||
|
]
|
||||||
|
test_name_pattern = kwargs.get('pattern', None)
|
||||||
|
if test_name_pattern:
|
||||||
|
test_args.extend([
|
||||||
|
'-R',
|
||||||
|
test_name_pattern,
|
||||||
|
])
|
||||||
|
try:
|
||||||
|
subprocess.check_call(test_args)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
msg = 'Unable to test ladybird '
|
||||||
|
if test_name_pattern:
|
||||||
|
msg += f'name pattern "{test_name_pattern}"'
|
||||||
|
else:
|
||||||
|
msg += 'project'
|
||||||
|
_print_process_stderr(e, msg)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def _print_process_stderr(e, msg):
|
def _print_process_stderr(e, msg):
|
||||||
err_details = f': {e.stderr}' if e.stderr else ''
|
err_details = f': {e.stderr}' if e.stderr else ''
|
||||||
print(f'{msg}{err_details}', file=sys.stderr)
|
print(f'{msg}{err_details}', file=sys.stderr)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue