Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ __pycache__/
src/test/rustdoc-gui/src/**.lock

# Before adding new lines, see the comment at the top.
/src/test/ref
/src/tools/dashboard/Cargo.lock
/src/tools/dashboard/target
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ exclude = [
"src/tools/x",
# stdarch has its own Cargo workspace
"library/stdarch",
"src/tools/dashboard",
]

[profile.release.package.compiler_builtins]
Expand Down
10 changes: 10 additions & 0 deletions scripts/display-dashboard.sh
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
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ impl<'a> Builder<'a> {
test::SMACK,
test::CargoRMC,
test::Expected,
test::Ref,
// Run run-make last, since these won't pass without make on Windows
test::RunMake,
),
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,8 @@ default_test!(CargoRMC { path: "src/test/cargo-rmc", mode: "cargo-rmc", suite: "

default_test!(Expected { path: "src/test/expected", mode: "expected", suite: "expected" });

default_test!(Ref { path: "src/test/ref", mode: "rmc", suite: "ref" });

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
struct Compiletest {
compiler: Compiler,
Expand Down
10 changes: 10 additions & 0 deletions src/tools/dashboard/Cargo.toml
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 }
13 changes: 13 additions & 0 deletions src/tools/dashboard/print.sh
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"
95 changes: 95 additions & 0 deletions src/tools/dashboard/src/dashboard.rs
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> {
Comment thread
bdalrhm marked this conversation as resolved.
Outdated
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)
}
}
9 changes: 9 additions & 0 deletions src/tools/dashboard/src/main.rs
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();
}
Loading