This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix dotest argument order
ClosedPublic

Authored by fdeazeve on Aug 25 2022, 3:56 AM.

Details

Summary

When running LLDB API tests, a user can override test arguments with
LLDB_TEST_USER_ARGS. However, these flags used to be concatenated with a
CMake-derived variable LLDB_TEST_COMMON_ARGS, as below:

set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}
    CACHE INTERNAL STRING)

This is problematic, because LLDB_TEST_COMMON_ARGS must be processed
first, while LLDB_TEST_USER_ARGS args must be processed last, so that
user overrides are respected. Currently, if a user attempts to override
one of the "inferred" flags, the user's request is ignored. This is the
case, for example, with --libcxx-include-dir and
--libcxx-library-dir. Both flags are needed by the greendragon bots.

This commit removes the concatenation above, keeping the two original
variables throughout the entire flow, processing the user's flag last.

The variable LLDB_TEST_COMMON_ARGS needs to be a CACHE property, but it
is modified throughout the CMake file with set or list or string
commands, which don't work with properties. As such, a temporary
variable LLDB_TEST_COMMON_ARGS_VAR is created.

This was tested locally by invoking CMake with:
-DLLDB_TEST_USER_ARGS="--libcxx-include-dir=blah --libcxx-library-dir=blah2"
and checking that tests failed appropriately.

Diff Detail

Event Timeline

fdeazeve created this revision.Aug 25 2022, 3:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2022, 3:56 AM
Herald added a subscriber: mgorny. · View Herald Transcript
fdeazeve requested review of this revision.Aug 25 2022, 3:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2022, 3:56 AM
fdeazeve updated this revision to Diff 455531.Aug 25 2022, 3:58 AM

Fix commit message typo

fdeazeve updated this revision to Diff 455585.Aug 25 2022, 7:48 AM

Added missing files

fdeazeve updated this revision to Diff 455588.Aug 25 2022, 7:55 AM
fdeazeve edited the summary of this revision. (Show Details)

Updated review message with the latest edits to the commit message.

JDevlieghere added inline comments.Aug 25 2022, 1:08 PM
lldb/test/API/CMakeLists.txt
166

Instead of having two variables, why not move this to line 40 and make LLDB_TEST_COMMON_ARGS a cached variable and operate directly on that?

lldb/test/API/lit.site.cfg.py.in
26

Let's omit the cmake part, it doesn't really matter where these args come from.

fdeazeve added inline comments.Aug 25 2022, 1:41 PM
lldb/test/API/CMakeLists.txt
166

I actually address this in the commit message:

The variable LLDB_TEST_COMMON_ARGS needs to be a CACHE property, but it

is modified throughout the CMake file with set or list or string
commands, which don't work with properties. As such, a temporary
variable LLDB_TEST_COMMON_ARGS_VAR is created.

Does this make sense?

lldb/test/API/lit.site.cfg.py.in
26

Agreed!

JDevlieghere accepted this revision.Aug 25 2022, 4:49 PM

LGTM

lldb/test/API/CMakeLists.txt
166

Gotcha, I didn't know about that limitation. I'm 99% sure you can still use the same variable and then cache it:

set(LLDB_TEST_COMMON_ARGS "")
list(APPEND LLDB_TEST_COMMON_ARGS "FOO")
list(APPEND LLDB_TEST_COMMON_ARGS "BAR")
set(LLDB_TEST_COMMON_ARGS "${LLDB_TEST_COMMON_ARGS}" CACHE INTERNAL STRING)

But maybe that's needless opaque.

This revision is now accepted and ready to land.Aug 25 2022, 4:49 PM
fdeazeve updated this revision to Diff 455859.Aug 26 2022, 3:53 AM

Addressed review comments

This revision was landed with ongoing or failed builds.Aug 26 2022, 3:53 AM
This revision was automatically updated to reflect the committed changes.