From 04a9b0022d42fea55f3435e461008525a7199a61 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 14 Jan 2016 14:13:10 +0000 Subject: [PATCH] test_bash: tests to assert Bash syntax is valid. Closes Homebrew/homebrew#47380. --- Library/Homebrew/test/test_bash.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Library/Homebrew/test/test_bash.rb diff --git a/Library/Homebrew/test/test_bash.rb b/Library/Homebrew/test/test_bash.rb new file mode 100644 index 0000000000..b77927e0b7 --- /dev/null +++ b/Library/Homebrew/test/test_bash.rb @@ -0,0 +1,16 @@ +require "testing_env" + +class BashTests < Homebrew::TestCase + def assert_valid_bash_syntax(files) + output = Utils.popen_read("/bin/bash -n #{files} 2>&1") + assert $?.success?, output + end + + def test_bin_brew + assert_valid_bash_syntax "#{HOMEBREW_LIBRARY_PATH.parent.parent}/bin/brew" + end + + def test_bash_cmds + assert_valid_bash_syntax "#{HOMEBREW_LIBRARY_PATH}/cmd/*.sh" + end +end