1 # This overlay implements mocking of the lib.path.splitRoot function
2 # It pretends that the last component named "mock-root" is the root:
4 # splitRoot /foo/mock-root/bar/mock-root/baz
6 # root = /foo/mock-root/bar/mock-root;
10 path = super.path // {
13 parts = super.path.splitRoot path;
14 components = self.path.subpath.components parts.subpath;
15 count = self.length components;
16 rootIndex = count - self.lists.findFirstIndex
17 (component: component == "mock-root")
18 (self.length components)
19 (self.reverseList components);
20 root = self.path.append parts.root (self.path.subpath.join (self.take rootIndex components));
21 subpath = self.path.subpath.join (self.drop rootIndex components);