-
Notifications
You must be signed in to change notification settings - Fork 147
Extract examples from reference and display their results in a dashboard. #325
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
Merged
adpaco
merged 4 commits into
model-checking:main-153-2021-07-15
from
bdalrhm:reference-dashboard
Jul 19, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
| RUST_DIR=$SCRIPT_DIR/.. | ||
| export PATH=$SCRIPT_DIR:$PATH | ||
|
|
||
| cargo build --manifest-path src/tools/dashboard/Cargo.toml | ||
| cargo run --manifest-path src/tools/dashboard/Cargo.toml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| [package] | ||
| name = "dashboard" | ||
| version = "0.1.0" | ||
| edition = "2018" | ||
|
|
||
| [dependencies] | ||
| pulldown-cmark = { version = "0.8.0", default-features = false } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!/bin/bash | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| # `rustdoc` treats this script as `rustc` and sends code extracted from markdown | ||
| # files to stdin of this script. Instead of compiling the code, this scripts | ||
| # simply copies the contents of stdin to the location where `rustdoc` caches the | ||
| # "compiled" output. | ||
|
|
||
| FILE="$6" | ||
| BASE=`basename "$FILE"` | ||
| mkdir -p "$BASE" | ||
| cp "/dev/stdin" "$FILE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| //! Data structures representing the dashboard and their utilities. | ||
|
|
||
| use std::fmt::{Display, Formatter, Result, Write}; | ||
|
|
||
| /// This data structure holds the results of running a test or a suite. | ||
| #[derive(Clone, Debug)] | ||
| pub struct Node { | ||
| pub name: String, | ||
| pub num_pass: u32, | ||
| pub num_fail: u32, | ||
| } | ||
|
|
||
| impl Node { | ||
| /// Creates a new test [`Node`]. | ||
| pub fn new(name: String, num_pass: u32, num_fail: u32) -> Node { | ||
| Node { name, num_pass, num_fail } | ||
| } | ||
| } | ||
|
|
||
| /// Tree data structure representing a confidence dashboard. `children` | ||
| /// represent sub-tests and sub-suites of the current test suite. This tree | ||
| /// structure allows us to collect and display a summary for test results in an | ||
| /// organized manner. | ||
| #[derive(Clone, Debug)] | ||
| pub struct Tree { | ||
| pub data: Node, | ||
| pub children: Vec<Tree>, | ||
| } | ||
|
|
||
| impl Tree { | ||
| /// Creates a new [`Tree`] representing a dashboard or a part of it. | ||
| pub fn new(data: Node, children: Vec<Tree>) -> Tree { | ||
| Tree { data, children } | ||
| } | ||
|
|
||
| /// Merges two trees, if their root have equal node names, and returns the | ||
| /// merged tree. | ||
| pub fn merge(mut l: Tree, r: Tree) -> Option<Tree> { | ||
| if l.data.name != r.data.name { | ||
| return None; | ||
| } | ||
| // For each subtree of `r`... | ||
| for cnr in r.children { | ||
| // Look for a subtree of `l` with an equal root node name. | ||
| let index = l.children.iter().position(|cnl| cnl.data.name == cnr.data.name); | ||
| if let Some(index) = index { | ||
| // If you find one, merge it with `r`'s subtree. | ||
| let cnl = l.children.remove(index); | ||
| l.children.insert(index, Tree::merge(cnl, cnr)?); | ||
| } else { | ||
| // Otherwise, `r`'s subtree is new. So, add it to `l`'s | ||
| // list of subtrees. | ||
| l.children.push(cnr); | ||
| } | ||
| } | ||
| Some(Tree::new( | ||
| Node::new( | ||
| l.data.name, | ||
| l.data.num_pass + r.data.num_pass, | ||
| l.data.num_fail + r.data.num_fail, | ||
| ), | ||
| l.children, | ||
| )) | ||
| } | ||
|
|
||
| /// A helper format function that indents each level of the tree. | ||
| fn fmt_aux(&self, p: usize, f: &mut Formatter<'_>) -> Result { | ||
| // Do not print line numbers. | ||
| if self.children.len() == 0 { | ||
| return Ok(()); | ||
| } | ||
| // Write `p` spaces into the formatter. | ||
| f.write_fmt(format_args!("{:1$}", "", p))?; | ||
| f.write_str(&self.data.name)?; | ||
| if self.data.num_pass > 0 { | ||
| f.write_fmt(format_args!(" ✔️ {}", self.data.num_pass))?; | ||
| } | ||
| if self.data.num_fail > 0 { | ||
| f.write_fmt(format_args!(" ❌ {}", self.data.num_fail))?; | ||
| } | ||
| f.write_char('\n')?; | ||
| for cn in &self.children { | ||
| cn.fmt_aux(p + 2, f)?; | ||
| } | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| impl Display for Tree { | ||
| fn fmt(&self, f: &mut Formatter<'_>) -> Result { | ||
| self.fmt_aux(0, f) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| mod dashboard; | ||
| mod reference; | ||
|
|
||
| fn main() { | ||
| reference::display_reference_dashboard(); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.