Added mermaid test cases for include diagrams
This commit is contained in:
@@ -22,6 +22,8 @@ diagrams:
|
||||
- 'note right of {{ alias("include/lib1") }}: This is a lib1 include dir'
|
||||
- 'note right of {{ alias("include/t40001_include1.h") }}: This is a t40001_include1.h include file'
|
||||
mermaid:
|
||||
before:
|
||||
- "%% t40001 test diagram of type {{ diagram.type }}"
|
||||
after:
|
||||
- 'N_00001(This is a lib1 include dir)-.-{{ alias("include/lib1") }}'
|
||||
- 'N_00002(This is a lib1 include dir)-.-{{ alias("include/t40001_include1.h") }}'
|
||||
- 'N_00002(This is a t40001_include1.h include file)-.-{{ alias("include/t40001_include1.h") }}'
|
||||
@@ -29,31 +29,30 @@ TEST_CASE("t40001", "[test-case][include]")
|
||||
REQUIRE(model->name() == "t40001_include");
|
||||
|
||||
{
|
||||
auto puml = generate_include_puml(diagram, *model);
|
||||
auto src = generate_include_puml(diagram, *model);
|
||||
|
||||
AliasMatcher _A(puml);
|
||||
AliasMatcher _A(src);
|
||||
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
REQUIRE_THAT(src, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(src, EndsWith("@enduml\n"));
|
||||
|
||||
REQUIRE_THAT(puml, IsFolder("lib1"));
|
||||
REQUIRE_THAT(puml, IsFile("lib1.h"));
|
||||
REQUIRE_THAT(puml, IsFile("t40001.cc"));
|
||||
REQUIRE_THAT(puml, IsFile("t40001_include1.h"));
|
||||
REQUIRE_THAT(src, IsFolder("lib1"));
|
||||
REQUIRE_THAT(src, IsFile("lib1.h"));
|
||||
REQUIRE_THAT(src, IsFile("t40001.cc"));
|
||||
REQUIRE_THAT(src, IsFile("t40001_include1.h"));
|
||||
|
||||
REQUIRE_THAT(puml, IsFile("string"));
|
||||
REQUIRE_THAT(puml, IsFile("yaml-cpp/yaml.h"));
|
||||
REQUIRE_THAT(src, IsFile("string"));
|
||||
REQUIRE_THAT(src, IsFile("yaml-cpp/yaml.h"));
|
||||
|
||||
REQUIRE_THAT(
|
||||
puml, IsAssociation(_A("t40001.cc"), _A("t40001_include1.h")));
|
||||
REQUIRE_THAT(
|
||||
puml, IsAssociation(_A("t40001_include1.h"), _A("lib1.h")));
|
||||
src, IsAssociation(_A("t40001.cc"), _A("t40001_include1.h")));
|
||||
REQUIRE_THAT(src, IsAssociation(_A("t40001_include1.h"), _A("lib1.h")));
|
||||
|
||||
REQUIRE_THAT(puml, IsDependency(_A("t40001_include1.h"), _A("string")));
|
||||
REQUIRE_THAT(src, IsDependency(_A("t40001_include1.h"), _A("string")));
|
||||
|
||||
REQUIRE_THAT(puml, HasComment("t40001 test diagram of type include"));
|
||||
REQUIRE_THAT(src, HasComment("t40001 test diagram of type include"));
|
||||
|
||||
save_puml(config.output_directory(), diagram->name + ".puml", puml);
|
||||
save_puml(config.output_directory(), diagram->name + ".puml", src);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -81,8 +80,31 @@ TEST_CASE("t40001", "[test-case][include]")
|
||||
}
|
||||
|
||||
{
|
||||
auto mmd = generate_include_mermaid(diagram, *model);
|
||||
auto src = generate_include_mermaid(diagram, *model);
|
||||
|
||||
save_mermaid(config.output_directory(), diagram->name + ".mmd", mmd);
|
||||
mermaid::AliasMatcher _A(src);
|
||||
using mermaid::HasComment;
|
||||
using mermaid::IsFile;
|
||||
using mermaid::IsFolder;
|
||||
using mermaid::IsIncludeDependency;
|
||||
|
||||
REQUIRE_THAT(src, IsFolder(_A("lib1")));
|
||||
REQUIRE_THAT(src, IsFile(_A("lib1.h")));
|
||||
REQUIRE_THAT(src, IsFile(_A("t40001.cc")));
|
||||
REQUIRE_THAT(src, IsFile(_A("t40001_include1.h")));
|
||||
|
||||
REQUIRE_THAT(src, IsFile(_A("string")));
|
||||
REQUIRE_THAT(src, IsFile(_A("yaml-cpp/yaml.h")));
|
||||
|
||||
REQUIRE_THAT(
|
||||
src, IsAssociation(_A("t40001.cc"), _A("t40001_include1.h")));
|
||||
REQUIRE_THAT(src, IsAssociation(_A("t40001_include1.h"), _A("lib1.h")));
|
||||
|
||||
REQUIRE_THAT(
|
||||
src, IsIncludeDependency(_A("t40001_include1.h"), _A("string")));
|
||||
|
||||
REQUIRE_THAT(src, HasComment("t40001 test diagram of type include"));
|
||||
|
||||
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,58 +29,58 @@ TEST_CASE("t40002", "[test-case][include]")
|
||||
REQUIRE(model->name() == "t40002_include");
|
||||
|
||||
{
|
||||
auto puml = generate_include_puml(diagram, *model);
|
||||
auto src = generate_include_puml(diagram, *model);
|
||||
|
||||
AliasMatcher _A(puml);
|
||||
AliasMatcher _A(src);
|
||||
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
REQUIRE_THAT(src, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(src, EndsWith("@enduml\n"));
|
||||
|
||||
REQUIRE_THAT(puml, IsFolder("lib1"));
|
||||
REQUIRE_THAT(puml, IsFolder("lib2"));
|
||||
REQUIRE_THAT(puml, IsFile("lib1.h"));
|
||||
REQUIRE_THAT(puml, IsFile("lib2.h"));
|
||||
REQUIRE_THAT(puml, !IsFile("lib2_detail.h"));
|
||||
REQUIRE_THAT(puml, IsFile("t40002.cc"));
|
||||
REQUIRE_THAT(puml, IsFile("lib1.cc"));
|
||||
REQUIRE_THAT(puml, IsFile("lib2.cc"));
|
||||
REQUIRE_THAT(src, IsFolder("lib1"));
|
||||
REQUIRE_THAT(src, IsFolder("lib2"));
|
||||
REQUIRE_THAT(src, IsFile("lib1.h"));
|
||||
REQUIRE_THAT(src, IsFile("lib2.h"));
|
||||
REQUIRE_THAT(src, !IsFile("lib2_detail.h"));
|
||||
REQUIRE_THAT(src, IsFile("t40002.cc"));
|
||||
REQUIRE_THAT(src, IsFile("lib1.cc"));
|
||||
REQUIRE_THAT(src, IsFile("lib2.cc"));
|
||||
|
||||
REQUIRE_THAT(puml, !IsFile("string"));
|
||||
REQUIRE_THAT(src, !IsFile("string"));
|
||||
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("t40002.cc"), _A("lib1.h")));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("lib1.h"), _A("lib2.h")));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("lib1.cc"), _A("lib1.h")));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("lib2.cc"), _A("lib2.h")));
|
||||
REQUIRE_THAT(src, IsAssociation(_A("t40002.cc"), _A("lib1.h")));
|
||||
REQUIRE_THAT(src, IsAssociation(_A("lib1.h"), _A("lib2.h")));
|
||||
REQUIRE_THAT(src, IsAssociation(_A("lib1.cc"), _A("lib1.h")));
|
||||
REQUIRE_THAT(src, IsAssociation(_A("lib2.cc"), _A("lib2.h")));
|
||||
|
||||
REQUIRE_THAT(puml,
|
||||
REQUIRE_THAT(src,
|
||||
HasLink(_A("t40002.cc"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/src/t40002.cc#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"t40002.cc"));
|
||||
|
||||
REQUIRE_THAT(puml,
|
||||
REQUIRE_THAT(src,
|
||||
HasLink(_A("lib1.cc"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/src/lib1/lib1.cc#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"lib1.cc"));
|
||||
|
||||
REQUIRE_THAT(puml,
|
||||
REQUIRE_THAT(src,
|
||||
HasLink(_A("lib1.h"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/include/lib1/lib1.h#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"lib1.h"));
|
||||
|
||||
REQUIRE_THAT(puml,
|
||||
REQUIRE_THAT(src,
|
||||
HasLink(_A("lib2.h"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/include/lib2/lib2.h#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"lib2.h"));
|
||||
|
||||
save_puml(config.output_directory(), diagram->name + ".puml", puml);
|
||||
save_puml(config.output_directory(), diagram->name + ".puml", src);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -112,8 +112,57 @@ TEST_CASE("t40002", "[test-case][include]")
|
||||
}
|
||||
|
||||
{
|
||||
auto mmd = generate_include_mermaid(diagram, *model);
|
||||
auto src = generate_include_mermaid(diagram, *model);
|
||||
|
||||
save_mermaid(config.output_directory(), diagram->name + ".mmd", mmd);
|
||||
mermaid::AliasMatcher _A(src);
|
||||
using mermaid::HasLink;
|
||||
using mermaid::IsFile;
|
||||
using mermaid::IsFolder;
|
||||
|
||||
REQUIRE_THAT(src, IsFolder(_A("lib1")));
|
||||
REQUIRE_THAT(src, IsFolder(_A("lib2")));
|
||||
REQUIRE_THAT(src, IsFile(_A("lib1.h")));
|
||||
REQUIRE_THAT(src, IsFile(_A("lib2.h")));
|
||||
REQUIRE_THAT(src, !IsFile(_A("lib2_detail.h")));
|
||||
REQUIRE_THAT(src, IsFile(_A("t40002.cc")));
|
||||
REQUIRE_THAT(src, IsFile(_A("lib1.cc")));
|
||||
REQUIRE_THAT(src, IsFile(_A("lib2.cc")));
|
||||
|
||||
REQUIRE_THAT(src, !IsFile(_A("string")));
|
||||
|
||||
REQUIRE_THAT(src, IsAssociation(_A("t40002.cc"), _A("lib1.h")));
|
||||
REQUIRE_THAT(src, IsAssociation(_A("lib1.h"), _A("lib2.h")));
|
||||
REQUIRE_THAT(src, IsAssociation(_A("lib1.cc"), _A("lib1.h")));
|
||||
REQUIRE_THAT(src, IsAssociation(_A("lib2.cc"), _A("lib2.h")));
|
||||
|
||||
REQUIRE_THAT(src,
|
||||
HasLink(_A("t40002.cc"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/src/t40002.cc#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"t40002.cc"));
|
||||
|
||||
REQUIRE_THAT(src,
|
||||
HasLink(_A("lib1.cc"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/src/lib1/lib1.cc#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"lib1.cc"));
|
||||
|
||||
REQUIRE_THAT(src,
|
||||
HasLink(_A("lib1.h"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/include/lib1/lib1.h#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"lib1.h"));
|
||||
|
||||
REQUIRE_THAT(src,
|
||||
HasLink(_A("lib2.h"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/include/lib2/lib2.h#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"lib2.h"));
|
||||
|
||||
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,25 +29,25 @@ TEST_CASE("t40003", "[test-case][include]")
|
||||
REQUIRE(model->name() == "t40003_include");
|
||||
|
||||
{
|
||||
auto puml = generate_include_puml(diagram, *model);
|
||||
auto src = generate_include_puml(diagram, *model);
|
||||
|
||||
AliasMatcher _A(puml);
|
||||
AliasMatcher _A(src);
|
||||
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
REQUIRE_THAT(src, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(src, EndsWith("@enduml\n"));
|
||||
|
||||
REQUIRE_THAT(puml, IsFolder("dependants"));
|
||||
REQUIRE_THAT(puml, IsFolder("dependencies"));
|
||||
REQUIRE_THAT(src, IsFolder("dependants"));
|
||||
REQUIRE_THAT(src, IsFolder("dependencies"));
|
||||
|
||||
REQUIRE_THAT(puml, IsFile("t1.h"));
|
||||
REQUIRE_THAT(puml, IsFile("t2.h"));
|
||||
REQUIRE_THAT(puml, IsFile("t3.h"));
|
||||
REQUIRE_THAT(src, IsFile("t1.h"));
|
||||
REQUIRE_THAT(src, IsFile("t2.h"));
|
||||
REQUIRE_THAT(src, IsFile("t3.h"));
|
||||
|
||||
REQUIRE_THAT(puml, !IsFile("t4.h"));
|
||||
REQUIRE_THAT(puml, IsFile("t5.h"));
|
||||
REQUIRE_THAT(puml, !IsFile("t6.h"));
|
||||
REQUIRE_THAT(src, !IsFile("t4.h"));
|
||||
REQUIRE_THAT(src, IsFile("t5.h"));
|
||||
REQUIRE_THAT(src, !IsFile("t6.h"));
|
||||
|
||||
save_puml(config.output_directory(), diagram->name + ".puml", puml);
|
||||
save_puml(config.output_directory(), diagram->name + ".puml", src);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -76,8 +76,24 @@ TEST_CASE("t40003", "[test-case][include]")
|
||||
}
|
||||
|
||||
{
|
||||
auto mmd = generate_include_mermaid(diagram, *model);
|
||||
auto src = generate_include_mermaid(diagram, *model);
|
||||
|
||||
save_mermaid(config.output_directory(), diagram->name + ".mmd", mmd);
|
||||
mermaid::AliasMatcher _A(src);
|
||||
using mermaid::HasLink;
|
||||
using mermaid::IsFile;
|
||||
using mermaid::IsFolder;
|
||||
|
||||
REQUIRE_THAT(src, IsFolder(_A("dependants")));
|
||||
REQUIRE_THAT(src, IsFolder(_A("dependencies")));
|
||||
|
||||
REQUIRE_THAT(src, IsFile(_A("t1.h")));
|
||||
REQUIRE_THAT(src, IsFile(_A("t2.h")));
|
||||
REQUIRE_THAT(src, IsFile(_A("t3.h")));
|
||||
|
||||
REQUIRE_THAT(src, !IsFile(_A("t4.h")));
|
||||
REQUIRE_THAT(src, IsFile(_A("t5.h")));
|
||||
REQUIRE_THAT(src, !IsFile(_A("t6.h")));
|
||||
|
||||
save_mermaid(config.output_directory(), diagram->name + ".mmd", src);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,6 +430,8 @@ struct AliasMatcher {
|
||||
std::regex{"class\\s" + alias_regex + "\\[\"" + name + "\"\\]"});
|
||||
patterns.push_back(
|
||||
std::regex{"subgraph\\s" + alias_regex + "\\[" + name + "\\]"});
|
||||
patterns.push_back(
|
||||
std::regex{"\\s\\s" + alias_regex + "\\[" + name + "\\]"}); // file
|
||||
|
||||
std::smatch base_match;
|
||||
|
||||
@@ -739,7 +741,13 @@ ContainsMatcher IsPackageDependency(std::string const &from,
|
||||
return ContainsMatcher(
|
||||
CasedString(fmt::format("{} -.-> {}", from, to), caseSensitivity));
|
||||
}
|
||||
|
||||
ContainsMatcher IsIncludeDependency(std::string const &from,
|
||||
std::string const &to,
|
||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||
{
|
||||
return ContainsMatcher(
|
||||
CasedString(fmt::format("{} -.-> {}", from, to), caseSensitivity));
|
||||
}
|
||||
}
|
||||
|
||||
ContainsMatcher IsConstraint(std::string const &from, std::string const &to,
|
||||
@@ -1105,6 +1113,20 @@ ContainsMatcher IsFile(std::string const &str,
|
||||
CasedString("file \"" + str + "\"", caseSensitivity));
|
||||
}
|
||||
|
||||
namespace mermaid {
|
||||
ContainsMatcher IsFolder(std::string const &str,
|
||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||
{
|
||||
return ContainsMatcher(CasedString("subgraph " + str, caseSensitivity));
|
||||
}
|
||||
|
||||
ContainsMatcher IsFile(std::string const &str,
|
||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||
{
|
||||
return ContainsMatcher(CasedString(str + "[", caseSensitivity));
|
||||
}
|
||||
}
|
||||
|
||||
ContainsMatcher IsDeprecated(std::string const &str,
|
||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ if not files:
|
||||
ok = 0
|
||||
|
||||
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
with ThreadPoolExecutor(max_workers=16) as executor:
|
||||
result = all(executor.map(generate_mermaid_diagram, files))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user