Skip to content

Commit

Permalink
Add test for github issue #172
Browse files Browse the repository at this point in the history
  • Loading branch information
regexident committed Apr 26, 2023
1 parent fbc8d17 commit cffa0cf
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/generate_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,16 @@ mod github_issue_80 {
);
}
}

mod github_issue_172 {
test_cmd!(
args: "generate graph \
--with-types \
--with-uses \
--with-traits \
--layout dot",
success: true,
color_mode: ColorMode::Plain,
project: github_issue_172
);
}
4 changes: 4 additions & 0 deletions tests/projects/github_issue_172/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "github_issue_172"
version = "0.1.0"
edition = "2018"
24 changes: 24 additions & 0 deletions tests/projects/github_issue_172/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
struct AThing;

pub mod alpha {
use delta::ATrait;
pub mod beta {
use crate::AThing;
use chrono::DateTime;

pub struct AnotherThing {
dt: chrono::Duration,
}

pub mod gamma {

use rand::CryptoRng;
}
}
pub mod delta {
use super::beta::AnotherThing;
use rand::Rng;

pub trait ATrait {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
source: tests/generate_graph.rs
expression: output
---
STDERR:

STDOUT:
digraph {

graph [
label="github_issue_172",
labelloc=t,

pad=0.4,

// Consider rendering the graph using a different layout algorithm, such as:
// [dot, neato, twopi, circo, fdp, sfdp]
layout=dot,
overlap=false,
splines="line",
rankdir=LR,

fontname="Helvetica",
fontsize="36",
];

node [
fontname="monospace",
fontsize="10",
shape="record",
style="filled",
];

edge [
fontname="monospace",
fontsize="10",
];

"github_issue_172" [label="crate|github_issue_172", fillcolor="#5397c8"]; // "crate" node
"github_issue_172::AThing" [label="pub(crate) struct|AThing", fillcolor="#f8c04c"]; // "struct" node
"github_issue_172::alpha" [label="pub mod|alpha", fillcolor="#81c169"]; // "mod" node
"github_issue_172::alpha::beta" [label="pub mod|alpha::beta", fillcolor="#81c169"]; // "mod" node
"github_issue_172::alpha::beta::AnotherThing" [label="pub struct|alpha::beta::AnotherThing", fillcolor="#81c169"]; // "struct" node
"github_issue_172::alpha::beta::gamma" [label="pub mod|alpha::beta::gamma", fillcolor="#81c169"]; // "mod" node
"github_issue_172::alpha::delta" [label="pub mod|alpha::delta", fillcolor="#81c169"]; // "mod" node
"github_issue_172::alpha::delta::ATrait" [label="pub trait|alpha::delta::ATrait", fillcolor="#81c169"]; // "trait" node

"github_issue_172" -> "github_issue_172::AThing" [label="owns", color="#000000", style="solid"] [constraint=true]; // "owns" edge
"github_issue_172" -> "github_issue_172::alpha" [label="owns", color="#000000", style="solid"] [constraint=true]; // "owns" edge
"github_issue_172::alpha" -> "github_issue_172::alpha::beta" [label="owns", color="#000000", style="solid"] [constraint=true]; // "owns" edge
"github_issue_172::alpha" -> "github_issue_172::alpha::delta" [label="owns", color="#000000", style="solid"] [constraint=true]; // "owns" edge
"github_issue_172::alpha" -> "github_issue_172::alpha::delta::ATrait" [label="uses", color="#7f7f7f", style="dashed"] [constraint=false]; // "uses" edge
"github_issue_172::alpha::beta" -> "github_issue_172::AThing" [label="uses", color="#7f7f7f", style="dashed"] [constraint=false]; // "uses" edge
"github_issue_172::alpha::beta" -> "github_issue_172::alpha::beta::AnotherThing" [label="owns", color="#000000", style="solid"] [constraint=true]; // "owns" edge
"github_issue_172::alpha::beta" -> "github_issue_172::alpha::beta::gamma" [label="owns", color="#000000", style="solid"] [constraint=true]; // "owns" edge
"github_issue_172::alpha::delta" -> "github_issue_172::alpha::beta::AnotherThing" [label="uses", color="#7f7f7f", style="dashed"] [constraint=false]; // "uses" edge
"github_issue_172::alpha::delta" -> "github_issue_172::alpha::delta::ATrait" [label="owns", color="#000000", style="solid"] [constraint=true]; // "owns" edge

}

0 comments on commit cffa0cf

Please sign in to comment.