aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/test/syntax_test.rb
blob: 0ea832bde62959a829e212f1fe849a0e752c4774 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require "test_helper"

describe "Syntax check" do
  project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../"))
  backend_files = Dir[project_root.join("**", "*.rb")].reject { |f| f.match %r{/vendor/|/Casks/} }
  interpreter = RUBY_PATH
  flags = %w[-c]
  flags.unshift "--disable-all"
  backend_files.each do |file|
    it "#{file} is valid Ruby" do
      args = flags + ["--", file]
      shutup do
        raise SyntaxError, "#{file} failed syntax check" unless system(interpreter, *args)
      end
    end
  end
end