forked from Homebrew/homebrew-cask
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for expected layout of files in repo
References: Homebrew#4914
- Loading branch information
1 parent
8b75032
commit ad49894
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
require 'test_helper' | ||
|
||
describe "Repo layout" do | ||
project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../")) | ||
|
||
# todo: a more clever way to do this would be to dispense with | ||
# the imperfect IGNORE lists and read the actual repo | ||
# contents by running "git ls-files | ||
|
||
# dot dirs are always a project of Dir.entries | ||
# other files are items that the developer hopefully has gitignored | ||
IGNORE_FILES = %w{ | ||
. | ||
.. | ||
.DS_Store | ||
} | ||
|
||
# the developer has hopefully gitignored these | ||
IGNORE_REGEXPS = [ | ||
%r{~$}, # emacs | ||
] | ||
|
||
TOPLEVEL_DIRS = %w{ | ||
.git | ||
Casks | ||
bin | ||
developer | ||
doc | ||
lib | ||
test | ||
} | ||
|
||
TOPLEVEL_FILES = %w{ | ||
.gitignore | ||
.travis.yml | ||
CONDUCT.md | ||
CONTRIBUTING.md | ||
Gemfile | ||
Gemfile.lock | ||
LICENSE | ||
README.md | ||
Rakefile | ||
USAGE.md | ||
brew-cask.rb | ||
} | ||
|
||
describe "toplevel dir" do | ||
it "finds some files at the top level" do | ||
entries = Dir.entries(project_root) | ||
entries.length.must_be :>, 0 | ||
end | ||
|
||
it "only finds expected files at the top level" do | ||
entries = Dir.entries(project_root) - IGNORE_FILES - TOPLEVEL_DIRS - TOPLEVEL_FILES | ||
IGNORE_REGEXPS.each do |regexp| | ||
entries.reject! { |elt| elt.match(regexp) } | ||
end | ||
entries.length.must_be :==, 0 | ||
end | ||
end | ||
|
||
describe "Casks dir" do | ||
it "finds some files in the Casks dir" do | ||
entries = Dir.entries(project_root.join('Casks')) | ||
entries.length.must_be :>, 0 | ||
end | ||
|
||
it "only finds .rb files in the Casks dir" do | ||
entries = Dir.entries(project_root.join('Casks')) - IGNORE_FILES | ||
IGNORE_REGEXPS.each do |regexp| | ||
entries.reject! { |elt| elt.match(regexp) } | ||
end | ||
entries.reject! { |elt| elt.match(%r{\.rb$}) } | ||
entries.length.must_be :==, 0 | ||
end | ||
end | ||
end |