Browse Source

Merge pull request #338 from federicobond/test-suite

Add minimal test suite
master
Roland Walker 11 years ago
parent
commit
2f983f8f6a
  1. 71
      .travis.yml
  2. 8
      Gemfile
  3. 19
      Gemfile.lock
  4. 8
      Rakefile
  5. 14
      test/Casks/compliance_test.rb
  6. 38
      test/test_helper.rb

71
.travis.yml

@ -0,0 +1,71 @@
language: objective-c
# todo
#
# test with Ruby 1.9, but allow failure
# test with Ruby 2.1, but allow failure
#
# "Current" is currently a duplicate of either 1.8 or 2.0, depending on OS version
env:
matrix:
- CASK_RUBY_TEST_VERSION="1.8"
- CASK_RUBY_TEST_VERSION="2.0"
- CASK_RUBY_TEST_VERSION="Current"
# permit "Current" to fail without affecting our badge
matrix:
allow_failures:
- env: CASK_RUBY_TEST_VERSION="Current"
fast_finish: true
# before_install steps
# * turn off RVM
# * set PATH according to env matrix
# * update Homebrew
# * informational feedback
before_install:
- rvm use system
- export PATH="/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin":"$PATH"
- brew update
- printenv PATH
- /usr/bin/which ruby
- ruby --version
- /usr/bin/which rake
- rake --version
- echo ls_ruby_bindir; ls "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin"
# install steps
# * bundler gem
# * Ruby gems required for brew-cask
install:
- echo gem_install_bundler; sudo "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin/gem" install bundler --bindir="/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin"
- echo bundle; sudo "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin/bundle" --system
- brew install caskroom/cask/brew-cask
# informational feedback
before_script:
- printenv PATH
- /usr/bin/which ruby
- ruby --version
- /usr/bin/which bundle
- bundle --version
- /usr/bin/which rake
- rake --version
- echo ls_ruby_bindir; ls "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin"
# the test itself
# path-quoting is different here due to YAML constraints
# @@@ todo: setting the --seed here is an ugly temporary hack, to remain only until test-suite glitches are fixed.
script:
- /System/Library/Frameworks/Ruby.framework/Versions/"${CASK_RUBY_TEST_VERSION}"/usr/bin/bundle exec "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin/rake" test TESTOPTS="--seed=14827"
# notifications:
# irc:
# channels:
# - "chat.freenode.net#homebrew-cask"
# template:
# - "%{build_number}: %{branch}@%{commit} %{author} -> %{message} %{build_url}"
# use_notice: true
# skip_join: true
# email: false

8
Gemfile

@ -0,0 +1,8 @@
source 'https://rubygems.org'
group :test do
gem 'rake'
gem 'minitest', '5.3'
gem 'minitest-colorize'
gem 'mocha', '0.14.0', :require => false
end

19
Gemfile.lock

@ -0,0 +1,19 @@
GEM
remote: https://rubygems.org/
specs:
metaclass (0.0.4)
minitest (5.3.0)
minitest-colorize (0.0.5)
minitest (>= 2.0)
mocha (0.14.0)
metaclass (~> 0.0.1)
rake (10.3.2)
PLATFORMS
ruby
DEPENDENCIES
minitest (= 5.3)
minitest-colorize
mocha (= 0.14.0)
rake

8
Rakefile

@ -0,0 +1,8 @@
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "test/**/*_test.rb"
t.libs << 'test'
end
task :default => :test

14
test/Casks/compliance_test.rb

@ -0,0 +1,14 @@
require 'test_helper'
describe "Casks" do
Cask.all.reject {|c| c.is_a?(TestCask) }.each do |cask|
describe "#{cask}" do
it "passes audit" do
audit = Cask::Audit.new(cask)
audit.run!
audit.errors.must_equal [], "[#{cask}] Cask audit must be error free"
audit.warnings.must_equal [], "[#{cask}] Cask audit must be warning free"
end
end
end
end

38
test/test_helper.rb

@ -0,0 +1,38 @@
require 'bundler'
require 'bundler/setup'
homebrew_path = Pathname(`brew --prefix`.chomp)
homebrew_path = Pathname('/usr/local') unless homebrew_path.exist?
# add cask lib to load path
brew_cask_path = homebrew_path.join('Library', 'Taps', 'caskroom', 'homebrew-cask')
lib_path = brew_cask_path.join('lib')
$:.push(lib_path)
# add homebrew to load path
$:.push(homebrew_path.join('Library', 'Homebrew'))
# require homebrew testing env
require 'test/testing_env'
# must be called after testing_env so at_exit hooks are in proper order
require 'minitest/autorun'
# todo, re-enable minitest-colorize, broken under current test environment for unknown reasons
# require 'minitest-colorize'
# our baby
require 'cask'
# pretend like we installed the cask tap
project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../"))
taps_dest = HOMEBREW_LIBRARY/"Taps/caskroom"
# create directories
FileUtils.mkdir_p taps_dest
HOMEBREW_PREFIX.join('bin').mkdir
FileUtils.ln_s project_root, taps_dest/"homebrew-cask"
# Common superclass for tests casks for when we need to filter them out
class TestCask < Cask; end
Loading…
Cancel
Save