-
-
Notifications
You must be signed in to change notification settings - Fork 9.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
Fix SystemCommand
:path
.
#4453
Fix SystemCommand
:path
.
#4453
Conversation
9b21b18
to
11cd34e
Compare
be97f6c
to
8342ccd
Compare
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.
Looks good to me, except for minor nitpicks.
I’ve also tested installing/uninstalling the relevant cask, and found no regression.
end | ||
|
||
prefix << "--" | ||
["env", *variables] |
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.
env
→ /usr/bin/env
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? The environment is filtered by default, so this shouldn't matter.
end | ||
|
||
subject.run! | ||
context "and sudo: true" do |
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.
I feel this part of the code used to be a bit clearer and easier to read correctly when the contexts were not nested.
A condensed example:
Something something
and its result
Something something with sudo
and its result
is easier to read and understand correctly than:
Something something
and its result
with sudo
and its result
Also, un-nesting won't cost us anything here since the code is duplicated anyway.
it "raises an ArgumentError" do | ||
expect { described_class.run("true", env: { "1ABC" => true }) } | ||
.to raise_error(ArgumentError, /variable name/) | ||
end | ||
end | ||
|
||
it "looks for executables in custom PATH" do |
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.
in custom PATH
→ in a custom PATH
#!/bin/sh | ||
echo Hello, world! | ||
SH | ||
|
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.
Can we stick with the generic <<~EOS
for now, and aim to replace it one day in a single swoop if we have decided on alternatives?
It feels a little confusing to get 98 % EOS
(including lots of code snippets) and 2 % heredocs with other identifiers when I grep for <<~[A-Z]+$
.
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.
With SH
I get nested syntax-highlighting in TextMate.
@@ -23,7 +23,7 @@ module ScriptInstaller | |||
def install_phase(command: nil, **_) | |||
ohai "Running #{self.class.dsl_key} script '#{path.relative_path_from(cask.staged_path)}'" | |||
FileUtils.chmod "+x", path unless path.executable? | |||
command.run(path, **args, path: PATH.new(HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"])) | |||
command.run!(path, **args, env: { "PATH" => PATH.new(HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"]) }) |
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.
Good catch!
I wonder whether we could have caught this earlier with an artifact/installer_spec.rb
.
I feel this change warrants creating that spec, and have the class under test start out with PATH=/var/dummy
, then assert that the system command finds both HOMEBREW_PREFIX/"bin"
and /var/dummy
in its environment PATH
.
(No full coverage needed for now – just the tiny bit that’s being changed here!)
8342ccd
to
5f76aae
Compare
5f76aae
to
ebedebb
Compare
bb24e8f
to
845da8e
Compare
845da8e
to
20ec595
Compare
Thanks again @reitermarkus! |
brew style
with your changes locally?brew tests
with your changes locally?Use
:env
instead of:path
. (Was missed in #4265.)