From 81a1d46723121928c38fc2b7ec466c663907e4ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Mon, 15 Apr 2019 11:33:11 +0200 Subject: [PATCH 1/3] exit integration test successfully if the crate build failed before applying rustfmt The `cargo test --all` command failed and exited the main process with a SIGINT. Trapping the signal or trying to get the code of a subshell didn't work. Close #2724 --- ci/integration.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/integration.sh b/ci/integration.sh index 6a293d5f8083..f719bc5cc6e4 100755 --- a/ci/integration.sh +++ b/ci/integration.sh @@ -42,8 +42,8 @@ function check_fmt_with_lib_tests { function check_fmt_base { local test_args="$1" - cargo test $test_args - if [[ $? != 0 ]]; then + local build=$(cargo test $test_args 2>&1) + if [[ "$build" =~ "build failed" ]]; then return 0 fi touch rustfmt.toml From 31fbf344396679b2b8e1b5e327a0bd35a27133ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Mon, 15 Apr 2019 12:01:49 +0200 Subject: [PATCH 2/3] add check for failed tests --- ci/integration.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/integration.sh b/ci/integration.sh index f719bc5cc6e4..4d5498b6ec74 100755 --- a/ci/integration.sh +++ b/ci/integration.sh @@ -43,7 +43,7 @@ function check_fmt_with_lib_tests { function check_fmt_base { local test_args="$1" local build=$(cargo test $test_args 2>&1) - if [[ "$build" =~ "build failed" ]]; then + if [[ "$build" =~ "build failed" ]] || [[ "$build" =~ "test result: FAILED." ]]; then return 0 fi touch rustfmt.toml From 1c7202b2eebb6a514fa1b175e38a66ac518ff409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Mon, 15 Apr 2019 12:50:01 +0200 Subject: [PATCH 3/3] fix test_ignore_path_set test when run on beta ``` ---- ignore_path::test::test_ignore_path_set stdout ---- Warning: can't set `ignore = IgnoreList({"foo.rs", "bar_dir/*"})`, unstable features are only available in nightly channel. thread 'ignore_path::test::test_ignore_path_set' panicked at 'assertion failed: ignore_path_set.is_match(&FileName::Real(PathBuf::from("src/foo.rs")))', src/ignore_path.rs:51:9 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. failures: ignore_path::test::test_ignore_path_set ``` --- src/ignore_path.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ignore_path.rs b/src/ignore_path.rs index 1e17337e6254..6299aedf4a75 100644 --- a/src/ignore_path.rs +++ b/src/ignore_path.rs @@ -39,17 +39,17 @@ mod test { #[test] fn test_ignore_path_set() { - let config = Config::from_toml( - "ignore = [ - \"foo.rs\", - \"bar_dir/*\", - ]", - ) - .unwrap(); - let ignore_path_set = IgnorePathSet::from_ignore_list(&config.ignore()).unwrap(); + match option_env!("CFG_RELEASE_CHANNEL") { + // this test requires nightly + None | Some("nightly") => { + let config = Config::from_toml(r#"ignore = ["foo.rs", "bar_dir/*"]"#).unwrap(); + let ignore_path_set = IgnorePathSet::from_ignore_list(&config.ignore()).unwrap(); - assert!(ignore_path_set.is_match(&FileName::Real(PathBuf::from("src/foo.rs")))); - assert!(ignore_path_set.is_match(&FileName::Real(PathBuf::from("bar_dir/baz.rs")))); - assert!(!ignore_path_set.is_match(&FileName::Real(PathBuf::from("src/bar.rs")))); + assert!(ignore_path_set.is_match(&FileName::Real(PathBuf::from("src/foo.rs")))); + assert!(ignore_path_set.is_match(&FileName::Real(PathBuf::from("bar_dir/baz.rs")))); + assert!(!ignore_path_set.is_match(&FileName::Real(PathBuf::from("src/bar.rs")))); + } + _ => (), + }; } }