mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.57k stars 1.62k forks source link

gcovr html coverage generation fails due to unknown argument supplied by meson #13781

Open amcn opened 1 week ago

amcn commented 1 week ago

Describe the bug Generating HTML coverage with gcovr causes an exception in meson 1.5.2 with gcovr version 5.2 due to the use of an unknown command line option: --html-nested. The use of this option was added in 783183260d6, replacing the use of --html-details.

--html-nested was added to gcovr in version 6.0 according its documentation. The version condition for generating HTML reports in gcovr is >=3.3 causing meson's coverage script to pass --html-nested to a binary which does not yet recognise it.

Stack trace:

(.venv) andrew@raspberrypi:~/github/ares/build_coverage $ ninja coverage
[1/1] Generates coverage reports
FAILED: meson-internal__coverage 
/home/andrew/github/ares/.venv/bin/meson --internal coverage /home/andrew/github/ares /home/andrew/github/ares/subprojects /home/andrew/github/ares/build_coverage /home/andrew/github/ares/build_coverage/meson-logs --gcov gcovr --llvm-cov llvm-cov
Debian LLVM version 14.0.6
  Optimized build.
  Default target: aarch64-unknown-linux-gnu
  Host CPU: cortex-a72
usage: gcovr [options] [search_paths...]
gcovr: error: unrecognized arguments: --html-nested
Traceback (most recent call last):
  File "/home/andrew/github/ares/.venv/bin/meson", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/andrew/github/ares/.venv/lib/python3.11/site-packages/mesonbuild/mesonmain.py", line 291, in main
    return run(sys.argv[1:], launcher)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andrew/github/ares/.venv/lib/python3.11/site-packages/mesonbuild/mesonmain.py", line 279, in run
    return run_script_command(args[1], args[2:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andrew/github/ares/.venv/lib/python3.11/site-packages/mesonbuild/mesonmain.py", line 220, in run_script_command
    return module.run(script_args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andrew/github/ares/.venv/lib/python3.11/site-packages/mesonbuild/scripts/coverage.py", line 208, in run
    return coverage(options.outputs, options.source_root,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/andrew/github/ares/.venv/lib/python3.11/site-packages/mesonbuild/scripts/coverage.py", line 162, in coverage
    subprocess.check_call(gcovr_base_cmd + gcovr_config +
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gcovr', '-r', '/home/andrew/github/ares', '/home/andrew/github/ares/build_coverage', '-e', '/home/andrew/github/ares/subprojects', '--html', '--html-nested', '--print-summary', '-o', '/home/andrew/github/ares/build_coverage/meson-logs/coveragereport/index.html']' returned non-zero exit status 2.
ninja: build stopped: subcommand failed.
(.venv) andrew@raspberrypi:~/github/ares/build_coverage $ meson --version
1.5.2
(.venv) andrew@raspberrypi:~/github/ares/build_coverage $ gcovr --version
gcovr 5.2

Copyright (c) 2013-2022 the gcovr authors
Copyright (c) 2013 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
(.venv) andrew@raspberrypi:~/github/ares/build_coverage $ 

To Reproduce As this requires a particular environment, supplying a meson.build is probably not useful: the bug is in how meson treats its environment and so should be reproducible with any meson.build. My environment, which triggers the bug, is as follows:

  1. Debian 12 (on a raspberrypi4)
  2. meson 1.5.2 (installed via pip in a venv)
  3. Python 3.11.2 (installed from debian 12 repos)
  4. gcovr 5.2 (installed from debian 12 repos)

Run meson on any project, specifying -Db_coverage=true and then invoke ninja's coverage target:

$ meson setup build -Db_coverage=true
$ ninja -C build
$ ninja -C build coverage

Expected behavior Coverage generation succeeds.

system parameters

amcn commented 1 week ago

This is a recent regression, working on a fix.