-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
feature: adds "output" mode, resolves #270 #278
Conversation
src/verify.rs
Outdated
@@ -101,11 +137,21 @@ fn prompt_for_completion(exercise: &Exercise) -> bool { | |||
Mode::Compile => "The code is compiling!", | |||
Mode::Test => "The code is compiling, and the tests pass!", | |||
Mode::Clippy => "The code is compiling, and 📎 Clippy 📎 is happy!", | |||
Mode::Output(..) => "The code is compiling and the output is correct!", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message doesn't make sense for Mode::Output(None)
🤦♀️
tests/integration_tests.rs
Outdated
@@ -70,6 +70,26 @@ fn run_single_test_success() { | |||
.success(); | |||
} | |||
|
|||
#[test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't there tests for failure cases?
The behavior of rustlings run
for a mode="output"
exercise with expected output is to simply run the program without running the "test harness". So I can't actually test the test harness itself 😞 I suppose this could be an argument in favor of actually running the comparison on rustling run
.
tests/integration_tests.rs
Outdated
@@ -70,6 +70,26 @@ fn run_single_test_success() { | |||
.success(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmoko One little detail that I noticed: the verify_all_failure
test case misled me a bit, since it only tests that some exercise fails to verify. Should we change the name?
src/verify.rs
Outdated
|
||
match comparison_result { | ||
Ok(_) => { | ||
success!("Successfully tested {}!", exercise); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-added this line, a regression introduced in #271 🙈
I might be a month late, but I think the first option sounds good for now. How do you wanna continue with this, make the changes in this PR or open a new one? |
I can make the changes in this PR 👍 |
When running "compile"-mode exercises in interactive `verify` mode, we print their output when we prompt the learner if they want to continue. This improves the "experimentation" experience, since trying different things does produce a visible change.
Looks good now! I'm trying to figure out how we wanna release this... it's definitely a breaking change, and there's some SemVer minor things laying around on master, so we could either do a minor release and then a major one a bit after or just coagulate all of it into a major release. What do you think? |
Hm, usually I'd be inclined to push a minor and then a major, so people can avoid breakage if they want. However, given the way I assume most people consume rustlings (they clone it, work on it for a while, and probably never update the repo), I think it'd be fine to just release a major. |
feature: adds "output" mode, resolves rust-lang#270
feature: adds "output" mode, resolves rust-lang#270
mode = "output
.output = "foobar"
is specified for an"output"
exercise, it runs a "test" against the expected output."output"
exercise prints its output in the🎉 Move on when you're ready
screen.Screenshots
After playing a while with this, I'm not entirely sold on the idea 😅 I think having expected output could be useful in a very exploratory exercise like "Get
main
to printHello world!
to the screen". But, in general, I feel like"test"
exercises guide you better toward the answer. Takestructs1.rs
for instance and its hypothetical alternative:structs1.rs
structs1.rs
with"output"
I don't think it works quite as well, since the learner has no clue what the value of
green.name
should be until they get the program to compile and see the Expected/Actual error message. And it'll be way harder to reach that point without the clue on what the fields ofColorClassicStruct
should be. I suspect we could blame the exercise itself. Others, likeif1.rs
, might work better.What I do think it works great is non-expected output exercises. Most of the
"compile"
exercises felt a bit anti-climatic. Once you get the program to compile, you can still play with it thanks toI AM NOT DONE
, but you don't see the results of your tweaks. Even if we don't adoptmode="output"
, I think the default behavior of"compile"
should be this.So, summary of options:
"compile"
always print output.mode = "test"
exercises should be converted."compile"
always print as in (1) andreserve
mode = "output"
for mandatory expected output (i.e. changeMode::Output(Option<String>)
toMode::Output(String)
).