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

View a specific exercise's stdout #262

Closed
samaaron opened this issue Jan 7, 2020 · 6 comments · Fixed by #422
Closed

View a specific exercise's stdout #262

samaaron opened this issue Jan 7, 2020 · 6 comments · Fixed by #422
Labels
A-source Area: CLI source C-feature-request Category: Feature Request

Comments

@samaaron
Copy link

samaaron commented Jan 7, 2020

Hi there,

I'm working through rustlings on a Windows machine. It's a wonderful resource - thank-you so much for putting the effort into making it.

One thing I have yet to figure out is how to view the output of the current exercise. Currently I just see if an exercise compiles (and the compile errors if not). However, if an exercise uses println! it would be lovely to be able to see that output somewhere.

Am I doing something wrong or is this something that's yet to be implemented?

@rrcobb
Copy link

rrcobb commented Jan 8, 2020

Hi @samaaron! I think you can get the results of a single exercise (complete with the stdout) using rustlings run <name_of_exercise>.

So, for me,

$: rustlings run variables3
Number 3
Number 5

✅ Successfully ran exercises/variables/variables3.rs

I don't know if there's a way to get stdout with rustlings verify or with rustlings watch. Maybe getting stdout while watch is incrementally re-running would be a good feature request!

@fspy
Copy link

fspy commented Mar 31, 2020

I am also unable to get the output on rustlings run. WSL2, fish/bash.

What can I do that might help diagnose this issue?

@fspy
Copy link

fspy commented Mar 31, 2020

To add to my previous comment, I tried running different programs that actually have a main function, and most of them work.

Here are the ones that didn't:
as_ref_mut, from_into, errors3, primitive_types1, traits1.

@shadows-withal shadows-withal added A-source Area: CLI source C-feature-request Category: Feature Request labels Apr 5, 2020
@AbdouSeck
Copy link
Contributor

Hi @fspy, just because a program file has a main in it does not mean that the main function will get invoked. The info.toml file helps the commands look for programs to compile and run or test. If an exercise has a value of test for mode in the info.toml, that means that the program will get compiled and tested only. Its main function does not get invoked.

But you're probably still wondering why then the println! lines in the test cases are not showing? That is a valid question, and one whose answer lies within the rustc --test command that is used by rustlings to run target tests. We can, relatively easily, add the feature to have rustc --test generate display the printed stuff to the standard output (or error).

One solution to your problem may be to add a global flag/option to rustlings called something like --show-output which should force the run, verify and watch commands to output stuff even when the mode of the target exercise is test.

Please, everyone, feel free to chime in and let me know what you think.

Thank you!

Abdou

@AbdouSeck
Copy link
Contributor

@rrcobb @samaaron forgot to mention you in the comment above

AbdouSeck added a commit to AbdouSeck/rustlings that referenced this issue Jun 4, 2020
This new feature can be accessed by invoking rustlings with --nocapture.

Both unit and integration tests added.

closes rust-lang#262

BREAKING CHANGES:
The following function take a new boolean argument:
	* `run`
	* `verify`
	* `test`
	* `compile_and_test`
MendelMonteiro pushed a commit to MendelMonteiro/rustlings that referenced this issue Jun 28, 2020
This new feature can be accessed by invoking rustlings with --nocapture.

Both unit and integration tests added.

closes rust-lang#262

BREAKING CHANGES:
The following function take a new boolean argument:
	* `run`
	* `verify`
	* `test`
	* `compile_and_test`
dlemel8 pushed a commit to dlemel8/rustlings that referenced this issue Aug 2, 2020
This new feature can be accessed by invoking rustlings with --nocapture.

Both unit and integration tests added.

closes rust-lang#262

BREAKING CHANGES:
The following function take a new boolean argument:
	* `run`
	* `verify`
	* `test`
	* `compile_and_test`
ppp3 pushed a commit to ppp3/rustlings that referenced this issue May 23, 2022
This new feature can be accessed by invoking rustlings with --nocapture.

Both unit and integration tests added.

closes rust-lang#262

BREAKING CHANGES:
The following function take a new boolean argument:
	* `run`
	* `verify`
	* `test`
	* `compile_and_test`
dmoore04 pushed a commit to dmoore04/rustlings that referenced this issue Sep 11, 2022
This new feature can be accessed by invoking rustlings with --nocapture.

Both unit and integration tests added.

closes rust-lang#262

BREAKING CHANGES:
The following function take a new boolean argument:
	* `run`
	* `verify`
	* `test`
	* `compile_and_test`
@sturmenta
Copy link

thanks @AbdouSeck, now I can see my logs using rustlings --nocapture watch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-source Area: CLI source C-feature-request Category: Feature Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants