-
Notifications
You must be signed in to change notification settings - Fork 543
Cargo test fails for hello-world #585
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
Comments
@Eratosthenes That's a bizarre error. Would you be willing to paste in the output of |
|
Hmm. I could not replicate this: $ rustc --version && cargo --version
Sun Jul 22 15:17:38 DST 2018
rustc 1.27.2 (58cc626de 2018-07-18)
cargo 1.27.0 (1e95190e5 2018-05-27)
$ cat src/lib.rs
Sun Jul 22 15:17:50 DST 2018
pub fn hello() -> &'static str {
"Hello, World!"
}
$ cargo test
Sun Jul 22 15:17:56 DST 2018
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running target/debug/deps/hello_world-034f85fca78591a8
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/hello_world-3a498d4002339e15
running 1 test
test test_hello_world ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Doc-tests hello-world
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out Perhaps something is going on in the tests? My extern crate hello_world;
#[test]
fn test_hello_world() {
assert_eq!("Hello, World!", hello_world::hello());
} If that is the same on your machine, then my best bet is that something has gone wrong with your rustc or llvm installations. I'd delete it, and then use rustup to reinstall. |
Segmentation faults are the kind of problem that Rust was explicitly designed to prevent, after all. They shouldn't be possible in the absence of |
Ok, I ran
And then reinstalled rust. Deleted the hello-world directory and tried again. Still getting the exact same error. Maybe the issue is with my version of exercism? |
Reinstalled exercism and re-downloaded problem. Still getting the same error.
I'm using Mac OS X 10.10.5 btw. |
I really don't know what's going on. Your OS is a bit old, but it's still in the tier 1 supported list. It shouldn't be an exercism issue; this is the rust compiler producing something which segfaults, which shouldn't be a thing. I'll ask you to perform one more test, and if it fails, you should create an issue in the core rust repo. Try doing this: $ cd
$ cargo new --bin hello
$ cd hello/ Use your editor of choice to create the following two files:
pub fn hello() -> &'static str {
"Hello World!"
}
extern crate hello;
use hello::hello;
fn main() {
println!("{}", hello());
} Finally, run: cargo run This does almost exactly what the exercism hello world exercise does, just in a main function. If this fails with a segfault, it's time to create an issue in the rust main repo. If this succeeds, it's time to create a test file, just like exercism does:
extern crate hello;
use hello::hello;
#[test]
fn test_hello() {
assert_eq!(hello(), "Hello World!");
} Then run: cargo test If this succeeds, then I'll be totally stumped: that's doing exactly what exercism does, except in a different path, and we constructed it manually. If it fails, you'll have two different instances you can use to create a bug in the core rust repo. |
Ok, so: In the example above, cargo run works and cargo test fails with the same error:
And when I run the executable I get a segmentation fault:
|
Fascinating. This is a rust bug unrelated to exercism, and I bet they'd be interested in a bug report at their repo, listing all the steps you've taken and the results you've gotten. Unfortunately, it also means that we've reached the limit of my own ability to help you. I can't reproduce your issue on either of the machines I have available, which suggests that whatever is going on, it is likely to be machine-specific. If you have another machine available, I suggest moving to that for the rust track exercises. I'm sorry I couldn't resolve this positively, but there is nothing else I can do. [edit] fixed rust repo link |
FWIW, this appears to be related to rust-lang/rust#52390. |
Cool... glad I'm not the only one! So, I uninstalled rust again and installed version 1.28.0-beta. Running that version works. Thanks for your help! |
Can anyone help me get hello-world working? Here's what happens when I run cargo test:
I believe I'm on the latest version of rust:
The weird thing is that I can see the executable file sitting there. When I run it, I get this output though:
The text was updated successfully, but these errors were encountered: