diff options
author | Pavel Labath <labath@google.com> | 2017-01-24 10:32:03 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2017-01-24 10:32:03 +0000 |
commit | 2f0960970f55637c0ff02764ad899d3c269f1053 (patch) | |
tree | 9e4d92f7e3d8ef91c30c4ae12487a3be8def3ad4 /llvm/unittests/Support/Path.cpp | |
parent | 5aeb880d909e50d85b44d6c019c3dfd3bcdb0ca2 (diff) | |
download | bcm5719-llvm-2f0960970f55637c0ff02764ad899d3c269f1053.tar.gz bcm5719-llvm-2f0960970f55637c0ff02764ad899d3c269f1053.zip |
[Support] Add sys::fs::set_current_path() (aka chdir)
Summary:
This adds a cross-platform way of setting the current working directory
analogous to the existing current_path() function used for retrieving
it. The function will be used in lldb.
Reviewers: rafael, silvas, zturner
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D29035
llvm-svn: 292907
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
-rw-r--r-- | llvm/unittests/Support/Path.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 30eaa8b278a..fb61cc7c26e 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -1135,4 +1135,23 @@ TEST_F(FileSystemTest, OpenFileForRead) { ::close(FileDescriptor); } + +TEST_F(FileSystemTest, set_current_path) { + SmallString<128> path; + + ASSERT_NO_ERROR(fs::current_path(path)); + ASSERT_NE(TestDirectory, path); + + struct RestorePath { + SmallString<128> path; + RestorePath(const SmallString<128> &path) : path(path) {} + ~RestorePath() { fs::set_current_path(path); } + } restore_path(path); + + ASSERT_NO_ERROR(fs::set_current_path(TestDirectory)); + + ASSERT_NO_ERROR(fs::current_path(path)); + ASSERT_EQ(TestDirectory, path); +} + } // anonymous namespace |