From ccff4e3380d8a2f0731a867170eb1a169847f592 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Tue, 16 Jul 2019 09:56:10 +0900 Subject: [PATCH 1/4] Add test-binary feature --- Cargo.toml | 1 + tests/cargo-fmt/main.rs | 2 ++ tests/rustfmt/main.rs | 2 ++ 3 files changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 0d55fb283d7..c5ca6ed32cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ default = ["cargo-fmt", "rustfmt-format-diff"] cargo-fmt = [] rustfmt-format-diff = [] generic-simd = ["bytecount/generic-simd"] +test-binary = [] [dependencies] atty = "0.2" diff --git a/tests/cargo-fmt/main.rs b/tests/cargo-fmt/main.rs index d1ba2e689b6..f5907edb850 100644 --- a/tests/cargo-fmt/main.rs +++ b/tests/cargo-fmt/main.rs @@ -1,5 +1,7 @@ // Integration tests for cargo-fmt. +#![cfg(feature = "test-binary")] + use std::env; use std::process::Command; diff --git a/tests/rustfmt/main.rs b/tests/rustfmt/main.rs index 51f311cd08d..182630fd08b 100644 --- a/tests/rustfmt/main.rs +++ b/tests/rustfmt/main.rs @@ -1,5 +1,7 @@ //! Integration tests for rustfmt. +#![cfg(feature = "test-binary")] + use std::env; use std::fs::remove_file; use std::path::Path; From ce2626606b2917b57cd5aebfd2c08a86a5494171 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Tue, 16 Jul 2019 09:57:13 +0900 Subject: [PATCH 2/4] Run test against binaries in our CI --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index abf565453de..7430dda7630 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ script: - | if [ -z ${INTEGRATION} ]; then cargo build - cargo test + cargo test --features "test-binary" else ./ci/integration.sh fi diff --git a/appveyor.yml b/appveyor.yml index 87c1773ce8e..9e2967dc524 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,4 +49,4 @@ build: false test_script: - cargo build --verbose - - cargo test + - cargo test --features "test-binary" From 4cf6f59d13cb3d6bbaf89f73336d1a66d6c20821 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Tue, 16 Jul 2019 15:28:11 +0900 Subject: [PATCH 3/4] Use ignore to filter out test that runs binary --- .travis.yml | 2 +- Cargo.toml | 1 - appveyor.yml | 2 +- src/chains.rs | 16 ++++++++-------- src/config/license.rs | 2 +- src/macros.rs | 2 +- src/utils.rs | 4 ++-- tests/cargo-fmt/main.rs | 5 +++-- tests/rustfmt/main.rs | 3 +-- tests/source/issue-3055/original.rs | 2 +- tests/target/issue-3055/original.rs | 2 +- 11 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7430dda7630..a5484870beb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ script: - | if [ -z ${INTEGRATION} ]; then cargo build - cargo test --features "test-binary" + cargo test -- --ignored else ./ci/integration.sh fi diff --git a/Cargo.toml b/Cargo.toml index c5ca6ed32cc..0d55fb283d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,6 @@ default = ["cargo-fmt", "rustfmt-format-diff"] cargo-fmt = [] rustfmt-format-diff = [] generic-simd = ["bytecount/generic-simd"] -test-binary = [] [dependencies] atty = "0.2" diff --git a/appveyor.yml b/appveyor.yml index 9e2967dc524..abeb876b090 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,4 +49,4 @@ build: false test_script: - cargo build --verbose - - cargo test --features "test-binary" + - cargo test -- --ignored diff --git a/src/chains.rs b/src/chains.rs index 1ca0ac582b7..c7acf19ee0c 100644 --- a/src/chains.rs +++ b/src/chains.rs @@ -16,7 +16,7 @@ //! following values of `chain_indent`: //! Block: //! -//! ```ignore +//! ```text //! let foo = { //! aaaa; //! bbb; @@ -27,7 +27,7 @@ //! //! Visual: //! -//! ```ignore +//! ```text //! let foo = { //! aaaa; //! bbb; @@ -41,7 +41,7 @@ //! the braces. //! Block: //! -//! ```ignore +//! ```text //! let a = foo.bar //! .baz() //! .qux @@ -49,7 +49,7 @@ //! //! Visual: //! -//! ```ignore +//! ```text //! let a = foo.bar //! .baz() //! .qux @@ -454,7 +454,7 @@ trait ChainFormatter { // Parent is the first item in the chain, e.g., `foo` in `foo.bar.baz()`. // Root is the parent plus any other chain items placed on the first line to // avoid an orphan. E.g., - // ```ignore + // ```text // foo.bar // .baz() // ``` @@ -516,7 +516,7 @@ impl<'a> ChainFormatterShared<'a> { // know whether 'overflowing' the last child make a better formatting: // // A chain with overflowing the last child: - // ```ignore + // ```text // parent.child1.child2.last_child( // a, // b, @@ -525,7 +525,7 @@ impl<'a> ChainFormatterShared<'a> { // ``` // // A chain without overflowing the last child (in vertical layout): - // ```ignore + // ```text // parent // .child1 // .child2 @@ -534,7 +534,7 @@ impl<'a> ChainFormatterShared<'a> { // // In particular, overflowing is effective when the last child is a method with a multi-lined // block-like argument (e.g., closure): - // ```ignore + // ```text // parent.child1.child2.last_child(|a, b, c| { // let x = foo(a, b, c); // let y = bar(a, b, c); diff --git a/src/config/license.rs b/src/config/license.rs index 2eb23bbcec7..121a1b1c151 100644 --- a/src/config/license.rs +++ b/src/config/license.rs @@ -82,7 +82,7 @@ impl TemplateParser { /// /// # Examples /// - /// ```ignore + /// ```text /// assert_eq!( /// TemplateParser::parse( /// r" diff --git a/src/macros.rs b/src/macros.rs index ac00e4452a7..c42010f77b2 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1417,7 +1417,7 @@ impl MacroBranch { /// /// # Expected syntax /// -/// ```ignore +/// ```text /// lazy_static! { /// [pub] static ref NAME_1: TYPE_1 = EXPR_1; /// [pub] static ref NAME_2: TYPE_2 = EXPR_2; diff --git a/src/utils.rs b/src/utils.rs index 26ee7317df5..1a4941aa72e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -507,7 +507,7 @@ pub(crate) fn remove_trailing_white_spaces(text: &str) -> String { /// Indent each line according to the specified `indent`. /// e.g. /// -/// ```rust,ignore +/// ```rust,compile_fail /// foo!{ /// x, /// y, @@ -521,7 +521,7 @@ pub(crate) fn remove_trailing_white_spaces(text: &str) -> String { /// /// will become /// -/// ```rust,ignore +/// ```rust,compile_fail /// foo!{ /// x, /// y, diff --git a/tests/cargo-fmt/main.rs b/tests/cargo-fmt/main.rs index f5907edb850..5493b09e4aa 100644 --- a/tests/cargo-fmt/main.rs +++ b/tests/cargo-fmt/main.rs @@ -1,7 +1,5 @@ // Integration tests for cargo-fmt. -#![cfg(feature = "test-binary")] - use std::env; use std::process::Command; @@ -48,6 +46,7 @@ macro_rules! assert_that { }; } +#[ignore] #[test] fn version() { assert_that!(&["--version"], starts_with("rustfmt ")); @@ -56,6 +55,7 @@ fn version() { assert_that!(&["--", "--version"], starts_with("rustfmt ")); } +#[ignore] #[test] fn print_config() { assert_that!( @@ -64,6 +64,7 @@ fn print_config() { ); } +#[ignore] #[test] fn rustfmt_help() { assert_that!(&["--", "--help"], contains("Format Rust code")); diff --git a/tests/rustfmt/main.rs b/tests/rustfmt/main.rs index 182630fd08b..18ef9b60963 100644 --- a/tests/rustfmt/main.rs +++ b/tests/rustfmt/main.rs @@ -1,7 +1,5 @@ //! Integration tests for rustfmt. -#![cfg(feature = "test-binary")] - use std::env; use std::fs::remove_file; use std::path::Path; @@ -50,6 +48,7 @@ macro_rules! assert_that { }; } +#[ignore] #[test] fn print_config() { assert_that!( diff --git a/tests/source/issue-3055/original.rs b/tests/source/issue-3055/original.rs index ad505547ac0..45e58473a4a 100644 --- a/tests/source/issue-3055/original.rs +++ b/tests/source/issue-3055/original.rs @@ -17,7 +17,7 @@ /// ``` /// /// Should not format with ignore attribute -/// ```ignore +/// ```text /// .--------------. /// | v /// Park <- Idle -> Poll -> Probe -> Download -> Install -> Reboot diff --git a/tests/target/issue-3055/original.rs b/tests/target/issue-3055/original.rs index de27ccfb344..2df6adbb5e2 100644 --- a/tests/target/issue-3055/original.rs +++ b/tests/target/issue-3055/original.rs @@ -18,7 +18,7 @@ /// ``` /// /// Should not format with ignore attribute -/// ```ignore +/// ```text /// .--------------. /// | v /// Park <- Idle -> Poll -> Probe -> Download -> Install -> Reboot From 76e81d670a46f999b557fb1ead86e1e22c1957b1 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Tue, 16 Jul 2019 15:32:29 +0900 Subject: [PATCH 4/4] Run normal cargo test as well ;) --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a5484870beb..966b7d7bac4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,7 @@ script: - | if [ -z ${INTEGRATION} ]; then cargo build + cargo test cargo test -- --ignored else ./ci/integration.sh diff --git a/appveyor.yml b/appveyor.yml index abeb876b090..1d3b06152a9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,4 +49,5 @@ build: false test_script: - cargo build --verbose + - cargo test - cargo test -- --ignored