Skip to content
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

Modifying all exercises to work with cargo #18

Closed
EduardoBautista opened this issue Oct 9, 2014 · 14 comments · Fixed by #27
Closed

Modifying all exercises to work with cargo #18

EduardoBautista opened this issue Oct 9, 2014 · 14 comments · Fixed by #27

Comments

@EduardoBautista
Copy link
Contributor

It looks like cargo will be the preferred way to run tests going forward. Since it comes with Rust, we should probably set up the exercises so that cargo run and cargo test can be used. I can help by making the changes.

@etrepum
Copy link
Contributor

etrepum commented Oct 9, 2014

👍

@pminten
Copy link
Contributor

pminten commented Oct 9, 2014

I've played around with this approach myself, but in the end my conclusion was that cargo doesn't add much benefit when you don't use dependencies.

For the exercism use case cargo test his equivalent to rustc --test test.rs && ./test

So cargo does simplify things a little bit for the user. On the other hand it requires adding a cargo.toml file and a subdir to hold the lib.rs and test.rs file, so it does add bureaucracy.

Looking at other tracks Elixir uses a direct invocation of the test file, even though mix (cargo equiv) is available. OCAM has simple makefiles that invokes a compilation manager (not a package system like cargo). Haskell uses direct invocation of the test file (using a standard script that immediately executes a compiled file).

All that said I'd love to hear more opinions about this.

Eduardo Bautista [email protected] schreef op 9 oktober 2014 20:18:33 CEST:

It looks like cargo will be the preferred way to run tests going
forward. Since it comes with Rust, we should probably set up the
exercises so that cargo run and cargo test can be used. I can help
by making the changes.


Reply to this email directly or view it on GitHub:
#18

@EduardoBautista
Copy link
Contributor Author

@pminten I think running cargo run instead of rustc bob.rs && ./bob is more convenient, especially since it's going to be the most common approach moving forward.

@pminten
Copy link
Contributor

pminten commented Oct 9, 2014

Oh, I do agree that it's more convenient. Whether it's going to be the common approach for two file rust programs remains to be seen, though it's quite possible.

We may want to consider though whether the more "primitieve" compiler and run approach providers a learning benefit since it teaches people how compilation works under the hood of cargo.

Eduardo Bautista [email protected] schreef op 9 oktober 2014 21:41:55 CEST:

@pminten I think running cargo run instead of rustc bob.rs && ./bob
is more convenient, especially since it's going to be the most common
approach moving forward.


Reply to this email directly or view it on GitHub:
#18 (comment)

Verzonden van mijn Android telefoon met K-9 Mail.

@EduardoBautista
Copy link
Contributor Author

@pminten Yeah, I understand that. Although, even the official guide stops using rustc by chapter 3. It might be beyond the scope of exercism to get "under the hood" and we should just focus on compiling and testing in the simplest way possible. Teaching people to learn the basic structure that cargo expects is also a good thing.

@kytrinyx
Copy link
Member

kytrinyx commented Oct 9, 2014

I would actually think that keeping things close to the metal (fewer dependencies) would be a good thing in exercism, provided that it's not an anti-pattern in the language. I see exercism as being about understanding the fundamentals as deeply as possible. All the magic/convenience of higher-level tools is often something that obscures things for beginners, whereas if you're comfortable with the fundamentals, adding a convenience wrapper is trivial.

@EduardoBautista
Copy link
Contributor Author

Well, with all things Rust on exercism, lets make this decision once the language is stable 😛

@kytrinyx
Copy link
Member

lets make this decision once the language is stable

Yeah, good point.

@jakejscott
Copy link

At the moment, there's 3 different places that help explain how to do testing in rust, we should point people at these docs so they can read them first?

cc @steveklabnik

The Rust Guide
http://doc.rust-lang.org/guide.html#testing

The Rust Testing guide
http://doc.rust-lang.org/guide-testing.html

The Crates Guide
http://crates.io/guide.html#tests

@steveklabnik
Copy link
Contributor

In general, Cargo is how you maintain packages, but Exercism isn't exactly a package. I'd just assume a small, single file, rustc invocation.

The Testing Guide is the best place to point people, though I haven't revised it yet.

@andrewclarkson
Copy link
Contributor

I'd really like to give this a bump.
Cargo has become the defacto way to do testing in Rust and now ships with Rust.

I'd be willing to create a pull request to add cargo to the exercises, if that's the direction we want to move.

@steveklabnik
Copy link
Contributor

In general, they're gonna need updated period. But yes, Cargo should be involved.

@mirosval
Copy link

mirosval commented Apr 4, 2015

I'm new to Rust and was hoping to start learning using Exercism, but with Rust 1.0.0-beta I don't even know how to run the tests w/o cargo, because the docs just don't mention it.

So +1 for Cargo-based test for Rust Exercism!

@steveklabnik
Copy link
Contributor

With beta out, it would be a decent time to start doing this.

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

Successfully merging a pull request may close this issue.

8 participants