From 3b416ce7b530f2d94864329eb79b7f81c8ccb6ca Mon Sep 17 00:00:00 2001 From: phinze Date: Sun, 7 Apr 2013 14:28:42 -0500 Subject: [PATCH] add audits into the build process this way travis will be able to cover incoming pull requests of new casks by running the audit on them. cool! also: - add checksums to audit - fix missing checksums --- Casks/ireadfast.rb | 1 + Casks/makemkv.rb | 1 + Casks/mu-commander.rb | 1 + Casks/scrup.rb | 5 +++-- Casks/zooom.rb | 1 + lib/cask/audit.rb | 6 ++++++ test/Casks/compliance_test.rb | 14 ++++++++++++++ test/cask/dsl_test.rb | 2 +- test/support/Casks/bad-checksum.rb | 2 +- test/support/Casks/{test-cask.rb => basic-cask.rb} | 2 +- test/support/Casks/local-caffeine.rb | 2 +- test/support/Casks/local-transmission.rb | 2 +- test/support/Casks/missing-checksum.rb | 2 +- test/support/Casks/no-checksum.rb | 2 +- test/test_helper.rb | 5 ++++- 15 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 test/Casks/compliance_test.rb rename test/support/Casks/{test-cask.rb => basic-cask.rb} (84%) diff --git a/Casks/ireadfast.rb b/Casks/ireadfast.rb index 3d06be87c..bc2086239 100644 --- a/Casks/ireadfast.rb +++ b/Casks/ireadfast.rb @@ -2,4 +2,5 @@ class Ireadfast < Cask url 'http://s5.histats.com/stats/r.php?130163&100&1&urlr=&gengis.110mb.com/downloads/iReadFast%202.0.dmg' homepage 'http://gengis.110mb.com/en/index.php' version '2.0' + sha1 '57a5963ae3c6bd02aaf29b60987df2f1b76c956c' end diff --git a/Casks/makemkv.rb b/Casks/makemkv.rb index f5ea2f95b..58e2636c4 100644 --- a/Casks/makemkv.rb +++ b/Casks/makemkv.rb @@ -2,4 +2,5 @@ class Makemkv < Cask url 'http://www.makemkv.com/download/makemkv_v1.7.8_osx.dmg' homepage 'http://www.makemkv.com/' version '1.7.8' + sha1 '33b486d4ae7a6e93dd75fa25411d365bb46b9387' end diff --git a/Casks/mu-commander.rb b/Casks/mu-commander.rb index 0c3a798f6..53125e7ca 100644 --- a/Casks/mu-commander.rb +++ b/Casks/mu-commander.rb @@ -2,4 +2,5 @@ class MuCommander < Cask url 'http://www.mucommander.com/download/mucommander-0_9_0.dmg' version '0.9.0' homepage 'http://www.mucommander.com/index.php' + sha1 'f733f5a4dc380836def21ca76656c2053153c960' end diff --git a/Casks/scrup.rb b/Casks/scrup.rb index 17b26002b..fbe81fd3d 100644 --- a/Casks/scrup.rb +++ b/Casks/scrup.rb @@ -1,5 +1,6 @@ class Scrup < Cask - url 'http://hunch.se/scrup/dist/scrup-1.3.2.zip' + url 'http://data.hunch.se/scrup/Scrup-1.3.3-bd23160.zip' homepage 'https://github.com/rsms/scrup' - version '1.3.2' + version '1.3.3' + sha1 '51ea66d5049fb231d28d285be8ccd5f75b467b97' end diff --git a/Casks/zooom.rb b/Casks/zooom.rb index c5401aef0..2316218ac 100644 --- a/Casks/zooom.rb +++ b/Casks/zooom.rb @@ -2,4 +2,5 @@ class Zooom < Cask url 'http://software.coderage-software.com/zooom/Zooom_2.5.0.dmg' homepage 'http://http://coderage-software.com/zooom' version '2.5.0' + sha1 '1fa66ef73e7005b368bc4c21e37ae676ed7bc1f5' end diff --git a/lib/cask/audit.rb b/lib/cask/audit.rb index 467ffc318..f732d4775 100644 --- a/lib/cask/audit.rb +++ b/lib/cask/audit.rb @@ -11,6 +11,7 @@ class Cask::Audit def run! _check_required_fields + _check_checksums return if errors? end @@ -23,4 +24,9 @@ class Cask::Audit add_error "version is required" unless cask.version add_error "homepage is required" unless cask.homepage end + + def _check_checksums + return if cask.sums == 0 + add_error "could not find checksum or no_checksum" unless cask.sums.is_a?(Array) && cask.sums.length > 0 + end end diff --git a/test/Casks/compliance_test.rb b/test/Casks/compliance_test.rb new file mode 100644 index 000000000..946ef2469 --- /dev/null +++ b/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 diff --git a/test/cask/dsl_test.rb b/test/cask/dsl_test.rb index 1b93ad425..2520d5be9 100644 --- a/test/cask/dsl_test.rb +++ b/test/cask/dsl_test.rb @@ -2,7 +2,7 @@ require 'test_helper' describe Cask::DSL do it "lets you set url, homepage, and version" do - test_cask = Cask.load('test-cask') + test_cask = Cask.load('basic-cask') test_cask.url.must_equal URI('http://example.com/TestCask.dmg') test_cask.homepage.must_equal 'http://example.com/' test_cask.version.must_equal '1.2.3' diff --git a/test/support/Casks/bad-checksum.rb b/test/support/Casks/bad-checksum.rb index 2f6edda14..68f37a831 100644 --- a/test/support/Casks/bad-checksum.rb +++ b/test/support/Casks/bad-checksum.rb @@ -1,4 +1,4 @@ -class BadChecksum < Cask +class BadChecksum < TestCask url TestHelper.local_binary('caffeine.zip') homepage 'http://example.com/local-caffeine' version '1.2.3' diff --git a/test/support/Casks/test-cask.rb b/test/support/Casks/basic-cask.rb similarity index 84% rename from test/support/Casks/test-cask.rb rename to test/support/Casks/basic-cask.rb index 0d307d46e..7210a61d5 100644 --- a/test/support/Casks/test-cask.rb +++ b/test/support/Casks/basic-cask.rb @@ -1,4 +1,4 @@ -class TestCask < Cask +class BasicCask < TestCask url 'http://example.com/TestCask.dmg' homepage 'http://example.com/' version '1.2.3' diff --git a/test/support/Casks/local-caffeine.rb b/test/support/Casks/local-caffeine.rb index 45921ca81..9219bb2da 100644 --- a/test/support/Casks/local-caffeine.rb +++ b/test/support/Casks/local-caffeine.rb @@ -1,4 +1,4 @@ -class LocalCaffeine < Cask +class LocalCaffeine < TestCask url TestHelper.local_binary('caffeine.zip') homepage 'http://example.com/local-caffeine' version '1.2.3' diff --git a/test/support/Casks/local-transmission.rb b/test/support/Casks/local-transmission.rb index b777171d8..581c6814d 100644 --- a/test/support/Casks/local-transmission.rb +++ b/test/support/Casks/local-transmission.rb @@ -1,4 +1,4 @@ -class LocalTransmission < Cask +class LocalTransmission < TestCask url TestHelper.local_binary('transmission-2.61.dmg') homepage 'http://example.com/local-transmission' version '2.61' diff --git a/test/support/Casks/missing-checksum.rb b/test/support/Casks/missing-checksum.rb index 5e16d4876..f8f015045 100644 --- a/test/support/Casks/missing-checksum.rb +++ b/test/support/Casks/missing-checksum.rb @@ -1,4 +1,4 @@ -class MissingChecksum < Cask +class MissingChecksum < TestCask url TestHelper.local_binary('caffeine.zip') homepage 'http://example.com/local-caffeine' version '1.2.3' diff --git a/test/support/Casks/no-checksum.rb b/test/support/Casks/no-checksum.rb index f169ae7ef..9b931df84 100644 --- a/test/support/Casks/no-checksum.rb +++ b/test/support/Casks/no-checksum.rb @@ -1,4 +1,4 @@ -class NoChecksum < Cask +class NoChecksum < TestCask url TestHelper.local_binary('caffeine.zip') homepage 'http://example.com/local-caffeine' version '1.2.3' diff --git a/test/test_helper.rb b/test/test_helper.rb index 4dbfbc145..3e7c32ec0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -36,7 +36,7 @@ class TestHelper end def self.test_cask - Cask.load('test-cask') + Cask.load('basic-cask') end def self.fake_fetcher @@ -67,5 +67,8 @@ taps_dest.mkdir FileUtils.ln_s project_root, taps_dest/"phinze-cask" +# Common superclass for tests casks for when we need to filter them out +class TestCask < Cask; end + # also jack in some test casks FileUtils.ln_s project_root/'test'/'support', taps_dest/"phinze-testcasks"