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

Warnings are being swallowed (unless --error-on-warnings is on) #535

Closed
beta-ziliani opened this issue Dec 3, 2021 · 8 comments
Closed

Comments

@beta-ziliani
Copy link
Member

Basically, the problematic line is:

status = Process.run("crystal", args: args, output: Process::Redirect::Inherit, error: error)

It is writing the error on a local memory object that is discarded unless there is an unsuccessful build.

Example:

➜  d git:(main) ✗ cat shard.yml
name: d
version: 1
targets:
  d:
    main: d.cr
➜  d git:(main) ✗ cat d.cr
@[Deprecated]
def a
end

a
➜  d git:(main) ✗ shards build
Dependencies are satisfied
Building: d
➜  d git:(main) ✗ crystal build d.cr
In d.cr:5:1

 5 | a
     ^
Warning: Deprecated top-level a.

A total of 1 warnings were found.
@straight-shoota
Copy link
Member

Yeah, I think passing STDERR through like STDOUT makes sense. shards build is supposed to be just a thin wrapper around crystal build.

@beta-ziliani
Copy link
Member Author

not as stderr? I was planning on forwarding it to stderr

@straight-shoota
Copy link
Member

Yeah, pass STDERR through to STDERR of course. I just compared it to STDOUT because there we already do that.

@luislavena
Copy link
Contributor

luislavena commented Dec 15, 2021

@beta-ziliani this means the raise exception should change?

raise Error.new("Error target #{target.name} failed to compile:\n#{error}") unless status.success?

Now STDERR is already part of the output so there is no error to use for that message.

Is that what you mean?

If that is the case, something like the following is what you would be expecting the output to be?

$ shards build
Dependencies are satisfied
Building: d
In d.cr:5:1

 5 | a
     ^
Warning: Deprecated top-level a.

A total of 1 warnings were found.

And when it errors, the last line will be Error target d failed to compile. with the entire error already shown above (due the usage of STDERR)

Thank you
❤️ ❤️ ❤️

@beta-ziliani
Copy link
Member Author

Sorry for the delay, @luislavena , yes, that's what I mean

@luislavena
Copy link
Contributor

No worries @beta-ziliani, thanks for responding!

I will be happy to send a PR with this change later this week 😊

Cheers.
❤️ ❤️ ❤️

PS: Happy New Year! 🎉

@beta-ziliani
Copy link
Member Author

I'm finishing on one right now :-) But I'll be happy to have your review. Happy new year for you too! 🎉

beta-ziliani added a commit that referenced this issue Jan 18, 2022
Solves #535 by outputting the STDERR of the crystal build to the STDERR of the shards process only if the build is successful. This allows to notice deprecation warnings and the like.
@luislavena
Copy link
Contributor

luislavena commented Jan 19, 2022

Thank you @beta-ziliani!!! 🎉 🥳 👏🏽

I think this one can be closed now that #540 has been merged!
❤️ ❤️ ❤️

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

No branches or pull requests

3 participants