-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
run
macro shows stderr when succeeded but there is stderr output
#5174
base: master
Are you sure you want to change the base?
run
macro shows stderr when succeeded but there is stderr output
#5174
Conversation
It helps to debug `run` macro.
I don't think this is correct. If |
What I mean is, if {{ run "bar.cr" }} and If you need to debug a macro run you can just run that file. That's the whole point of macro run being able to run files and passing arguments to it, it's just a regular program that you can test outside of macros. |
I see what you mean @asterite, maybe the stderr of the macro run should be printed (for debug purpose) on the stderr of the caller, so that nested macro run's debugs always end up in stderr in the end, and are not understood as being part of the macro run's code output? (not sure if it's clear, I can rephrase otherwise) |
Yes, printing to STDERR is probably good. |
Indeed, but passing correct argument to And I don't understand about what you are afraid. Because this example works: $ cat foo.cr
STDERR.puts "from foo.cr"
$ cat bar.cr
{{ run("./foo.cr") }}
STDERR.puts "from bar.cr"
puts "pp 1 + 2"
$ cat main.cr
{{ run("./bar.cr") }}
$ ./crystal run main.cr
Success executing run: ./foo.cr
stderr:
from foo.cr
Success executing run: ./bar.cr
stderr:
from bar.cr
1 + 2 # => 3
|
Hm, for some reason it works. It still looks like a hack, though. Why printing to STDERR is the way to debug this? Why STDERR is only shown on success? I'm still not sure about this. |
@makenowjust But why does this example work? Judging from your code, running |
Debugging tastes like hacking sometime ;)
Why losing STDERR output is right? This PR comes from that. @straight-shoota I've already exaplained:
|
I think this is generally useful, but how about we just connect the invoked program's stderr to the compiler's? that is we print the stderr of the called file to the compiler's stderr in any case and maybe just prefix it with something like |
Currently
run
macro loses stderr output when it is succeeded.So
crystal run bar.cr
says nothing, but I think it is useful for debugging if stderr is showed.