diff options
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/test_integration_cmds.rb | 20 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_shell.rb | 38 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_utils.rb | 11 |
3 files changed, 64 insertions, 5 deletions
diff --git a/Library/Homebrew/test/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb index 330e7c0a8..4c0330340 100644 --- a/Library/Homebrew/test/test_integration_cmds.rb +++ b/Library/Homebrew/test/test_integration_cmds.rb @@ -227,6 +227,26 @@ class IntegrationCommandTests < Homebrew::TestCase cmd("--env")) end + def test_env_bash + assert_match %r{export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"}, + cmd("--env", "--shell=bash") + end + + def test_env_fish + assert_match %r{set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"}, + cmd("--env", "--shell=fish") + end + + def test_env_csh + assert_match %r{setenv CMAKE_PREFIX_PATH}, + cmd("--env", "--shell=tcsh") + end + + def test_env_plain + assert_match %r{CMAKE_PREFIX_PATH: #{Regexp.quote(HOMEBREW_PREFIX)}}, + cmd("--env", "--plain") + end + def test_prefix_formula assert_match "#{HOMEBREW_CELLAR}/testball", cmd("--prefix", testball) diff --git a/Library/Homebrew/test/test_shell.rb b/Library/Homebrew/test/test_shell.rb new file mode 100644 index 000000000..63ca5adaa --- /dev/null +++ b/Library/Homebrew/test/test_shell.rb @@ -0,0 +1,38 @@ +require "testing_env" +require "utils/shell" + +class ShellSmokeTest < Homebrew::TestCase + def test_path_to_shell() + # raw command name + assert_equal :bash, Utils::Shell.path_to_shell("bash") + # full path + assert_equal :bash, Utils::Shell.path_to_shell("/bin/bash") + # versions + assert_equal :zsh, Utils::Shell.path_to_shell("zsh-5.2") + # strip newline too + assert_equal :zsh, Utils::Shell.path_to_shell("zsh-5.2\n") + end + + def test_path_to_shell_failure() + assert_equal nil, Utils::Shell.path_to_shell("") + assert_equal nil, Utils::Shell.path_to_shell("@@@@@@") + assert_equal nil, Utils::Shell.path_to_shell("invalid_shell-4.2") + end + + def test_sh_quote() + assert_equal "''", Utils::Shell.sh_quote("") + assert_equal "\\\\", Utils::Shell.sh_quote("\\") + assert_equal "'\n'", Utils::Shell.sh_quote("\n") + assert_equal "\\$", Utils::Shell.sh_quote("$") + assert_equal "word", Utils::Shell.sh_quote("word") + end + + def test_csh_quote() + assert_equal "''", Utils::Shell.csh_quote("") + assert_equal "\\\\", Utils::Shell.csh_quote("\\") + # note this test is different + assert_equal "'\\\n'", Utils::Shell.csh_quote("\n") + assert_equal "\\$", Utils::Shell.csh_quote("$") + assert_equal "word", Utils::Shell.csh_quote("word") + end +end diff --git a/Library/Homebrew/test/test_utils.rb b/Library/Homebrew/test/test_utils.rb index 9b55965b5..3d30baf9c 100644 --- a/Library/Homebrew/test/test_utils.rb +++ b/Library/Homebrew/test/test_utils.rb @@ -1,6 +1,7 @@ require "testing_env" require "utils" require "tempfile" +require "utils/shell" class TtyTests < Homebrew::TestCase def test_strip_ansi @@ -157,15 +158,15 @@ class UtilTests < Homebrew::TestCase def test_shell_profile ENV["SHELL"] = "/bin/sh" - assert_equal "~/.bash_profile", shell_profile + assert_equal "~/.bash_profile", Utils::Shell.shell_profile ENV["SHELL"] = "/bin/bash" - assert_equal "~/.bash_profile", shell_profile + assert_equal "~/.bash_profile", Utils::Shell.shell_profile ENV["SHELL"] = "/bin/another_shell" - assert_equal "~/.bash_profile", shell_profile + assert_equal "~/.bash_profile", Utils::Shell.shell_profile ENV["SHELL"] = "/bin/zsh" - assert_equal "~/.zshrc", shell_profile + assert_equal "~/.zshrc", Utils::Shell.shell_profile ENV["SHELL"] = "/bin/ksh" - assert_equal "~/.kshrc", shell_profile + assert_equal "~/.kshrc", Utils::Shell.shell_profile end def test_popen_read |
