Commit Graph

25 Commits

Author SHA1 Message Date
Pavel Labath 7ed3e22f00 [unittests] Add a helper function for getting an input file
Summary:
Fetching an input file required about five lines of code, and this was
repeated in multiple unit tests, with slight variations. Add a helper
function for doing that into the lldbUtilityMocks module (which I rename
to lldbUtilityHelpers to commemorate the fact it includes more than
mocks)

Reviewers: zturner, eugene

Subscribers: emaste, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D34683

llvm-svn: 306668
2017-06-29 13:02:11 +00:00
Zachary Turner 426d1379b0 Fix crash when completing in the current directory.
llvm-svn: 300386
2017-04-15 02:44:53 +00:00
Zachary Turner 8d48cd6009 Resubmit "Delete the remainder of platform specific code in FileSpec."
This was causing a test failure in one of LLDB's tests which
specifically dealt with a limitation in LLVM's implementation
of home_directory() that LLDB's own implementation had worked
around.

This limitation has been addressed in r298513 on the LLVM side,
so the failing test (which is now unnecessary as the limitation
no longer exists) was removed in r298519, allowing this patch to
be re-submitted without modification.

llvm-svn: 298526
2017-03-22 17:33:23 +00:00
Pavel Labath ed00beba12 Revert "Delete the remainder of platform specific code in FileSpec."
This reverts commit r298465 as it breaks
TestLLVM.TestHomeDirectory.test_tilde_home_directory.

llvm-svn: 298509
2017-03-22 14:04:43 +00:00
Zachary Turner aaedf89101 Delete the remainder of platform specific code in FileSpec.
Differential Revision: https://reviews.llvm.org/D31129

llvm-svn: 298465
2017-03-22 00:27:24 +00:00
Zachary Turner 573ab909d3 Move StringList from Core -> Utility.
llvm-svn: 298412
2017-03-21 18:25:04 +00:00
Zachary Turner c8c9f97258 Fix unit test compilation failure.
llvm-svn: 298202
2017-03-19 05:48:01 +00:00
Pavel Labath bb114f84e7 Fix flakyness in TestCompletion
One of the file name templates was occasionally generating the name
"fooa***", which conflicted with the one of the tests expectation that
there is only one item beginning with "fooa".

There doesn't seem to be a good reason for using random file templates
here, so just switch to a fixed set of files to increase
reproducibility.

llvm-svn: 297743
2017-03-14 14:58:31 +00:00
Pavel Labath 9bd69ad9b8 Fix Linux build for the FileSpec changes
Propagate changes that were made during review, and fix a couple of
warnings while I'm in there.

llvm-svn: 297609
2017-03-13 09:46:15 +00:00
Zachary Turner 2cc5a18dc2 Resubmit "Make file / directory completion work properly on Windows."
This fixes the compilation failures with the original patch.

llvm-svn: 297597
2017-03-13 00:41:01 +00:00
Zachary Turner 0734e6a525 Revert "Make file / directory completion work properly on Windows."
This reverts commit a6a29374662716710f80c8ece96629751697841e.

It has a few compilation failures that I don't have time to fix
at the moment.

llvm-svn: 297589
2017-03-12 20:01:37 +00:00
Zachary Turner d5bd3a1e6a Make file / directory completion work properly on Windows.
There were a couple of problems with this function on Windows. Different
separators and differences in how tilde expressions are resolved for
starters, but in addition there was no clear indication of what the
function's inputs or outputs were supposed to be, and there were no tests
to demonstrate its use.

To more easily paper over the differences between Windows paths,
non-Windows paths, and tilde expressions, I've ported this function to use
LLVM-based directory iteration (in fact, I would like to eliminate all of
LLDB's directory iteration code entirely since LLVM's is cleaner / more
efficient (i.e. it invokes fewer stat calls)). and llvm's portable path
manipulation library.

Since file and directory completion assumes you are referring to files and
directories on your local machine, it's safe to assume the path syntax
properties of the host in doing so, so LLVM's APIs are perfect for this.

I've also added a fairly robust set of unit tests. Since you can't really
predict what users will be on your machine, or what their home directories
will be, I added an interface called TildeExpressionResolver, and in the
unit test I've mocked up a fake implementation that acts like a unix
password database. This allows us to configure some fake users and home
directories in the test, so we can exercise all of those hard-to-test
codepaths that normally otherwise depend on the host.

Differential Revision: https://reviews.llvm.org/D30789

llvm-svn: 297585
2017-03-12 18:18:50 +00:00
Pavel Labath 5e336903be Modernize Enable/DisableLogChannel interface a bit
Summary:
Use StringRef and ArrayRef where possible. This adds an accessor to the
Args class to get a view of the arguments as ArrayRef<const char *>.

Reviewers: zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D30402

llvm-svn: 296592
2017-03-01 10:08:40 +00:00
Chris Bieneman 1751311a87 [CMake] Update unit tests with accurate dependencies
This is extending the updates from r293696 to the LLDB unit tests.

llvm-svn: 293821
2017-02-01 22:17:00 +00:00
Zachary Turner 691405be38 Refactor the Args class.
There were a number of issues with the Args class preventing
efficient use of strings and incoporating LLVM's StringRef class.
The two biggest were:

1. Backing memory stored in a std::string, so we would frequently
   have to use const_cast to get a mutable buffer for passing to
   various low level APIs.
2. backing std::strings stored in a std::list, which doesn't
   provide random access.

I wanted to solve these two issues so that we could provide
StringRef access to the underlying arguments, and also a way
to provide range-based access to the underlying argument array
while still providing convenient c-style access via an argv style
const char**.

The solution here is to store arguments in a single "entry" class
which contains the backing memory, a StringRef with precomputed
length, and the quote char.  The backing memory is a manually
allocated const char* so that it is not invalidated when the
container is resized, and there is a separate argv array provided
for c-style access.

Differential revision: https://reviews.llvm.org/D25099

llvm-svn: 283157
2016-10-03 22:51:09 +00:00
Todd Fiala 36bf6a46d8 added environment variable-related Args gtests
Also fixed up a couple misbehaving functions.  It is perfectly
legal to have env vars with no values (i.e. the '=' and following
need not be present).

llvm-svn: 282171
2016-09-22 16:00:01 +00:00
Zachary Turner 552d012b7e Fix compilation of unit tests.
llvm-svn: 281926
2016-09-19 18:32:23 +00:00
Zachary Turner ecbb0bb169 Fix more functions in Args to use StringRef.
This patch also marks the const char* versions as =delete to prevent
their use.  This has the potential to cause build breakages on some
platforms which I can't compile.  I have tested on Windows, Linux,
and OSX.  Best practices for fixing broken callsites are outlined in
Args.h in a comment above the deleted function declarations.

Eventually we can remove these =delete declarations, but for now they
are important to make sure that all implicit conversions from
const char * are manually audited to make sure that they do not invoke a
conversion from nullptr.

llvm-svn: 281919
2016-09-19 17:54:06 +00:00
Zachary Turner 6fa7681bb6 Convert many functions to use StringRefs.
Where possible, remove the const char* version.  To keep the
risk and impact here minimal, I've only done the simplest
functions.

In the process, I found a few opportunities for adding some
unit tests, so I added those as well.

Tested on Windows, Linux, and OSX.

llvm-svn: 281799
2016-09-17 02:00:02 +00:00
Zachary Turner 7b2e5a36e4 Add unit tests for a few string conversion functions in Args.
Also provided a StringRef overload for these functions and have
the const char* overloads delegate to the StringRef overload.

llvm-svn: 281764
2016-09-16 19:09:12 +00:00
Kate Stone b9c1b51e45 *** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style.  This kind of mass change has
*** two obvious implications:

Firstly, merging this particular commit into a downstream fork may be a huge
effort.  Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit.  The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):

    find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
    find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;

The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.

Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit.  There are alternatives available that will attempt
to look through this change and find the appropriate prior commit.  YMMV.

llvm-svn: 280751
2016-09-06 20:57:50 +00:00
Zachary Turner 799770c03a Fix linking of unit tests via CMake on Windows.
A previous attempt to make the unit tests link properly on
Linux broke it for Windows.  This patch fixes it for both platforms.

llvm-svn: 232648
2015-03-18 16:56:24 +00:00
Zachary Turner 85bc48ca74 Convert CRLF to LF.
I accidentally let some Windows line endings slip in.  This is a
good reminder for me to use core.eol=lf.

llvm-svn: 232560
2015-03-17 22:51:21 +00:00
David Blaikie 3dfb86b641 Fix the clang -Werror build & make the unit tests link under Linux
The order of libraries passed to the linker didn't work under linux (you
need the llvm libraries first, then the lldb libraries). I modelled this
after clang's setup here. Seemed simple enough to just be consistent.

llvm-svn: 232461
2015-03-17 03:32:21 +00:00
Zachary Turner 073951f28b Fix a bug related to arg escaping, and add unit tests.
A recent refactor had introduced a bug where if you escaped a
character, the rest of the string would get processed incorrectly.

This patch fixes that bug and adds some unit tests for Args.

llvm-svn: 232288
2015-03-14 23:39:42 +00:00