From e1d46512bf620148f2ae5d87c17dc1a6a43459b2 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 19 Sep 2019 11:37:36 -0700 Subject: [PATCH 01/34] [datatest-stable] introduce data-driven testing framework Introduce `datatest-stable`, a data-driven testing framework that is meant to be a simple version of `datatest` that is usable with a stable rust compiler without using the `RUSTC_BOOTSTRAP` mechanism for allowing nightly features to be used with a stable compiler. Closes: #1016 Approved by: sunshowers --- datatest-stable/Cargo.toml | 19 +++ datatest-stable/src/lib.rs | 30 ++++ datatest-stable/src/macros.rs | 25 +++ datatest-stable/src/runner.rs | 285 +++++++++++++++++++++++++++++++ datatest-stable/src/utils.rs | 30 ++++ datatest-stable/tests/example.rs | 12 ++ datatest-stable/tests/files/a | 1 + datatest-stable/tests/files/b | 1 + 8 files changed, 403 insertions(+) create mode 100644 datatest-stable/Cargo.toml create mode 100644 datatest-stable/src/lib.rs create mode 100644 datatest-stable/src/macros.rs create mode 100644 datatest-stable/src/runner.rs create mode 100644 datatest-stable/src/utils.rs create mode 100644 datatest-stable/tests/example.rs create mode 100644 datatest-stable/tests/files/a create mode 100644 datatest-stable/tests/files/b diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml new file mode 100644 index 000000000..5b4bbeb2a --- /dev/null +++ b/datatest-stable/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "datatest-stable" +version = "0.1.0" +authors = ["Libra Association "] +license = "Apache-2.0" +publish = false +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +regex = "1.3.1" +walkdir = "2.2.9" +structopt = "0.3.2" +termcolor = "1.0.5" + +[[test]] +name = "example" +harness = false diff --git a/datatest-stable/src/lib.rs b/datatest-stable/src/lib.rs new file mode 100644 index 000000000..686f420eb --- /dev/null +++ b/datatest-stable/src/lib.rs @@ -0,0 +1,30 @@ +//! `datatest-stable` is a very simple test harness intended to meet some of the needs provided by +//! the `datatest` crate when using a stable rust compiler without using the `RUSTC_BOOTSTRAP` hack +//! to use nightly features on the stable track. +//! +//! In order to setup data-driven tests for a particular test target you must do the following: +//! 1. Configure the test target by setting the following in the `Cargo.toml` +//! ```lang=toml +//! [[test]] +//! name = "" +//! harness = false +//! ``` +//! +//! 2. Call the `datatest_stable::harness!(testfn, root, pattern)` macro with the following +//! parameters: +//! * `testfn` - The test function to be executed on each matching input. This function must have +//! the type `fn(&Path) -> datatest_stable::Result<()>` +//! * `root` - The path to the root directory where the input files live. This path is relative to +//! the root of the crate. +//! * `pattern` - the regex used to match against and select each file to be tested. +//! +//! The three parameters can be repeated if you have multiple sets of data-driven tests to be run: +//! `datatest_stable::harness!(testfn1, root1, pattern1, testfn2, root2, pattern2)` + +mod macros; +mod runner; +mod utils; + +pub type Result = ::std::result::Result>; + +pub use self::runner::{runner, Requirements}; diff --git a/datatest-stable/src/macros.rs b/datatest-stable/src/macros.rs new file mode 100644 index 000000000..c4adb3a91 --- /dev/null +++ b/datatest-stable/src/macros.rs @@ -0,0 +1,25 @@ +/// `datatest-stable` test harness entry point. Should be declared in the test module. +/// +/// Also, `harness` should be set to `false` for that test module in `Cargo.toml` (see [Configuring +/// a target](https://doc.rust-lang.org/cargo/reference/manifest.html#configuring-a-target)). +#[macro_export] +macro_rules! harness { + ( $( $name:path, $root:expr, $pattern:expr ),+ $(,)* ) => { + fn main() { + let mut requirements = Vec::new(); + + $( + requirements.push( + $crate::Requirements::new( + $name, + stringify!($name).to_string(), + $root.to_string(), + $pattern.to_string() + ) + ); + )+ + + $crate::runner(&requirements); + } + }; +} diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs new file mode 100644 index 000000000..8cff1dce9 --- /dev/null +++ b/datatest-stable/src/runner.rs @@ -0,0 +1,285 @@ +use crate::{utils, Result}; +use std::{ + io::{self, Write}, + num::NonZeroUsize, + panic::{catch_unwind, AssertUnwindSafe}, + path::Path, + process, + sync::mpsc::{channel, Sender}, + thread, +}; +use structopt::StructOpt; +use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; + +#[derive(Debug, StructOpt)] +#[structopt(about = "Datatest-harness for running data-driven tests")] +struct TestOpts { + /// The FILTER string is tested against the name of all tests, and only those tests whose names + /// contain the filter are run. + filter: Option, + #[structopt(long = "exact")] + /// Exactly match filters rather than by substring + filter_exact: bool, + #[structopt(long, default_value = "32", env = "RUST_TEST_THREADS")] + /// Number of threads used for running tests in parallel + test_threads: NonZeroUsize, + #[structopt(short = "q", long)] + /// Output minimal information + quiet: bool, + #[structopt(long)] + /// We already can't capture anything but we don't want arg parsing to fail so this is a noop + nocapture: bool, +} + +pub fn runner(reqs: &[Requirements]) { + let options = TestOpts::from_args(); + + let tests = reqs.iter().flat_map(|req| req.expand()).collect(); + + match run_tests(options, tests) { + Ok(true) => {} + Ok(false) => process::exit(101), + Err(e) => { + eprintln!("error: io error when running tests: {:?}", e); + process::exit(101); + } + } +} + +struct Test { + testfn: Box Result<()> + Send>, + name: String, +} + +enum TestResult { + Ok, + Failed, + FailedWithMsg(String), +} + +fn run_tests(options: TestOpts, tests: Vec) -> io::Result { + let total = tests.len(); + + // Filter out tests + let mut remaining = match &options.filter { + None => tests, + Some(filter) => tests + .into_iter() + .filter(|test| { + if options.filter_exact { + test.name == filter[..] + } else { + test.name.contains(&filter[..]) + } + }) + .rev() + .collect(), + }; + + let filtered_out = total - remaining.len(); + let mut summary = TestSummary::new(total, filtered_out); + + if !options.quiet { + summary.write_starting_msg()?; + } + + let (tx, rx) = channel(); + + let mut pending = 0; + while pending > 0 || !remaining.is_empty() { + while pending < options.test_threads.get() && !remaining.is_empty() { + let test = remaining.pop().unwrap(); + run_test(test, tx.clone()); + pending += 1; + } + + let (name, result) = rx.recv().unwrap(); + summary.handle_result(name, result)?; + + pending -= 1; + } + + // Write Test Summary + if !options.quiet { + summary.write_summary()?; + } + + Ok(summary.success()) +} + +fn run_test(test: Test, channel: Sender<(String, TestResult)>) { + let Test { name, testfn } = test; + + let cfg = thread::Builder::new().name(name.clone()); + cfg.spawn(move || { + let result = match catch_unwind(AssertUnwindSafe(|| testfn())) { + Ok(Ok(())) => TestResult::Ok, + Ok(Err(e)) => TestResult::FailedWithMsg(format!("{:?}", e)), + Err(_) => TestResult::Failed, + }; + + channel.send((name, result)).unwrap(); + }) + .unwrap(); +} + +struct TestSummary { + stdout: StandardStream, + total: usize, + filtered_out: usize, + passed: usize, + failed: Vec, +} + +impl TestSummary { + fn new(total: usize, filtered_out: usize) -> Self { + Self { + stdout: StandardStream::stdout(ColorChoice::Auto), + total, + filtered_out, + passed: 0, + failed: Vec::new(), + } + } + + fn handle_result(&mut self, name: String, result: TestResult) -> io::Result<()> { + write!(self.stdout, "test {} ... ", name)?; + match result { + TestResult::Ok => { + self.passed += 1; + self.write_ok()?; + } + TestResult::Failed => { + self.failed.push(name); + self.write_failed()?; + } + TestResult::FailedWithMsg(msg) => { + self.failed.push(name); + self.write_failed()?; + writeln!(self.stdout)?; + + write!(self.stdout, "Error: {}", msg)?; + } + } + writeln!(self.stdout)?; + Ok(()) + } + + fn write_ok(&mut self) -> io::Result<()> { + self.stdout + .set_color(ColorSpec::new().set_fg(Some(Color::Green)))?; + write!(self.stdout, "ok")?; + self.stdout.reset()?; + Ok(()) + } + + fn write_failed(&mut self) -> io::Result<()> { + self.stdout + .set_color(ColorSpec::new().set_fg(Some(Color::Red)))?; + write!(self.stdout, "FAILED")?; + self.stdout.reset()?; + Ok(()) + } + + fn write_starting_msg(&mut self) -> io::Result<()> { + writeln!(self.stdout)?; + writeln!( + self.stdout, + "running {} tests", + self.total - self.filtered_out + )?; + Ok(()) + } + + fn write_summary(&mut self) -> io::Result<()> { + // Print out the failing tests + if !self.failed.is_empty() { + writeln!(self.stdout)?; + writeln!(self.stdout, "failures:")?; + for name in &self.failed { + writeln!(self.stdout, " {}", name)?; + } + } + + writeln!(self.stdout)?; + write!(self.stdout, "test result: ")?; + if self.failed.is_empty() { + self.write_ok()?; + } else { + self.write_failed()?; + } + writeln!( + self.stdout, + ". {} passed; {} failed; {} filtered out", + self.passed, + self.failed.len(), + self.filtered_out + )?; + writeln!(self.stdout)?; + Ok(()) + } + + fn success(&self) -> bool { + self.failed.is_empty() + } +} + +pub struct Requirements { + test: fn(&Path) -> Result<()>, + test_name: String, + root: String, + pattern: String, +} + +impl Requirements { + pub fn new( + test: fn(&Path) -> Result<()>, + test_name: String, + root: String, + pattern: String, + ) -> Self { + Self { + test, + test_name, + root, + pattern, + } + } + + /// Generate standard test descriptors ([`test::TestDescAndFn`]) from the descriptor of + /// `#[datatest::files(..)]`. + /// + /// Scans all files in a given directory, finds matching ones and generates a test descriptor + /// for each of them. + fn expand(&self) -> Vec { + let root = Path::new(&self.root).to_path_buf(); + + let re = regex::Regex::new(&self.pattern) + .unwrap_or_else(|_| panic!("invalid regular expression: '{}'", self.pattern)); + + let tests: Vec<_> = utils::iterate_directory(&root) + .filter_map(|path| { + let input_path = path.to_string_lossy(); + if re.is_match(&input_path) { + let testfn = self.test; + let name = utils::derive_test_name(&root, &path, &self.test_name); + let testfn = Box::new(move || (testfn)(&path)); + + Some(Test { testfn, name }) + } else { + None + } + }) + .collect(); + + // We want to avoid silent fails due to typos in regexp! + if tests.is_empty() { + panic!( + "no test cases found for test '{}'. Scanned directory: '{}' with pattern '{}'", + self.test_name, self.root, self.pattern, + ); + } + + tests + } +} diff --git a/datatest-stable/src/utils.rs b/datatest-stable/src/utils.rs new file mode 100644 index 000000000..f2c0c8973 --- /dev/null +++ b/datatest-stable/src/utils.rs @@ -0,0 +1,30 @@ +use std::path::{Path, PathBuf}; + +/// Helper function to iterate through all the files in the given directory, skipping hidden files, +/// and return an iterator of their paths. +pub fn iterate_directory(path: &Path) -> impl Iterator { + walkdir::WalkDir::new(path) + .into_iter() + .map(::std::result::Result::unwrap) + .filter(|entry| { + entry.file_type().is_file() + && entry + .file_name() + .to_str() + .map_or(false, |s| !s.starts_with('.')) // Skip hidden files + }) + .map(|entry| entry.path().to_path_buf()) +} + +pub fn derive_test_name(root: &Path, path: &Path, test_name: &str) -> String { + let relative = path.strip_prefix(root).unwrap_or_else(|_| { + panic!( + "failed to strip prefix '{}' from path '{}'", + root.display(), + path.display() + ) + }); + let mut test_name = test_name.to_string(); + test_name.push_str(&format!("::{}", relative.display())); + test_name +} diff --git a/datatest-stable/tests/example.rs b/datatest-stable/tests/example.rs new file mode 100644 index 000000000..cff8845b0 --- /dev/null +++ b/datatest-stable/tests/example.rs @@ -0,0 +1,12 @@ +use datatest_stable::Result; +use std::{fs::File, io::Read, path::Path}; + +fn test_artifact(path: &Path) -> Result<()> { + let mut file = File::open(path)?; + let mut contents = String::new(); + file.read_to_string(&mut contents)?; + + Ok(()) +} + +datatest_stable::harness!(test_artifact, "tests/files", r"^.*/*"); diff --git a/datatest-stable/tests/files/a b/datatest-stable/tests/files/a new file mode 100644 index 000000000..b328fe4aa --- /dev/null +++ b/datatest-stable/tests/files/a @@ -0,0 +1 @@ +baz stuff diff --git a/datatest-stable/tests/files/b b/datatest-stable/tests/files/b new file mode 100644 index 000000000..9f4b6d8bf --- /dev/null +++ b/datatest-stable/tests/files/b @@ -0,0 +1 @@ +This is a test file From 14c1ffa7379d3435670e0beec0e91039355de6d1 Mon Sep 17 00:00:00 2001 From: Tristan Debrunner Date: Thu, 3 Oct 2019 15:10:18 -0600 Subject: [PATCH 02/34] Add generic descriptions, repositories, and homepages to Cargo.toml's Closes: #1194 Approved by: huitseeker --- datatest-stable/Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 5b4bbeb2a..aab6e704e 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -2,6 +2,9 @@ name = "datatest-stable" version = "0.1.0" authors = ["Libra Association "] +description = "Libra datatest-stable" +repository = "https://github.com/libra/libra" +homepage = "https://libra.org" license = "Apache-2.0" publish = false edition = "2018" From 9262a91b12e84bc7a49b9d598444fbbd56af8d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Tue, 8 Oct 2019 13:52:36 -0700 Subject: [PATCH 03/34] remove underscrores & dashes from descriptions Closes: #1194 Approved by: huitseeker --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index aab6e704e..614201925 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -2,7 +2,7 @@ name = "datatest-stable" version = "0.1.0" authors = ["Libra Association "] -description = "Libra datatest-stable" +description = "Libra datatest stable" repository = "https://github.com/libra/libra" homepage = "https://libra.org" license = "Apache-2.0" From dab1040cf967eea4b3ee8e4d1fe0a24f83339b11 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Mon, 4 Nov 2019 15:19:20 -0800 Subject: [PATCH 04/34] [lint] ensure all *.{rs,sh} files have a license header Closes: #1609 Approved by: davidiw --- datatest-stable/src/lib.rs | 3 +++ datatest-stable/src/macros.rs | 3 +++ datatest-stable/src/runner.rs | 3 +++ datatest-stable/src/utils.rs | 3 +++ datatest-stable/tests/example.rs | 3 +++ 5 files changed, 15 insertions(+) diff --git a/datatest-stable/src/lib.rs b/datatest-stable/src/lib.rs index 686f420eb..cb7d4589b 100644 --- a/datatest-stable/src/lib.rs +++ b/datatest-stable/src/lib.rs @@ -1,3 +1,6 @@ +// Copyright (c) The Libra Core Contributors +// SPDX-License-Identifier: Apache-2.0 + //! `datatest-stable` is a very simple test harness intended to meet some of the needs provided by //! the `datatest` crate when using a stable rust compiler without using the `RUSTC_BOOTSTRAP` hack //! to use nightly features on the stable track. diff --git a/datatest-stable/src/macros.rs b/datatest-stable/src/macros.rs index c4adb3a91..be9b9c5c8 100644 --- a/datatest-stable/src/macros.rs +++ b/datatest-stable/src/macros.rs @@ -1,3 +1,6 @@ +// Copyright (c) The Libra Core Contributors +// SPDX-License-Identifier: Apache-2.0 + /// `datatest-stable` test harness entry point. Should be declared in the test module. /// /// Also, `harness` should be set to `false` for that test module in `Cargo.toml` (see [Configuring diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs index 8cff1dce9..3abe56c71 100644 --- a/datatest-stable/src/runner.rs +++ b/datatest-stable/src/runner.rs @@ -1,3 +1,6 @@ +// Copyright (c) The Libra Core Contributors +// SPDX-License-Identifier: Apache-2.0 + use crate::{utils, Result}; use std::{ io::{self, Write}, diff --git a/datatest-stable/src/utils.rs b/datatest-stable/src/utils.rs index f2c0c8973..a76932c34 100644 --- a/datatest-stable/src/utils.rs +++ b/datatest-stable/src/utils.rs @@ -1,3 +1,6 @@ +// Copyright (c) The Libra Core Contributors +// SPDX-License-Identifier: Apache-2.0 + use std::path::{Path, PathBuf}; /// Helper function to iterate through all the files in the given directory, skipping hidden files, diff --git a/datatest-stable/tests/example.rs b/datatest-stable/tests/example.rs index cff8845b0..1d3c11ed0 100644 --- a/datatest-stable/tests/example.rs +++ b/datatest-stable/tests/example.rs @@ -1,3 +1,6 @@ +// Copyright (c) The Libra Core Contributors +// SPDX-License-Identifier: Apache-2.0 + use datatest_stable::Result; use std::{fs::File, io::Read, path::Path}; From ebd4c3831f5d6ed729e7915b6eb20de55e30d286 Mon Sep 17 00:00:00 2001 From: Todd Nowacki Date: Tue, 22 Oct 2019 15:15:53 -0700 Subject: [PATCH 05/34] [language][Move] Added test framework - Added test framework for Move lang expected output tests - Added tests to check all of the stdlib files Closes: #1624 Approved by: vgao1996 --- datatest-stable/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/src/lib.rs b/datatest-stable/src/lib.rs index cb7d4589b..03cb71805 100644 --- a/datatest-stable/src/lib.rs +++ b/datatest-stable/src/lib.rs @@ -26,7 +26,7 @@ mod macros; mod runner; -mod utils; +pub mod utils; pub type Result = ::std::result::Result>; From 2af682a1e26ae672745b79a687fc8990f4d2f10b Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Mon, 25 Nov 2019 16:48:09 -0600 Subject: [PATCH 06/34] Forbid unsafe code throughout the codebase, with a few exceptions One instance of unsafe code was deleted from libra-swarm, crates which use no unsafe code have top level `#![forbid(unsafe_code)]`, and crates which use unsafe code now forbid unsafe code in all other files. Closes: #1833 Approved by: bmwill --- datatest-stable/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/datatest-stable/src/lib.rs b/datatest-stable/src/lib.rs index 03cb71805..cf7615ff5 100644 --- a/datatest-stable/src/lib.rs +++ b/datatest-stable/src/lib.rs @@ -1,6 +1,8 @@ // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 +#![forbid(unsafe_code)] + //! `datatest-stable` is a very simple test harness intended to meet some of the needs provided by //! the `datatest` crate when using a stable rust compiler without using the `RUSTC_BOOTSTRAP` hack //! to use nightly features on the stable track. From 961ad68366e5c876dffb788c7f702b5fe9ef71d5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 15 Mar 2020 20:00:51 +0000 Subject: [PATCH 07/34] Bump regex from 1.3.4 to 1.3.5 Bumps [regex](https://github.com/rust-lang/regex) from 1.3.4 to 1.3.5. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.3.4...1.3.5) Signed-off-by: dependabot-preview[bot] Closes: #2941 Approved by: rexhoffman --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 614201925..b24207090 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.3.1" +regex = "1.3.5" walkdir = "2.2.9" structopt = "0.3.2" termcolor = "1.0.5" From e22c350cbe9faa2f61e2b6e3021b6d889b29e76c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2020 07:41:10 +0000 Subject: [PATCH 08/34] Bump structopt from 0.3.11 to 0.3.12 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.11...v0.3.12) Signed-off-by: dependabot-preview[bot] Closes: #3033 Approved by: rexhoffman --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index b24207090..d3e17dc55 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" [dependencies] regex = "1.3.5" walkdir = "2.2.9" -structopt = "0.3.2" +structopt = "0.3.12" termcolor = "1.0.5" [[test]] From ec69f3d36e1d54fda581c364f186b94824b32e56 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2020 07:49:08 +0000 Subject: [PATCH 09/34] Bump regex from 1.3.5 to 1.3.6 Bumps [regex](https://github.com/rust-lang/regex) from 1.3.5 to 1.3.6. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.3.5...1.3.6) Signed-off-by: dependabot-preview[bot] Closes: #3121 Approved by: rexhoffman --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index d3e17dc55..c69ba6c37 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.3.5" +regex = "1.3.6" walkdir = "2.2.9" structopt = "0.3.12" termcolor = "1.0.5" From 1dd5a13205c64086d66eb202a5506f097e43cd28 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 7 Apr 2020 15:04:51 -0700 Subject: [PATCH 10/34] datatest: enable listing of tests Teach test binaries built using `datatest-stable` to be able to list the names of each test with the `--list` option. This matches the behavior of the `--list` option with test binaries built using the default test harness. Closes: #3318 Approved by: sausagee --- datatest-stable/src/runner.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs index 3abe56c71..af1e3701b 100644 --- a/datatest-stable/src/runner.rs +++ b/datatest-stable/src/runner.rs @@ -32,12 +32,25 @@ struct TestOpts { #[structopt(long)] /// We already can't capture anything but we don't want arg parsing to fail so this is a noop nocapture: bool, + #[structopt(long)] + /// List all tests + list: bool, } pub fn runner(reqs: &[Requirements]) { let options = TestOpts::from_args(); - let tests = reqs.iter().flat_map(|req| req.expand()).collect(); + let tests: Vec = reqs.iter().flat_map(|req| req.expand()).collect(); + + if options.list { + for test in &tests { + println!("{}: test", test.name); + } + + println!(); + println!("{} tests, 0 benchmarks", tests.len()); + return; + } match run_tests(options, tests) { Ok(true) => {} From 6549dd78a2c2cc5be7e3257bb39519d45a2c07a9 Mon Sep 17 00:00:00 2001 From: Rex Hoffman Date: Wed, 8 Apr 2020 09:14:48 -0700 Subject: [PATCH 11/34] [test] unblock the use of --ignored in libra-fuzzer Closes: #3328 Approved by: bmwill --- datatest-stable/src/runner.rs | 74 ++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs index af1e3701b..730819308 100644 --- a/datatest-stable/src/runner.rs +++ b/datatest-stable/src/runner.rs @@ -30,11 +30,83 @@ struct TestOpts { /// Output minimal information quiet: bool, #[structopt(long)] - /// We already can't capture anything but we don't want arg parsing to fail so this is a noop + /// NO-OP: don't capture stdout/stderr of each task, allow printing directly nocapture: bool, #[structopt(long)] /// List all tests list: bool, + #[structopt(long)] + /// NO-OP: Run only ignored tests + ignored: bool, + #[structopt(long)] + /// NO-OP: Run ignored and not ignored tests + include_ignored: bool, + #[structopt(long)] + /// NO-OP: Forces tests to run in-process when panic=abort + force_run_in_process: bool, + #[structopt(long)] + /// NO-OP: Excludes tests marked as should_panic + exclude_should_panic: bool, + #[structopt(long)] + /// NO-OP: Run tests and not benchmarks + test: bool, + #[structopt(long)] + /// NO-OP: Run benchmarks instead of tests + bench: bool, + #[structopt(long)] + /// NO-OP: Write logs to the specified file instead of stdout + logfile: Option, + #[structopt(long, number_of_values = 1)] + /// NO-OP: Skip tests whose names contain FILTER (this flag can be used multiple times) + skip: Vec, + #[structopt(long)] + /// NO-OP: Show captured stdo + show_output: bool, + #[structopt(long)] + /// NO-OP: auto|always|never + /// Configure coloring of output: + /// auto = colorize if stdout is a tty and tests are run + /// on serially (default); + /// always = always colorize output; + /// never = never colorize output; + color: Option, + #[structopt(long)] + /// NO-OP: pretty|terse|json + /// Configure formatting of output: + /// pretty = Print verbose output; + /// terse = Display one character per test; + /// json = Output a json document + format: Option, + #[structopt(long)] + /// NO-OP: [plain|colored] + /// Show execution time of each test. Awailable values: + /// plain = do not colorize the execution time (default); + /// colored = colorize output according to the `color` + /// parameter value; + /// Threshold values for colorized output can be + /// configured via + /// `RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION` + /// and + /// `RUST_TEST_TIME_DOCTEST` environment variables. + /// Expected format of environment variable is + /// `VARIABLE=WARN_TIME,CRITICAL_TIME`. + /// Durations must be specified in milliseconds, e.g. + /// `500,2000` means that the warn time + /// is 0.5 seconds, and the critical time is 2 seconds. + /// Not available for --format=terse + report_time: Option, + #[structopt(long)] + /// NO-OP: Treat excess of the test execution time limit as + /// error. + /// Threshold values for this option can be configured via + /// `RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION` + /// and + /// `RUST_TEST_TIME_DOCTEST` environment variables. + /// Expected format of environment variable is + /// `VARIABLE=WARN_TIME,CRITICAL_TIME`. + /// `CRITICAL_TIME` here means the limit that should not + /// be exceeded by test. + ensure_time: bool, } pub fn runner(reqs: &[Requirements]) { From 333f13994a1d30ab209cecd03cd55512080aab54 Mon Sep 17 00:00:00 2001 From: Rex Hoffman Date: Wed, 8 Apr 2020 12:41:48 -0700 Subject: [PATCH 12/34] [test] explicitly and only state that these are no-op args/flags. Closes: #3328 Approved by: bmwill --- datatest-stable/src/runner.rs | 61 ++++++++--------------------------- 1 file changed, 14 insertions(+), 47 deletions(-) diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs index 730819308..135e6a008 100644 --- a/datatest-stable/src/runner.rs +++ b/datatest-stable/src/runner.rs @@ -30,82 +30,49 @@ struct TestOpts { /// Output minimal information quiet: bool, #[structopt(long)] - /// NO-OP: don't capture stdout/stderr of each task, allow printing directly + /// NO-OP: unsupported option, exists for compatibility with the default test harness nocapture: bool, #[structopt(long)] /// List all tests list: bool, #[structopt(long)] - /// NO-OP: Run only ignored tests + /// NO-OP: unsupported option, exists for compatibility with the default test harness ignored: bool, #[structopt(long)] - /// NO-OP: Run ignored and not ignored tests + /// NO-OP: unsupported option, exists for compatibility with the default test harness include_ignored: bool, #[structopt(long)] - /// NO-OP: Forces tests to run in-process when panic=abort + /// NO-OP: unsupported option, exists for compatibility with the default test harness force_run_in_process: bool, #[structopt(long)] - /// NO-OP: Excludes tests marked as should_panic + /// NO-OP: unsupported option, exists for compatibility with the default test harness exclude_should_panic: bool, #[structopt(long)] - /// NO-OP: Run tests and not benchmarks + /// NO-OP: unsupported option, exists for compatibility with the default test harness test: bool, #[structopt(long)] - /// NO-OP: Run benchmarks instead of tests + /// NO-OP: unsupported option, exists for compatibility with the default test harness bench: bool, #[structopt(long)] - /// NO-OP: Write logs to the specified file instead of stdout + /// NO-OP: unsupported option, exists for compatibility with the default test harness logfile: Option, #[structopt(long, number_of_values = 1)] - /// NO-OP: Skip tests whose names contain FILTER (this flag can be used multiple times) + /// NO-OP: unsupported option, exists for compatibility with the default test harness skip: Vec, #[structopt(long)] - /// NO-OP: Show captured stdo + /// NO-OP: unsupported option, exists for compatibility with the default test harness show_output: bool, #[structopt(long)] - /// NO-OP: auto|always|never - /// Configure coloring of output: - /// auto = colorize if stdout is a tty and tests are run - /// on serially (default); - /// always = always colorize output; - /// never = never colorize output; + /// NO-OP: unsupported option, exists for compatibility with the default test harness color: Option, #[structopt(long)] - /// NO-OP: pretty|terse|json - /// Configure formatting of output: - /// pretty = Print verbose output; - /// terse = Display one character per test; - /// json = Output a json document + /// NO-OP: unsupported option, exists for compatibility with the default test harness format: Option, #[structopt(long)] - /// NO-OP: [plain|colored] - /// Show execution time of each test. Awailable values: - /// plain = do not colorize the execution time (default); - /// colored = colorize output according to the `color` - /// parameter value; - /// Threshold values for colorized output can be - /// configured via - /// `RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION` - /// and - /// `RUST_TEST_TIME_DOCTEST` environment variables. - /// Expected format of environment variable is - /// `VARIABLE=WARN_TIME,CRITICAL_TIME`. - /// Durations must be specified in milliseconds, e.g. - /// `500,2000` means that the warn time - /// is 0.5 seconds, and the critical time is 2 seconds. - /// Not available for --format=terse + /// NO-OP: unsupported option, exists for compatibility with the default test harness report_time: Option, #[structopt(long)] - /// NO-OP: Treat excess of the test execution time limit as - /// error. - /// Threshold values for this option can be configured via - /// `RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION` - /// and - /// `RUST_TEST_TIME_DOCTEST` environment variables. - /// Expected format of environment variable is - /// `VARIABLE=WARN_TIME,CRITICAL_TIME`. - /// `CRITICAL_TIME` here means the limit that should not - /// be exceeded by test. + /// NO-OP: unsupported option, exists for compatibility with the default test harness ensure_time: bool, } From 5dddf99e926abc4372fa83193b675197d1dfef39 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:22:52 +0000 Subject: [PATCH 13/34] Bump structopt from 0.3.12 to 0.3.13 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.12 to 0.3.13. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/commits) Signed-off-by: dependabot-preview[bot] Closes: #3345 Approved by: bmwill --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index c69ba6c37..8cd67ac37 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" [dependencies] regex = "1.3.6" walkdir = "2.2.9" -structopt = "0.3.12" +structopt = "0.3.13" termcolor = "1.0.5" [[test]] From 17fc201b0c38ec8f706d7fe6a251a8e7dfcb8cc1 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Mon, 16 Mar 2020 21:25:28 -0500 Subject: [PATCH 14/34] Add workspace-hack crate to unify third party dependency features By unifying the features requested in third party dependencies, this crate improves caching and should speed up build/test time. Each time cargo is invoked, it resolves features for its targets, but since the targets change every invocation potentially, the resolved features for third party crates might also change, causing those third party crates to be recompiled. This unifies the features among third party crates so that every feature resolution is the same for third party crates. The downside is we have dependencies to libra-workspace-hack from every first party crate, and we create new, unused dependency edges from some crates to third party dependencies. Both downsides can be mitigated by using cargo-guppy with the `--omit-edges-into libra-workspace-hack`. This solution is modeled on the one in the rust compiler, which is at https://github.com/rust-lang/rust/tree/master/src/tools/rustc-workspace-hack Closes: #3151 Approved by: sunshowers --- datatest-stable/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 8cd67ac37..71cc6732b 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -16,6 +16,7 @@ regex = "1.3.6" walkdir = "2.2.9" structopt = "0.3.13" termcolor = "1.0.5" +libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } [[test]] name = "example" From 70f472e47e0f13e670140329982a130d353e89da Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2020 08:14:29 +0000 Subject: [PATCH 15/34] Bump regex from 1.3.6 to 1.3.7 Bumps [regex](https://github.com/rust-lang/regex) from 1.3.6 to 1.3.7. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.3.6...regex-1.3.7) Signed-off-by: dependabot-preview[bot] Closes: #3505 Approved by: rexhoffman --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 71cc6732b..c36be7f50 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.3.6" +regex = "1.3.7" walkdir = "2.2.9" structopt = "0.3.13" termcolor = "1.0.5" From b81de616e77d57bb60c6d0297e9f25d28da77086 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2020 01:53:57 +0000 Subject: [PATCH 16/34] Bump structopt from 0.3.13 to 0.3.14 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.13 to 0.3.14. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.13...v0.3.14) Signed-off-by: dependabot-preview[bot] Closes: #3559 Approved by: wqfish --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index c36be7f50..d24e6adaa 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" [dependencies] regex = "1.3.7" walkdir = "2.2.9" -structopt = "0.3.13" +structopt = "0.3.14" termcolor = "1.0.5" libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } From 75ddc9d27cf82ca45439f0fffb47a8ab71c081df Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 29 May 2020 14:36:18 +0000 Subject: [PATCH 17/34] Bump regex from 1.3.7 to 1.3.9 Bumps [regex](https://github.com/rust-lang/regex) from 1.3.7 to 1.3.9. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/regex-1.3.7...1.3.9) Signed-off-by: dependabot-preview[bot] Closes: #4116 Approved by: rexhoffman --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index d24e6adaa..11876890c 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.3.7" +regex = "1.3.9" walkdir = "2.2.9" structopt = "0.3.14" termcolor = "1.0.5" From ea0ac8b716645fb4f61aca54761bcef81d25046f Mon Sep 17 00:00:00 2001 From: Rex Hoffman Date: Wed, 3 Jun 2020 09:37:29 -0700 Subject: [PATCH 18/34] [deps] use cargo-edit's cargo upgrade command to cleanup project tomls Closes: #4226 Approved by: metajack --- datatest-stable/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 11876890c..4c0d28520 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -13,9 +13,9 @@ edition = "2018" [dependencies] regex = "1.3.9" -walkdir = "2.2.9" +walkdir = "2.3.1" structopt = "0.3.14" -termcolor = "1.0.5" +termcolor = "1.1.0" libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } [[test]] From b7fc402fbc85340c0b44bcd8b3e97d4a338463dc Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 17 Jun 2020 07:20:21 +0000 Subject: [PATCH 19/34] Bump structopt from 0.3.14 to 0.3.15 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.14 to 0.3.15. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.14...v0.3.15) Signed-off-by: dependabot-preview[bot] Closes: #4567 Approved by: rexhoffman --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 4c0d28520..d353e5d3b 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" [dependencies] regex = "1.3.9" walkdir = "2.3.1" -structopt = "0.3.14" +structopt = "0.3.15" termcolor = "1.1.0" libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } From b4a1e85f62836b746936b20413226ddc30856637 Mon Sep 17 00:00:00 2001 From: bors-libra Date: Fri, 28 Aug 2020 02:12:44 +0000 Subject: [PATCH 20/34] fixup! [Deps] Downgrade bindgen to unyanked 0.54.0, upgrade others. clang-sys 1.0.0/0.23.0 collision prevented bindgen upgrade Closes: #5762 --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index d353e5d3b..94d154321 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" [dependencies] regex = "1.3.9" walkdir = "2.3.1" -structopt = "0.3.15" +structopt = "0.3.17" termcolor = "1.1.0" libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } From 5a45dd0f537e801c2fabf4bd7fac3a38753319a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Sep 2020 15:32:06 +0000 Subject: [PATCH 21/34] Bump structopt from 0.3.17 to 0.3.18 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.17 to 0.3.18. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.17...v0.3.18) Signed-off-by: dependabot[bot] Closes: #6184 --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 94d154321..f5c00ae22 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" [dependencies] regex = "1.3.9" walkdir = "2.3.1" -structopt = "0.3.17" +structopt = "0.3.18" termcolor = "1.1.0" libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } From 8dc0904e9964df4ce97962bbc90ccadce49f4c53 Mon Sep 17 00:00:00 2001 From: David Wong Date: Fri, 2 Oct 2020 08:38:36 -0700 Subject: [PATCH 22/34] [integer-overflow] enforce some checked operations Closes: #6526 --- datatest-stable/src/runner.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs index 135e6a008..f74f54426 100644 --- a/datatest-stable/src/runner.rs +++ b/datatest-stable/src/runner.rs @@ -1,6 +1,8 @@ // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 +#![allow(clippy::integer_arithmetic)] + use crate::{utils, Result}; use std::{ io::{self, Write}, From fe8404480274f5191d42ecc94ff2b0567fb31d88 Mon Sep 17 00:00:00 2001 From: Rex Hoffman Date: Wed, 28 Oct 2020 13:25:01 -0700 Subject: [PATCH 23/34] cargo upgrade --workspace aho-corasick anyhow backtrace bitvec cc crossbeam crossbeam-channel ctrlc env_logger indexmap indoc regex serde serde_derive serde_json structopt syn toml rayon serde-generate futures libc enum_dispatch syn handlebars bitvec memchr && cargo update --- datatest-stable/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index f5c00ae22..71970fec8 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -12,9 +12,9 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.3.9" +regex = "1.4.1" walkdir = "2.3.1" -structopt = "0.3.18" +structopt = "0.3.20" termcolor = "1.1.0" libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } From b36eed6608b77b855c5b41b273b83e5fe2dc3353 Mon Sep 17 00:00:00 2001 From: Rex Hoffman Date: Mon, 9 Nov 2020 19:09:15 -0800 Subject: [PATCH 24/34] cargo upgrade --workspace aes-gcm ureq thiserror structopt sha2 sha-1 serde_yaml serde_json serde regex ref-cast prost-build prost num-traits num-derive native-tls hyper flate2 cc backtrace anyhow Closes: #6675 --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 71970fec8..59a0ba41f 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.4.1" +regex = "1.4.2" walkdir = "2.3.1" structopt = "0.3.20" termcolor = "1.1.0" From d868d98ec0557327ec85e68bdf7e404e063b6c2a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Nov 2020 23:55:37 +0000 Subject: [PATCH 25/34] Bump termcolor from 1.1.0 to 1.1.2 Bumps [termcolor](https://github.com/BurntSushi/termcolor) from 1.1.0 to 1.1.2. - [Release notes](https://github.com/BurntSushi/termcolor/releases) - [Commits](https://github.com/BurntSushi/termcolor/compare/1.1.0...1.1.2) Signed-off-by: dependabot[bot] Closes: #6743 --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 59a0ba41f..a9f1b3930 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" regex = "1.4.2" walkdir = "2.3.1" structopt = "0.3.20" -termcolor = "1.1.0" +termcolor = "1.1.2" libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } [[test]] From f1da5b1502491e1c84c9e99e7fdab8c774a886e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Dec 2020 06:24:44 +0000 Subject: [PATCH 26/34] Bump structopt from 0.3.20 to 0.3.21 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.20 to 0.3.21. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.20...v0.3.21) Signed-off-by: dependabot[bot] Closes: #6773 --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index a9f1b3930..11126d8bc 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" [dependencies] regex = "1.4.2" walkdir = "2.3.1" -structopt = "0.3.20" +structopt = "0.3.21" termcolor = "1.1.2" libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } From a1f3d20e5a9692b9dfa2b786973f55490941c55a Mon Sep 17 00:00:00 2001 From: Tim Zakian Date: Thu, 3 Dec 2020 10:27:45 -0800 Subject: [PATCH 27/34] [Rename] Rename all occurences of "Libra" to "Diem" Closes: #6798 --- datatest-stable/Cargo.toml | 8 ++++---- datatest-stable/src/lib.rs | 2 +- datatest-stable/src/macros.rs | 2 +- datatest-stable/src/runner.rs | 2 +- datatest-stable/src/utils.rs | 2 +- datatest-stable/tests/example.rs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 11126d8bc..bc15a02d2 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "datatest-stable" version = "0.1.0" -authors = ["Libra Association "] -description = "Libra datatest stable" +authors = ["Diem Association "] +description = "Diem datatest stable" repository = "https://github.com/libra/libra" -homepage = "https://libra.org" +homepage = "https://diem.com" license = "Apache-2.0" publish = false edition = "2018" @@ -16,7 +16,7 @@ regex = "1.4.2" walkdir = "2.3.1" structopt = "0.3.21" termcolor = "1.1.2" -libra-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } +diem-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } [[test]] name = "example" diff --git a/datatest-stable/src/lib.rs b/datatest-stable/src/lib.rs index cf7615ff5..608458a77 100644 --- a/datatest-stable/src/lib.rs +++ b/datatest-stable/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (c) The Libra Core Contributors +// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] diff --git a/datatest-stable/src/macros.rs b/datatest-stable/src/macros.rs index be9b9c5c8..1b0d580fd 100644 --- a/datatest-stable/src/macros.rs +++ b/datatest-stable/src/macros.rs @@ -1,4 +1,4 @@ -// Copyright (c) The Libra Core Contributors +// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 /// `datatest-stable` test harness entry point. Should be declared in the test module. diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs index f74f54426..73ba1d984 100644 --- a/datatest-stable/src/runner.rs +++ b/datatest-stable/src/runner.rs @@ -1,4 +1,4 @@ -// Copyright (c) The Libra Core Contributors +// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 #![allow(clippy::integer_arithmetic)] diff --git a/datatest-stable/src/utils.rs b/datatest-stable/src/utils.rs index a76932c34..5b2405b42 100644 --- a/datatest-stable/src/utils.rs +++ b/datatest-stable/src/utils.rs @@ -1,4 +1,4 @@ -// Copyright (c) The Libra Core Contributors +// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use std::path::{Path, PathBuf}; diff --git a/datatest-stable/tests/example.rs b/datatest-stable/tests/example.rs index 1d3c11ed0..19b2c2ef7 100644 --- a/datatest-stable/tests/example.rs +++ b/datatest-stable/tests/example.rs @@ -1,4 +1,4 @@ -// Copyright (c) The Libra Core Contributors +// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use datatest_stable::Result; From 8941d00a52fa475c94499771a460f3935da0df26 Mon Sep 17 00:00:00 2001 From: Rex Hoffman Date: Wed, 9 Dec 2020 11:20:15 -0800 Subject: [PATCH 28/34] github url update, ignoring developers.libra.org Closes: #6874 --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index bc15a02d2..d651b2317 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -3,7 +3,7 @@ name = "datatest-stable" version = "0.1.0" authors = ["Diem Association "] description = "Diem datatest stable" -repository = "https://github.com/libra/libra" +repository = "https://github.com/diem/diem" homepage = "https://diem.com" license = "Apache-2.0" publish = false From 26bea2f78f7cb64c31fa32a6bc8ecf8121ce6d9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Jan 2021 03:31:55 +0000 Subject: [PATCH 29/34] Bump regex from 1.4.2 to 1.4.3 Bumps [regex](https://github.com/rust-lang/regex) from 1.4.2 to 1.4.3. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.4.2...1.4.3) Signed-off-by: dependabot[bot] Closes: #7172 --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index d651b2317..f120774ae 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -12,7 +12,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -regex = "1.4.2" +regex = "1.4.3" walkdir = "2.3.1" structopt = "0.3.21" termcolor = "1.1.2" From 168d7d4c9548b5715e7b2fad37c0449c2e24c9b2 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Tue, 23 Feb 2021 19:01:29 -0800 Subject: [PATCH 30/34] x: add unpublished-packages-only-use-path-dependencies lint Add a lint enforcing that all unpublished dependencies not specify a version for first-party packages. Given that we will have a small subset of dependencies that will be initially published, this will reduce the effort needed to bump versions numbers when new versions of packages are published. --- datatest-stable/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index f120774ae..4b9076158 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -16,7 +16,7 @@ regex = "1.4.3" walkdir = "2.3.1" structopt = "0.3.21" termcolor = "1.1.2" -diem-workspace-hack = { path = "../workspace-hack", version = "0.1.0" } +diem-workspace-hack = { path = "../workspace-hack" } [[test]] name = "example" From 4dae2092925066d0fa40461a3e2c99a1dc30ff1d Mon Sep 17 00:00:00 2001 From: Rain Date: Mon, 15 Mar 2021 21:31:55 -0700 Subject: [PATCH 31/34] [datatest-stable] support --format terse Support the terse format while listing tests, since that's what the test runner uses. Closes: #7932 --- datatest-stable/src/runner.rs | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs index 73ba1d984..b92155839 100644 --- a/datatest-stable/src/runner.rs +++ b/datatest-stable/src/runner.rs @@ -13,7 +13,7 @@ use std::{ sync::mpsc::{channel, Sender}, thread, }; -use structopt::StructOpt; +use structopt::{clap::arg_enum, StructOpt}; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; #[derive(Debug, StructOpt)] @@ -68,8 +68,12 @@ struct TestOpts { /// NO-OP: unsupported option, exists for compatibility with the default test harness color: Option, #[structopt(long)] - /// NO-OP: unsupported option, exists for compatibility with the default test harness - format: Option, + /// Configure formatting of output: + /// pretty = Print verbose output; + /// terse = Display one character per test; + /// (json is unsupported, exists for compatibility with the default test harness) + #[structopt(possible_values = &Format::variants(), default_value, case_insensitive = true)] + format: Format, #[structopt(long)] /// NO-OP: unsupported option, exists for compatibility with the default test harness report_time: Option, @@ -78,6 +82,21 @@ struct TestOpts { ensure_time: bool, } +arg_enum! { + #[derive(Debug, Eq, PartialEq)] + enum Format { + Pretty, + Terse, + Json, + } +} + +impl Default for Format { + fn default() -> Self { + Format::Pretty + } +} + pub fn runner(reqs: &[Requirements]) { let options = TestOpts::from_args(); @@ -88,8 +107,10 @@ pub fn runner(reqs: &[Requirements]) { println!("{}: test", test.name); } - println!(); - println!("{} tests, 0 benchmarks", tests.len()); + if options.format == Format::Pretty { + println!(); + println!("{} tests, 0 benchmarks", tests.len()); + } return; } From a3099219d004e68002ddc99b28c6516a1a027407 Mon Sep 17 00:00:00 2001 From: Rain Date: Thu, 25 Mar 2021 15:47:19 -0700 Subject: [PATCH 32/34] [datatest-stable] handle the --ignored flag The new test runner tries to list these out, and malfunctions because the full set of tests is printed out as both ignored and non-ignored tests. --- datatest-stable/src/runner.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs index b92155839..56b342d5d 100644 --- a/datatest-stable/src/runner.rs +++ b/datatest-stable/src/runner.rs @@ -38,7 +38,8 @@ struct TestOpts { /// List all tests list: bool, #[structopt(long)] - /// NO-OP: unsupported option, exists for compatibility with the default test harness + /// List or run ignored tests (always empty: it is currently not possible to mark tests as + /// ignored) ignored: bool, #[structopt(long)] /// NO-OP: unsupported option, exists for compatibility with the default test harness @@ -100,7 +101,13 @@ impl Default for Format { pub fn runner(reqs: &[Requirements]) { let options = TestOpts::from_args(); - let tests: Vec = reqs.iter().flat_map(|req| req.expand()).collect(); + let tests: Vec = if options.ignored { + // Currently impossible to mark tests as ignored. + // TODO: add support for this in the future, probably by supporting an "ignored" dir + vec![] + } else { + reqs.iter().flat_map(|req| req.expand()).collect() + }; if options.list { for test in &tests { From 24a4a35976025f21ebd00884a3f1d46ced40b699 Mon Sep 17 00:00:00 2001 From: Rain Date: Thu, 25 Mar 2021 18:07:28 -0700 Subject: [PATCH 33/34] [datatest-stable] prepare for merge into diem-devtools Clean up references to Diem. --- datatest-stable/Cargo.toml | 10 +++------- datatest-stable/src/lib.rs | 2 +- datatest-stable/src/macros.rs | 2 +- datatest-stable/src/runner.rs | 2 +- datatest-stable/src/utils.rs | 2 +- datatest-stable/tests/example.rs | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/datatest-stable/Cargo.toml b/datatest-stable/Cargo.toml index 4b9076158..8ca7cef84 100644 --- a/datatest-stable/Cargo.toml +++ b/datatest-stable/Cargo.toml @@ -2,21 +2,17 @@ name = "datatest-stable" version = "0.1.0" authors = ["Diem Association "] -description = "Diem datatest stable" -repository = "https://github.com/diem/diem" -homepage = "https://diem.com" -license = "Apache-2.0" +description = "Data-driven tests that work on stable Rust" +repository = "https://github.com/diem/diem-devtools" +license = "MIT OR Apache-2.0" publish = false edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] regex = "1.4.3" walkdir = "2.3.1" structopt = "0.3.21" termcolor = "1.1.2" -diem-workspace-hack = { path = "../workspace-hack" } [[test]] name = "example" diff --git a/datatest-stable/src/lib.rs b/datatest-stable/src/lib.rs index 608458a77..37a20aa3c 100644 --- a/datatest-stable/src/lib.rs +++ b/datatest-stable/src/lib.rs @@ -1,5 +1,5 @@ // Copyright (c) The Diem Core Contributors -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT OR Apache-2.0 #![forbid(unsafe_code)] diff --git a/datatest-stable/src/macros.rs b/datatest-stable/src/macros.rs index 1b0d580fd..0d676c898 100644 --- a/datatest-stable/src/macros.rs +++ b/datatest-stable/src/macros.rs @@ -1,5 +1,5 @@ // Copyright (c) The Diem Core Contributors -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT OR Apache-2.0 /// `datatest-stable` test harness entry point. Should be declared in the test module. /// diff --git a/datatest-stable/src/runner.rs b/datatest-stable/src/runner.rs index 56b342d5d..093585b83 100644 --- a/datatest-stable/src/runner.rs +++ b/datatest-stable/src/runner.rs @@ -1,5 +1,5 @@ // Copyright (c) The Diem Core Contributors -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT OR Apache-2.0 #![allow(clippy::integer_arithmetic)] diff --git a/datatest-stable/src/utils.rs b/datatest-stable/src/utils.rs index 5b2405b42..1bdbc2cab 100644 --- a/datatest-stable/src/utils.rs +++ b/datatest-stable/src/utils.rs @@ -1,5 +1,5 @@ // Copyright (c) The Diem Core Contributors -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT OR Apache-2.0 use std::path::{Path, PathBuf}; diff --git a/datatest-stable/tests/example.rs b/datatest-stable/tests/example.rs index 19b2c2ef7..6c8d41451 100644 --- a/datatest-stable/tests/example.rs +++ b/datatest-stable/tests/example.rs @@ -1,5 +1,5 @@ // Copyright (c) The Diem Core Contributors -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT OR Apache-2.0 use datatest_stable::Result; use std::{fs::File, io::Read, path::Path}; From 436a41142f9f5c7f5bb714ba013a0a2fdd0ee67a Mon Sep 17 00:00:00 2001 From: Rain Date: Thu, 25 Mar 2021 18:12:16 -0700 Subject: [PATCH 34/34] [datatest-stable] add to workspace --- Cargo.lock | 41 +++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 42 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index b616ed689..7c932cb68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -198,6 +198,16 @@ dependencies = [ "syn 1.0.60", ] +[[package]] +name = "datatest-stable" +version = "0.1.0" +dependencies = [ + "regex", + "structopt", + "termcolor", + "walkdir", +] + [[package]] name = "diff" version = "0.1.12" @@ -623,6 +633,17 @@ dependencies = [ "bitflags", ] +[[package]] +name = "regex" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.23" @@ -656,6 +677,15 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -920,6 +950,17 @@ dependencies = [ "libc", ] +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 641f5c11e..6631c5b31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] resolver = "2" members = [ + "datatest-stable", "quick-junit", "testrunner", ]