diff options
author | Florian Schmaus <flo@geekplace.eu> | 2023-04-29 16:06:52 +0200 |
---|---|---|
committer | Kim Gräsman <kim.grasman@gmail.com> | 2023-05-28 18:20:01 +0200 |
commit | 1d113962b23e814e1bc69b32644d94643eed9002 (patch) | |
tree | 909a33156c94dbb126e90685a8d8cdc198e19f89 | |
parent | bd9c2c8c3e7bdf5c7cc6a06a27081794b35eeb27 (diff) |
iwyu_test_util: add support for IWYU_EXTRA_ARGS env variable
When running the tests as part of Gentoo's emerge process (in
src_test()) the tests fail due clang's include directory missing.
The emerge phase that runs the tests is performed with the application
under test still in the build directory. And this is what breaks the
IWYU tests there.
The include-what-you-use binary seems to have, amongst other, the
following default include path (as per
"include-what-you-use-0.19_build/bin/include-what-you-use -E -x c++ -
-v < /dev/null"):
ignoring nonexistent directory
"/var/tmp/portage/dev-util/include-what-you-use-0.19/work/include-what-you-use-0.19_build/bin/../../../../lib/clang/15.0.7/include"
Here,
/var/tmp/portage/dev-util/include-what-you-use-0.19/work/include-what-you-use-0.19_build/
is the build directory. Unfortunately, the whole path to the clang
include is invalid (non-existent). It will become correct once IWYU is merged
into the live filesystem.
As workaround run_iwyu_tests.py now supports IWYU_EXTRA_ARGS to be
able to provide the correct include path by invoking run_iwyu_test.py
basically like:
IWYU_EXTRA_ARGS="-I /usr/lib/clang/15.0.7/include" \
run_iwyu_tests.py \
-- ${BUILD_DIR}/bin/include-what-you-use
Related Gentoo bug: https://bugs.gentoo.org/905214
-rwxr-xr-x | iwyu_test_util.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/iwyu_test_util.py b/iwyu_test_util.py index c4b0d5e..29cc5b1 100755 --- a/iwyu_test_util.py +++ b/iwyu_test_util.py @@ -438,6 +438,9 @@ def TestIwyuOnRelativeFile(cc_file, cpp_files_to_check, verbose=False): env_verbose_level = os.getenv('IWYU_VERBOSE') if env_verbose_level: cmd += ['-Xiwyu', '--verbose=' + env_verbose_level] + env_iwyu_extra_args = os.getenv('IWYU_EXTRA_ARGS') + if env_iwyu_extra_args: + cmd += shlex.split(env_iwyu_extra_args) cmd += [cc_file] if verbose: |