2010-01-29 10:41:03 -08:00
|
|
|
class InreplaceTest < Test::Unit::TestCase
|
|
|
|
def test_change_make_var
|
|
|
|
# Replace flag
|
|
|
|
s1="FLAG = abc"
|
|
|
|
s1.extend(HomebrewInreplaceExtension)
|
|
|
|
s1.change_make_var! "FLAG", "def"
|
|
|
|
assert_equal "FLAG=def", s1
|
|
|
|
end
|
2010-03-12 13:24:04 +01:00
|
|
|
|
|
|
|
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
|
2010-01-29 10:41:03 -08:00
|
|
|
|
|
|
|
def test_change_make_var_append
|
|
|
|
# Append to flag
|
|
|
|
s1="FLAG = abc"
|
|
|
|
s1.extend(HomebrewInreplaceExtension)
|
|
|
|
s1.change_make_var! "FLAG", "\\1 def"
|
|
|
|
assert_equal "FLAG=abc def", s1
|
|
|
|
end
|
2010-02-09 09:21:25 -08:00
|
|
|
|
|
|
|
def test_change_make_var_shell_style
|
|
|
|
# Shell variables have no spaces around =
|
|
|
|
s1="FLAG=abc"
|
|
|
|
s1.extend(HomebrewInreplaceExtension)
|
|
|
|
s1.change_make_var! "FLAG", "def"
|
|
|
|
assert_equal "FLAG=def", s1
|
|
|
|
end
|
2010-01-29 10:41:03 -08:00
|
|
|
|
|
|
|
def test_remove_make_var
|
|
|
|
# Replace flag
|
|
|
|
s1="FLAG = abc\nFLAG2 = def"
|
|
|
|
s1.extend(HomebrewInreplaceExtension)
|
|
|
|
s1.remove_make_var! "FLAG"
|
2010-02-09 09:21:25 -08:00
|
|
|
assert_equal "FLAG2 = def", s1
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_remove_make_vars
|
|
|
|
# Replace flag
|
|
|
|
s1="FLAG = abc\nFLAG2 = def"
|
|
|
|
s1.extend(HomebrewInreplaceExtension)
|
|
|
|
s1.remove_make_var! ["FLAG", "FLAG2"]
|
2010-02-09 09:21:25 -08:00
|
|
|
assert_equal "", s1
|
2010-01-29 10:41:03 -08:00
|
|
|
end
|
|
|
|
end
|