Skip to content

Default "make test" fail with errors #4400

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

Closed
davidBar-On opened this issue Aug 28, 2020 · 14 comments
Closed

Default "make test" fail with errors #4400

davidBar-On opened this issue Aug 28, 2020 · 14 comments

Comments

@davidBar-On
Copy link
Contributor

I installed rustfmt code from scratch and the "cargo make test" failed with errors.

Following are the install process steps to reproduce the problem:

  1. On https://github.com/rust-lang/rustfmt "fork" the repository.

  2. On your local machine clone the repository form the fork: "git clone <forked repository>"

  3. Set environment variables for cargo make:
    export CFG_RELEASE_CHANNEL=nightly; export CFG_RELEASE=1.47.0-nightly
    ("1.47.0-nightly" is from "rustc -vV")

  4. Run "cargo make test" - rustfmt version "2.0.0-rc.2-nightly" is built

Two errors are shown:

@calebcartwright
Copy link
Member

Can you please run these steps:

  1. (in a new directory) git clone https://github.com/rust-lang/rustfmt- note the cloning of rustfmt source, not your fork.
  2. cd rustfmt
  3. cargo make test

If you get test failures, please provide the output from the terminal.

@calebcartwright
Copy link
Member

Formatting "tests/parser/issue-4126/invalid.rs" fails

Also, is the test failing, or are you just referring to the console output? That's a negative scenario test, and the parser error output is intentional. However, the test is passing:

Note the passing test test test::parser_errors_in_submods_are_surfaced ... ok

error: expected `{`, found `println`
 --> tests/parser/issue-4126/invalid.rs:5:5
  |
2 |     if bar && if !baz {
  |     -- this `if` expression has a condition, but no block
...
5 |     println!("foo");
  |     ^^^^^^^---------
  |     |
  |     expected `{`
  |     help: try placing this code inside a block: `{ println!("foo"); }`

test test::parser_errors_in_submods_are_surfaced ... ok

@davidBar-On
Copy link
Contributor Author

davidBar-On commented Aug 28, 2020 via email

@calebcartwright
Copy link
Member

Yes, this is the error I see. I didn't notice that there are different
types of errors.

There's a difference between stdout/stderr text on the terminal and the actual result/outcome of a test. In this case the test is passing, not failing. Make sure you look at the test results, which cargo/libtest summarize really well.

Unless something should be done regarding the default branch
(documentation?)
It may be that the default master branch should be the latest 1.x and not 2.x.

I have no idea what you're referring to here. We have the branches configured how we want them, and it is very intentional. There is nothing to change, nor document.

the issue may be closed.
Panic at 'config::test::test_merged_config'

I'm still unclear if you're getting a panic, if you are then that is something I'd like to understand. However, as mentioned elsewhere, there is no such panic happening anywhere else so this almost certainly is related to something in your local environment. Please let me know if you receive a panic when following the exact steps I described above (and only those steps), otherwise I will close this.

https://github.com/rust-lang/rustfmt/actions?query=branch%3Amaster+event%3Apush

@davidBar-On
Copy link
Contributor Author

I have no idea what you're referring to here. We have the branches configured how we want them, and it is very intentional. There is nothing to change, nor document.

The issue I am referring to is that the default master branch builds rustfmt 2.0.0-rc.2-nightly but that caused panic in "cargo make test", and I had to checkout branch rustfmt-1.4.20 (the latest 1.x version) to prevent the panic. It may be that this is because I did something wrong (although I installed from scratch) or that this should have been clear to me and therefore no related documentation is needed. On the other hand it may be that what I did is o.k. and knowing to set branch 1.x instead of 2.x is not trivial, so it may be helpful to add in https://github.com/rust-lang/rustfmt#installing-from-source in addition to "tag or branch for the version of rustfmt you want" that that those that don't develop for version 2.x should install/checkout a 1.x version.

I'm still unclear if you're getting a panic, if you are then that is something I'd like to understand. However, as mentioned elsewhere, there is no such panic happening anywhere else so this almost certainly is related to something in your local environment. Please let me know if you receive a panic when following the exact steps I described above (and only those steps), otherwise I will close this.

When running "the exact steps I described above" I get the following errors:

dbo@DESKTOP-L81E90U:~/Tools/rusttest/rustfmt$ cargo make test
[cargo-make] INFO - cargo make 0.32.3
[cargo-make] INFO - Project: rustfmt-nightly
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: test
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Execute Command: "cargo" "test" "--all-features"
   Compiling smallvec v1.4.0
   Compiling rustc-ap-rustc_graphviz v671.0.0
   Compiling vec_map v0.8.2
   Compiling rustfmt-nightly v2.0.0-rc.2 (/home/dbo/Tools/rusttest/rustfmt)
   Compiling diff v0.1.12
   Compiling dunce v1.0.0
   Compiling bytecount v0.6.0
   Compiling unicode_categories v0.1.1
error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /home/dbo/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-1.4.0/lib.rs:61:32
   |
61 | #![cfg_attr(feature = "union", feature(untagged_unions))]
   |                                ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /home/dbo/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-1.4.0/lib.rs:63:37
   |
63 | #![cfg_attr(feature = "may_dangle", feature(dropck_eyepatch))]
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
   --> /home/dbo/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-ap-rustc_graphviz-671.0.0/lib.rs:278:1
    |
278 | #![feature(rustc_private, nll)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.
error: could not compile `rustc-ap-rustc_graphviz`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0554`.
error: build failed
[cargo-make] ERROR - Error while executing command, exit code: 101
[cargo-make] WARN - Build Failed.

@calebcartwright
Copy link
Member

@davidBar-On - The error message above is different than anything you've shared previously, and the key point comes from lines like this: error[E0554]: #![feature] may not be used on the stable release channel that show you're trying to compile rustfmt with stable, which is not supported.

Do you have a nightly toolchain installed?
https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust

@davidBar-On
Copy link
Contributor Author

davidBar-On commented Aug 28, 2020

@calebcartwright, as you guessed, I didn't have the nightly toolchain installed. Sorry for that (I assume that I should have known to do that). I installed it now and when running "cargo make test" on the rustfmt source I get the same panic that I get for my fork clone, although in this case version rustfmt 1.4.20-nightly was built (and not 2.x):

...
test test::stdin_parser_panic_caught ... ok
test test::parser_errors_in_submods_are_surfaced ... ok
test test::checkstyle_test ... ok
test test::json_test ... ok
test test::string_eq_ignore_newline_repr_test ... ok
test test::stdin_works_with_modified_lines ... ok
test config::test::test_merged_config ... FAILED
test test::stdin_works_with_json ... ok
test test::stdin_works_with_checkstyle ... ok
test test::configuration_snippet::configuration_snippet_tests ... ok
test test::verify_config_test_names ... ok
test test::self_tests ... ok
Ran 467 system tests.
test test::system_tests ... ok
Ran 621 idempotent tests.
test test::idempotence_tests ... ok

failures:

---- config::test::test_merged_config stdout ----
thread 'config::test::test_merged_config' panicked at 'couldn't create temp file: Os { code: 17, kind: AlreadyExists, message: "File exists" }', src/config.rs:466:52
stack backtrace:
   0:     0x7f203f4a6dd0 - std::backtrace_rs::backtrace::libunwind::trace::hdf911925cfd1a062
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
   1:     0x7f203f4a6dd0 - std::backtrace_rs::backtrace::trace_unsynchronized::h1a4f248df23e18fe
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/../../backtrace/src/backtrace/mod.rs:66
   2:     0x7f203f4a6dd0 - std::sys_common::backtrace::_print_fmt::hf3ec23fc59b676bd
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/sys_common/backtrace.rs:79
   3:     0x7f203f4a6dd0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h00fdb223b1b833ac
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/sys_common/backtrace.rs:58
   4:     0x7f203f4cd76c - core::fmt::write::h1857a60b204f1b6a
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/core/src/fmt/mod.rs:1082
   5:     0x7f203edd11d5 - std::io::Write::write_fmt::h5e22a552f3b92d42
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/io/mod.rs:1514
   6:     0x7f203f49fa81 - std::io::impls::<impl std::io::Write for alloc::boxed::Box<W>>::write_fmt::hca9eaa0dec3f9ceb
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/io/impls.rs:176
   7:     0x7f203f4a9240 - std::sys_common::backtrace::_print::hf25dbce5d8adc35c
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/sys_common/backtrace.rs:61
   8:     0x7f203f4a9240 - std::sys_common::backtrace::print::h40243408d050ccf7
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/sys_common/backtrace.rs:48
   9:     0x7f203f4a9240 - std::panicking::default_hook::{{closure}}::ha452abcc85cd3549
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panicking.rs:200
  10:     0x7f203f4a8f36 - std::panicking::default_hook::h637245b92cbb00b1
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panicking.rs:216
  11:     0x7f203f4a98a3 - std::panicking::rust_panic_with_hook::h2f4c96dfd8ba524a
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panicking.rs:569
  12:     0x7f203f4a9479 - std::panicking::begin_panic_handler::{{closure}}::h7740abbe2875cb4d
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panicking.rs:476
  13:     0x7f203f4a725c - std::sys_common::backtrace::__rust_end_short_backtrace::hcad001df0a36db28
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/sys_common/backtrace.rs:153
  14:     0x7f203f4a9439 - rust_begin_unwind
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panicking.rs:475
  15:     0x7f203f4cb301 - core::panicking::panic_fmt::hb15d6f55e8472f62
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/core/src/panicking.rs:85
  16:     0x7f203f4cb123 - core::option::expect_none_failed::he492a18657d97593
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/core/src/option.rs:1221
  17:     0x7f203eb25b3c - core::result::Result<T,E>::expect::h3edfde187eeb5d24
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/core/src/result.rs:933
  18:     0x7f203eacffe0 - rustfmt_nightly::config::test::make_temp_file::ha758f6565170311d
                               at /home/dbo/Tools/tmptest/rustfmt/src/config.rs:466
  19:     0x7f203ead22ca - rustfmt_nightly::config::test::test_merged_config::h5ed7dba451fa459d
                               at /home/dbo/Tools/tmptest/rustfmt/src/config.rs:649
  20:     0x7f203ea4e58a - rustfmt_nightly::config::test::test_merged_config::{{closure}}::h2db20104bd04a05b
                               at /home/dbo/Tools/tmptest/rustfmt/src/config.rs:645
  21:     0x7f203eadd5de - core::ops::function::FnOnce::call_once::h9be019eb80df49ad
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/core/src/ops/function.rs:227
  22:     0x7f203edf9a03 - core::ops::function::FnOnce::call_once::hec5f237bd4771aa6
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/core/src/ops/function.rs:227
  23:     0x7f203edf9a03 - test::__rust_begin_short_backtrace::h27aa84d85057b9a2
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/test/src/lib.rs:517
  24:     0x7f203edf7f53 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h43438cd95259f6ec
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/alloc/src/boxed.rs:1042
  25:     0x7f203edf7f53 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h06c1f8d4b7eac333
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panic.rs:308
  26:     0x7f203edf7f53 - std::panicking::try::do_call::h94cc8e5302f45973
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panicking.rs:373
  27:     0x7f203edf7f53 - std::panicking::try::hc4ce81e8ce9110fa
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panicking.rs:337
  28:     0x7f203edf7f53 - std::panic::catch_unwind::h88039e2790561905
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panic.rs:379
  29:     0x7f203edf7f53 - test::run_test_in_process::hcac6097c8c91186c
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/test/src/lib.rs:544
  30:     0x7f203edf7f53 - test::run_test::run_test_inner::{{closure}}::ha7ee66e96337f996
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/test/src/lib.rs:450
  31:     0x7f203edd0606 - std::sys_common::backtrace::__rust_begin_short_backtrace::h9e4f8413e9a9a61b
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/sys_common/backtrace.rs:137
  32:     0x7f203edd5835 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::hed8ea63dfb1598f0
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/thread/mod.rs:458
  33:     0x7f203edd5835 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h8f79bb62078df99c
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panic.rs:308
  34:     0x7f203edd5835 - std::panicking::try::do_call::h750feb1160046866
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panicking.rs:373
  35:     0x7f203edd5835 - std::panicking::try::h014cdec3fc92b0a5
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panicking.rs:337
  36:     0x7f203edd5835 - std::panic::catch_unwind::h2abab2e9cbb229d8
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/panic.rs:379
  37:     0x7f203edd5835 - std::thread::Builder::spawn_unchecked::{{closure}}::h7ea2abbe572a14c2
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/thread/mod.rs:457
  38:     0x7f203edd5835 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h7eb9087eb07aaa13
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/core/src/ops/function.rs:227
  39:     0x7f203f4b0c1a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hd50938a7cbd66861
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/alloc/src/boxed.rs:1042
  40:     0x7f203f4b0c1a - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hbdaa88962d74e8ba
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/alloc/src/boxed.rs:1042
  41:     0x7f203f4b0c1a - std::sys::unix::thread::Thread::new::thread_start::h2e71bf448b68bc62
                               at /rustc/397b390cc76ba1d98f80b2a24a371f708dcc9169/library/std/src/sys/unix/thread.rs:87
  42:     0x7f203ddc76db - start_thread
  43:     0x7f203d8c1a3f - __clone
  44:                0x0 - <unknown>


failures:
    config::test::test_merged_config

test result: FAILED. 167 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '--lib'
[cargo-make] ERROR - Error while executing command, exit code: 101
[cargo-make] WARN - Build Failed.

@calebcartwright
Copy link
Member

as you guessed, I didn't have the nightly toolchain installed. Sorry for that (I assume that I should have known to do that)

No worries. A recent nightly is required for the majority of the official Rust tools. The nightly requirement is called out explicitly in several places, but I guess folks that are brand new to Rust may not know exactly what that means/what they need to do.

I installed it now

What do you mean when you say "install"? You aren't running a cargo make install or a cargo +nightly install ... command are you?

and when running "cargo make test" on the rustfmt source I get the same panic that I get for my fork clone, although in this case version rustfmt 1.4.20-nightly was built (and not 2.x)

If you run through the steps I provided previously, and only those steps, there's no way you can be running the tests with v1.4.20. Could you please try again, in a new/clean directory, starting with a fresh clone of the repo?

@davidBar-On
Copy link
Contributor Author

What do you mean when you say "install"? You aren't running a cargo make install or a cargo +nightly install ... command are you?

I am using "cargo make test". By "install" I mean taking the steps described in https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust, mainly rustup toolchain install nightly.

If you run through the steps I provided previously, and only those steps, there's no way you can be running the tests with v1.4.20. Could you please try again, in a new/clean directory, starting with a fresh clone of the repo?

My mistake, the built version is rustfmt 2.0.0-rc.2-nightly, the same version as for the fork clone. I now tried again the steps you provided twice: once with the env variables CFG_RELEASE_CHANNEL and CFG_RELEASE set, and once when they were unset. In both cases I get the same panic.

@calebcartwright
Copy link
Member

By "install" I mean taking the steps described in https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust, mainly rustup toolchain install nightly

Gotcha, thanks!

In both cases I get the same panic.

What version of rust are you on? (rustc --version) What OS?

@davidBar-On
Copy link
Contributor Author

I found and fixed the problem which was a problem in my local machine. I added debug messages before src/config.rs:466 and found that path="/tmp/a/rustfmt.toml". After deleting /tmp/a the build works o.k, for both the direct rustfmt clone and for my fork clone. It may be that an old /tmp/a folder existed with the wrong permissions.

Thanks a lot for spending the effort to help with this issues.

@calebcartwright
Copy link
Member

Sure! Thanks for all the follow ups. It may be worth some tweaks to the test path to avoid any potential future overlaps, especially since /tmp/a could reasonably exist/be used elsewhere.

The only thing that matters for that particular test is that the second config file is in a subdirectory of the root of the first, doesn't really matter whether the root is a or something-rustfmt-random-asdfasdfawerawerfasdf

rustfmt/src/config.rs

Lines 645 to 680 in d7f0d76

fn test_merged_config() {
match option_env!("CFG_RELEASE_CHANNEL") {
// this test requires nightly
None | Some("nightly") => {
let _outer_config = make_temp_file(
"a/rustfmt.toml",
r#"
tab_spaces = 2
fn_call_width = 50
ignore = ["b/main.rs", "util.rs"]
"#,
);
let inner_config = make_temp_file(
"a/b/rustfmt.toml",
r#"
version = "two"
tab_spaces = 3
ignore = []
"#,
);
let inner_dir = inner_config.path.parent().unwrap();
let (config, paths) = load_config::<NullOptions>(Some(inner_dir), None).unwrap();
assert_eq!(config.tab_spaces(), 3);
assert_eq!(config.fn_call_width(), 50);
assert_eq!(config.ignore().to_string(), r#"["main.rs"]"#);
let paths = paths.unwrap();
assert!(paths[0].ends_with("a/rustfmt.toml"));
assert!(paths[1].ends_with("a/b/rustfmt.toml"));
}
_ => {}
};
}

@davidBar-On
Copy link
Contributor Author

It may be worth some tweaks to the test path to avoid any potential future overlaps, especially since /tmp/a could reasonably exist/be used elsewhere.

Should I close the issue or should it remain open for potentially changing a to unique directory name?

@calebcartwright
Copy link
Member

Should I close the issue or should it remain open for potentially changing a to unique directory name?

I'm going to go ahead and close, but feel free to open a new PR if you'd like to suggest a directory name change for that test 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants