This will be useful for other things as well such as the disallowedRequisites error in the builder code. Additionally, print the dependencyPath in the tree bold to spot where a change terminates. Also implemented some unit-tests for this code. Change-Id: I8460f3f6c5095d5bfbe390f223bc0252800dca5e
56 lines
1.9 KiB
C++
56 lines
1.9 KiB
C++
#include <gtest/gtest.h>
|
|
#include "lix/libstore/path-tree.hh"
|
|
#include "lix/libstore/path.hh"
|
|
#include "lix/libstore/store-api.hh"
|
|
#include "lix/libutil/async.hh"
|
|
|
|
namespace nix {
|
|
TEST(PathTree, simple)
|
|
{
|
|
AsyncIoRoot aio;
|
|
|
|
auto store = aio.blockOn(openStore("dummy://"));
|
|
|
|
auto parent = StorePath{"hr8lmmjmd1jk6s3p5ymggyk4am7n2lmb-openssh-10.0p2"};
|
|
auto child = StorePath{"q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66"};
|
|
|
|
std::map<StorePath, StorePathSet> graph;
|
|
graph.insert({child, {}});
|
|
graph.insert({parent, {child}});
|
|
|
|
auto graph_data =
|
|
aio.blockOn(genGraphString(parent, child, graph, *store, false, false));
|
|
ASSERT_EQ(
|
|
graph_data,
|
|
"/nix/store/hr8lmmjmd1jk6s3p5ymggyk4am7n2lmb-openssh-10.0p2\n└───/nix/store/"
|
|
"q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66\x1B[0m"
|
|
);
|
|
}
|
|
|
|
TEST(PathTree, all)
|
|
{
|
|
AsyncIoRoot aio;
|
|
|
|
auto store = aio.blockOn(openStore("dummy://"));
|
|
|
|
auto parent = StorePath{"hr8lmmjmd1jk6s3p5ymggyk4am7n2lmb-openssh-10.0p2"};
|
|
auto child = StorePath{"q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66"};
|
|
auto intermediate = StorePath{"6r4zqb04fq5l5l4zghq76wvcpz7dwd35-linux-pam-1.6.1"};
|
|
|
|
std::map<StorePath, StorePathSet> graph;
|
|
graph.insert({intermediate, {child}});
|
|
graph.insert({parent, {intermediate, child}});
|
|
graph.insert({child, {}});
|
|
|
|
const std::string expected =
|
|
"/nix/store/hr8lmmjmd1jk6s3p5ymggyk4am7n2lmb-openssh-10.0p2\n"
|
|
"├───/nix/store/q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66\x1B[0m\n"
|
|
"└───/nix/store/6r4zqb04fq5l5l4zghq76wvcpz7dwd35-linux-pam-1.6.1\x1B[0m\n"
|
|
" └───/nix/store/q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66\x1B[0m";
|
|
|
|
auto graph_data =
|
|
aio.blockOn(genGraphString(parent, child, graph, *store, true, false));
|
|
ASSERT_EQ(graph_data, expected);
|
|
}
|
|
}
|