-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
followSymlinks: Improve error message
- Loading branch information
Showing
9 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "../input-accessor.hh" | ||
#include "../memory-input-accessor.hh" | ||
#include "gmock/gmock.h" | ||
#include <gtest/gtest.h> | ||
#include "terminal.hh" | ||
|
||
namespace nix { | ||
|
||
TEST(SourcePath, followSymlinks_cycle) { | ||
auto fs = makeMemoryInputAccessor(); | ||
fs->addSymlink({"origin", CanonPath::root}, "a"); | ||
fs->addSymlink({"a", CanonPath::root}, "b"); | ||
fs->addSymlink({"b", CanonPath::root}, "a"); | ||
|
||
ASSERT_TRUE(fs->pathExists({"a", CanonPath::root})); | ||
SourcePath origin (fs->root() + "origin"); | ||
try { | ||
origin.followSymlinks(); | ||
ASSERT_TRUE(false); | ||
} catch (const Error &e) { | ||
auto msg = filterANSIEscapes(e.what(), true); | ||
// EXPECT_THAT(msg, ("too many levels of symbolic links")); | ||
EXPECT_THAT(msg, testing::HasSubstr("too many levels of symbolic links")); | ||
EXPECT_THAT(msg, testing::HasSubstr("'/origin'")); | ||
EXPECT_THAT(msg, testing::HasSubstr("assuming it leads to a cycle after following 1000 indirections")); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
check: libfetchers-tests-exe_RUN | ||
|
||
programs += libfetchers-tests-exe | ||
|
||
libfetchers-tests-exe_NAME = libnixfetchers-tests | ||
|
||
libfetchers-tests-exe_DIR := $(d) | ||
|
||
ifeq ($(INSTALL_UNIT_TESTS), yes) | ||
libfetchers-tests-exe_INSTALL_DIR := $(checkbindir) | ||
else | ||
libfetchers-tests-exe_INSTALL_DIR := | ||
endif | ||
|
||
|
||
libfetchers-tests-exe_LIBS = libfetchers-tests libstore | ||
|
||
|
||
libfetchers-tests-exe_LDFLAGS := $(GTEST_LIBS) | ||
|
||
libraries += libfetchers-tests | ||
|
||
libfetchers-tests_NAME = libnixfetchers-tests | ||
|
||
libfetchers-tests_DIR := $(d) | ||
|
||
ifeq ($(INSTALL_UNIT_TESTS), yes) | ||
libfetchers-tests_INSTALL_DIR := $(checklibdir) | ||
else | ||
libfetchers-tests_INSTALL_DIR := | ||
endif | ||
|
||
libfetchers-tests_SOURCES := $(wildcard $(d)/*.cc) | ||
|
||
libfetchers-tests_CXXFLAGS += -I src/libfetchers -I src/libutil -I src/libstore | ||
|
||
libfetchers-tests_LIBS = libutil-tests libstore-tests libutil libstore libfetchers | ||
|
||
libfetchers-tests_LDFLAGS := -lrapidcheck $(GTEST_LIBS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters