-
-
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
Print build errors to stderr #4494
Conversation
3ba7d12
to
ab04bed
Compare
LGTM! I think the two cases you mention should also print to stderr. Why would you send them to stdout? |
About the JSON formatted errors, I'm thinking about the use-case of using shell commands: $ crystal build --format json file.cr | use_the_json_output Once the JSON errors will be on stderr, they'll have a hard time getting the correct stream to go in the pipe to But maybe it's not our business, and it should stay on stderr, as most users will use their language's stdlib to spawn a process and granuraly get it's stdout/stderr programmatically. |
c9bc54e
to
06a304d
Compare
I fixed the specs, but now I don't know why the build doesn't work, did I broke something else? https://travis-ci.org/crystal-lang/crystal/jobs/240012478 |
@bew so far, so (green) good... :) |
The travis build fails so often on osx, why don't we just disable it or ignore the results and use circleci only? |
06a304d
to
8daf815
Compare
8daf815
to
d84e42c
Compare
Rebased, osx still failing, are we waiting for #4528 to be merged? Or can we merge this PR soon? |
d84e42c
to
7177f4a
Compare
Looks like GTG, merge-time? |
7177f4a
to
800f6d7
Compare
I'm unsure to write errors to STDERR in JSON output case. Better to choose output stream by output format. Errors to JSON to STDOUT is ok. Isn't it? |
@akzhan I'd expect to see errors on |
@akzhan I believe that an error message should always go to stderr, whatever the output format is. |
Looks good to me, would be nice if we could spec this behaviour but i'm not really opposed to landing this without specs. |
Restarted the build (I know, I know, we'll tackle that soon :)). |
@mverzilli this PR is from may so I guess it doesn't have the |
Remove unnecessary I/O flush, it's already done in the `main`. Note: The notation `command 2>&1 >/dev/null` will close stdout, then redirect stderr to (a new) stdout.
800f6d7
to
0ffaa94
Compare
@RX14 You're right, I've rebased the branch on current master it should be good now. |
I've found another place where output should go on STDERR: diff --git a/src/spec.cr b/src/spec.cr
index 2c3c303a5..aa49cdbcf 100644
--- a/src/spec.cr
+++ b/src/spec.cr
@@ -83,8 +83,8 @@ OptionParser.parse! do |opts|
if location =~ /\A(.+?)\:(\d+)\Z/
Spec.add_location $1, $2.to_i
else
- puts "location #{location} must be file:line"
- exit
+ STDERR.puts "location #{location} must be file:line"
+ exit 1
end
end
opts.on("--junit_output OUTPUT_DIR", "generate JUnit XML output") do |output_dir|
@@ -106,7 +106,7 @@ OptionParser.parse! do |opts|
end
unless ARGV.empty?
- puts "Error: unknown argument '#{ARGV.first}'"
+ STDERR.puts "Error: unknown argument '#{ARGV.first}'"
exit 1
end Should I add this change in this PR ? (it's not a build error, but it's still an error) |
@bew IMHO it's an addition in line with this PR, so yes, I'd add it too. |
@bew that's not actually build errors though is it? I'm fine with modifying the spec runner in this PR but the commit should be renamed to "Print build and spec errors to stderr". |
Indeed it's not a build error, that's why I asked first. I'll make another PR later today (or someone else can if he wants to!) for the spec runners, as it was not in the scope of this PR to check every possible |
@bew so, is this ready to merge? |
If you all agree, yes I think so. |
Great job @bew! Thank you ❤️ |
This addresses #4451
There are some cases which needs discussion about where to prints them: