Fix change_make_var!
for empty variables.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
This commit is contained in:
parent
1e9c7df871
commit
d03411775f
@ -6,6 +6,14 @@ class InreplaceTest < Test::Unit::TestCase
|
|||||||
s1.change_make_var! "FLAG", "def"
|
s1.change_make_var! "FLAG", "def"
|
||||||
assert_equal "FLAG=def", s1
|
assert_equal "FLAG=def", s1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_change_make_var_empty
|
||||||
|
# Replace empty flag
|
||||||
|
s1="FLAG = \nFLAG2=abc"
|
||||||
|
s1.extend(HomebrewInreplaceExtension)
|
||||||
|
s1.change_make_var! "FLAG", "def"
|
||||||
|
assert_equal "FLAG=def\nFLAG2=abc", s1
|
||||||
|
end
|
||||||
|
|
||||||
def test_change_make_var_append
|
def test_change_make_var_append
|
||||||
# Append to flag
|
# Append to flag
|
||||||
|
@ -157,7 +157,7 @@ module HomebrewInreplaceExtension
|
|||||||
# value with "new_value", or removes the definition entirely.
|
# value with "new_value", or removes the definition entirely.
|
||||||
def change_make_var! flag, new_value
|
def change_make_var! flag, new_value
|
||||||
new_value = "#{flag}=#{new_value}"
|
new_value = "#{flag}=#{new_value}"
|
||||||
gsub! Regexp.new("^#{flag}\\s*=\\s*(.*)$"), new_value
|
gsub! Regexp.new("^#{flag}\\s*=[ \\t]*(.*)$"), new_value
|
||||||
end
|
end
|
||||||
# Removes variable assignments completely.
|
# Removes variable assignments completely.
|
||||||
def remove_make_var! flags
|
def remove_make_var! flags
|
||||||
|
Loading…
x
Reference in New Issue
Block a user