Skip to content

Commit

Permalink
Fix assert_contains_make_command on make defined by environment varia…
Browse files Browse the repository at this point in the history
…ble.

The `parse_make_command_line` in `assert_contains_make_command` fails to get
the make targets correctly, when the make command is set with make options by
environment variable such as `export make='make -j2'` at
lib/rubygems/ext/builder.rb::make.

So, we include the make options (eg, -XX) as a part of the command to fix the
case. Note that this commit still doesn't fix the case of
`export make='make -j 2'`.
  • Loading branch information
junaruga authored and deivid-rodriguez committed Nov 9, 2021
1 parent 8c2725e commit 7730ef3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions test/rubygems/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def scan_make_command_lines(output)
end

def parse_make_command_line(line)
command, *args = line.shellsplit
args = line.sub(/^#{Regexp.escape make_command}/, "").shellsplit

targets = []
macros = {}
Expand All @@ -263,7 +263,7 @@ def parse_make_command_line(line)
targets << '' if targets.empty?

{
:command => command,
:command => make_command,
:targets => targets,
:macros => macros,
}
Expand Down
10 changes: 7 additions & 3 deletions test/rubygems/test_gem_ext_ext_conf_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ def test_class_build_rbconfig_make_prog
end
end

def test_class_build_env_make
env_make = ENV.delete 'MAKE'
def test_class_build_env_MAKE
env_make = ENV.delete 'make'
ENV['make'] = nil

env_MAKE = ENV.delete 'MAKE'
ENV['MAKE'] = 'anothermake'

if java_platform?
Expand All @@ -89,7 +92,8 @@ def test_class_build_env_make
assert_contains_make_command 'clean', output[4]
end
ensure
ENV['MAKE'] = env_make
ENV['MAKE'] = env_MAKE
ENV['make'] = env_make
end

def test_class_build_extconf_fail
Expand Down

0 comments on commit 7730ef3

Please sign in to comment.