From 9a29a306cfd6b116a0cb696ce56bd7bc7679a8e3 Mon Sep 17 00:00:00 2001 From: Greg Nisbet Date: Wed, 10 Aug 2016 23:19:09 -0700 Subject: resolve conflict in diagnostic.rb --- Library/Homebrew/test/test_shell.rb | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Library/Homebrew/test/test_shell.rb (limited to 'Library/Homebrew/test/test_shell.rb') 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 -- cgit v1.2.3 From f1ce3585511c6c13a0628534c0399a3638f98596 Mon Sep 17 00:00:00 2001 From: Greg Nisbet Date: Fri, 13 May 2016 00:23:14 -0700 Subject: Utils::Shell.shell_profile in formula_cellar_checks --- Library/Homebrew/test/test_shell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library/Homebrew/test/test_shell.rb') diff --git a/Library/Homebrew/test/test_shell.rb b/Library/Homebrew/test/test_shell.rb index 63ca5adaa..5a1057457 100644 --- a/Library/Homebrew/test/test_shell.rb +++ b/Library/Homebrew/test/test_shell.rb @@ -30,7 +30,7 @@ class ShellSmokeTest < Homebrew::TestCase def test_csh_quote() assert_equal "''", Utils::Shell.csh_quote("") assert_equal "\\\\", Utils::Shell.csh_quote("\\") - # note this test is different + # note this test is different than for sh assert_equal "'\\\n'", Utils::Shell.csh_quote("\n") assert_equal "\\$", Utils::Shell.csh_quote("$") assert_equal "word", Utils::Shell.csh_quote("word") -- cgit v1.2.3 From bf63c08d50acb5fa79413325029e67e2c28a6023 Mon Sep 17 00:00:00 2001 From: Greg Nisbet Date: Sun, 22 May 2016 18:02:39 -0700 Subject: tests for shell-specific diagnostic message --- Library/Homebrew/test/test_shell.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Library/Homebrew/test/test_shell.rb') diff --git a/Library/Homebrew/test/test_shell.rb b/Library/Homebrew/test/test_shell.rb index 5a1057457..5e054f9d9 100644 --- a/Library/Homebrew/test/test_shell.rb +++ b/Library/Homebrew/test/test_shell.rb @@ -35,4 +35,25 @@ class ShellSmokeTest < Homebrew::TestCase assert_equal "\\$", Utils::Shell.csh_quote("$") assert_equal "word", Utils::Shell.csh_quote("word") end + + def prepend_path_shell(shell, path, fragment) + original_shell = ENV["SHELL"] + ENV["SHELL"] = shell + + prepend_message = Utils::Shell.prepend_path_in_shell_profile(path) + assert( + prepend_message.start_with?(fragment), + "#{shell}: expected #{prepend_message} to match #{fragment}" + ) + + ENV["SHELL"] = original_shell + end + + def test_prepend_path_in_shell_profile() + prepend_path_shell "/bin/tcsh", "/path", "echo 'setenv PATH /path" + + prepend_path_shell "/bin/bash", "/path", "echo 'export PATH=\"/path" + + prepend_path_shell "/usr/local/bin/fish", "/path", "echo 'set -g fish_user_paths \"/path\" $fish_user_paths' >>" + end end -- cgit v1.2.3