Merge remote-tracking branch 'origin/master' into test-helper

* origin/master:
  Add Gemfile.lock sample
  Remove deprecated method
  #all_extensions already includes primary extension
  typo
  remove unused assertion
  Symlink ant.xml to build.xml
  Avoid shadowing variable name
  Update comment
  Make missing sample failure message similar
  Remove blank extensions property
  Fix sample tests
  Add Forth extensions .f and .for; add heuristics for Forth and FORTRAN.
  Add FORTRAN and Forth samples.
  Extensions aren't actually required
  Fix errors from pedantic test
  Make pedantic test actually pedantic
  Removing extensions when they should be filenames
  Adding sample pom.xml files
  Link to contributing docs
  require samples if filename matches multiple languages

Conflicts:
	test/test_pedantic.rb
This commit is contained in:
Brandon Keepers
2014-11-18 16:48:26 -05:00
21 changed files with 1318 additions and 115 deletions

View File

@@ -52,20 +52,28 @@ class TestSamples < Test::Unit::TestCase
end
# If a language extension isn't globally unique then make sure there are samples
def test_presence
Linguist::Language.all.each do |language|
language.all_extensions.each do |extension|
language_matches = Language.find_by_filename("foo#{extension}")
Linguist::Language.all.each do |language|
define_method "test_#{language.name}_has_samples" do
language.extensions.each do |extension|
language_matches = Language.find_by_extension(extension)
# If there is more than one language match for a given extension
# then check that there are examples for that language with the extension
# Check for samples if more than one language matches the given extension.
if language_matches.length > 1
language_matches.each do |language|
assert File.directory?("samples/#{language.name}"), "#{language.name} is missing a samples directory"
assert Dir.glob("samples/#{language.name}/*#{extension}").any?, "#{language.name} is missing samples for extension #{extension}"
language_matches.each do |match|
samples = "samples/#{match.name}/*#{extension}"
assert Dir.glob(samples).any?, "Missing samples in #{samples.inspect}. See https://github.com/github/linguist/blob/master/CONTRIBUTING.md"
end
end
end
language.filenames.each do |filename|
# Check for samples if more than one language matches the given filename
if Language.find_by_filename(filename).size > 1
sample = "samples/#{language.name}/filenames/#{filename}"
assert File.exists?(sample),
"Missing sample in #{sample.inspect}. See https://github.com/github/linguist/blob/master/CONTRIBUTING.md"
end
end
end
end
end