Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add clang-uml dependency and test #120

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Install the base system with all tool dependencies
COPY .devcontainer/base/apt-requirements.json /tmp/apt-requirements-base.json
COPY .devcontainer/base/apt-repositories.json /tmp/apt-repositories.json
COPY .devcontainer/gcc-${GCC_VERSION}/apt-requirements.json /tmp/apt-requirements-gcc.json
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends jq \
&& jq -s '.[0] * .[1]' /tmp/apt-requirements-base.json /tmp/apt-requirements-gcc.json > /tmp/apt-requirements.json \
&& jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements.json | xargs apt-get install -y --no-install-recommends \
&& jq -r 'to_entries | .[] | .key + ":" + .value' /tmp/apt-repositories.json | xargs add-apt-repository \
&& rm /tmp/apt-requirements* \
&& rm -rf /var/lib/apt/lists/*

Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/base/apt-repositories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ppa": "bkryza/clang-uml"
}
1 change: 1 addition & 0 deletions .devcontainer/base/apt-requirements.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"software-properties-common" : "0.99.22.7",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
"software-properties-common" : "0.99.22.7",
"software-properties-common": "0.99.22.7",

"bzip2": "1.0.8-5build1",
"ca-certificates": "20230311ubuntu0.22.04.1",
"gdb": "12.1-0ubuntu1~22.04",
Expand Down
15 changes: 8 additions & 7 deletions .devcontainer/clang-15/apt-requirements.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"clang-15": "1:15.0.7-0ubuntu0.22.04.2",
"clangd-15": "1:15.0.7-0ubuntu0.22.04.2",
"clang-format-15": "1:15.0.7-0ubuntu0.22.04.2",
"clang-tidy-15": "1:15.0.7-0ubuntu0.22.04.2",
"clang-tools-15": "1:15.0.7-0ubuntu0.22.04.2",
"lld-15": "1:15.0.7-0ubuntu0.22.04.2",
"llvm-15": "1:15.0.7-0ubuntu0.22.04.2"
"clang-15": "1:15.0.7-0ubuntu0.22.04.3",
"clangd-15": "1:15.0.7-0ubuntu0.22.04.3",
"clang-format-15": "1:15.0.7-0ubuntu0.22.04.3",
"clang-tidy-15": "1:15.0.7-0ubuntu0.22.04.3",
"clang-tools-15": "1:15.0.7-0ubuntu0.22.04.3",
"lld-15": "1:15.0.7-0ubuntu0.22.04.3",
"llvm-15": "1:15.0.7-0ubuntu0.22.04.3",
"clang-uml": "0.3.8-0ubuntu1ppa1~jammy"
}
13 changes: 13 additions & 0 deletions test/.clang-uml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
compilation_database_dir: build/clang
output_directory: puml
diagrams:
test_class:
type: class
glob:
- clang-tools/clang-uml-class.cpp
comment_parser: clang
using_namespace:
- clanguml::t00002
include:
namespaces:
- clanguml::t00002
7 changes: 7 additions & 0 deletions test/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
"configurePreset": "clang",
"targets": ["test-clang-iwyu"]
},
{
"name": "clang-uml",
"configurePreset": "clang",
"targets": [
"test-clang-uml"
]
Comment on lines +62 to +64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MegaLinter] reported by reviewdog 🐶

Suggested change
"targets": [
"test-clang-uml"
]
"targets": ["test-clang-uml"]

},
{
"name": "coverage",
"configurePreset": "coverage",
Expand Down
3 changes: 3 additions & 0 deletions test/clang-tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ set_property(TARGET test-clang-tidy PROPERTY CXX_CLANG_TIDY clang-tidy -checks=-

add_executable(test-clang-iwyu EXCLUDE_FROM_ALL main.cpp)
set_property(TARGET test-clang-iwyu PROPERTY CXX_INCLUDE_WHAT_YOU_USE iwyu)

add_executable(test-clang-uml EXCLUDE_FROM_ALL clang-uml-class.cpp)
set_property(TARGET test-clang-uml PROPERTY CXX_INCLUDE_WHAT_YOU_USE iwyu)
91 changes: 91 additions & 0 deletions test/clang-tools/clang-uml-class.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include <vector>

namespace clanguml {
namespace t00002 {

/// \brief This is class A
class A {
public:
/// Abstract foo_a
virtual void foo_a() = 0;
/// Abstract foo_c
virtual void foo_c() = 0;
};

/// \brief This is class B
class B : public A {
public:
virtual void foo_a() override { }
};

/// @brief This is class C - class C has a long comment
///
/// Vivamus integer non suscipit taciti mus etiam at primis tempor sagittis sit,
/// euismod libero facilisi aptent elementum felis blandit cursus gravida sociis
/// erat ante, eleifend lectus nullam dapibus netus feugiat curae curabitur est
/// ad.
class C : public A {
public:
/// Do nothing unless override is provided
virtual void foo_c() override { }
};

/// This is class D
/// which is a little like B
/// and a little like C
class D : public B, public C {
public:
/**
* Forward foo_a
*/
void foo_a() override
{
for (auto a : as)
a->foo_a();
}

/**
* Forward foo_c
*/
void foo_c() override
{
for (auto a : as)
a->foo_c();
}

private:
/// All the A pointers
std::vector<A *> as;
};

class E : virtual public B, public virtual C {
public:
///
/// Forward foo_a
///
void foo_a() override
{
for (auto a : as)
a->foo_a();
}

///
/// Forward foo_c
///
void foo_c() override
{
for (auto a : as)
a->foo_c();
}

private:
/// All the A pointers
std::vector<A *> as;
};
} // namespace t00002
} // namespace clanguml

int main()
{
return 0;
}
14 changes: 14 additions & 0 deletions test/testsuite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,17 @@ teardown() {
assert_success
assert_output "Hello World!"
}

# bats test_tags=tc:16
@test "using clang-uml to generate uml class diagram" {
run cmake --preset clang
assert_success

run cmake --build --preset clang-uml
assert_success

run cd tests
run clang-uml
assert_success
assert_file_exist puml/test_class.puml
}
Loading