mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
Test that interpreters are defined in languages.yml
This commit is contained in:
@@ -37,21 +37,26 @@ class TestSamples < Test::Unit::TestCase
|
|||||||
assert !data["interpreters"].empty?
|
assert !data["interpreters"].empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check that there aren't samples with extensions that aren't explicitly defined in languages.yml
|
# Check that there aren't samples with extensions or interpreters that
|
||||||
def test_parity
|
# aren't explicitly defined in languages.yml
|
||||||
extensions = Samples.cache['extnames']
|
languages_yml = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
|
||||||
languages_yml = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
|
YAML.load_file(languages_yml).each do |name, options|
|
||||||
languages = YAML.load_file(languages_yml)
|
define_method "test_samples_have_parity_with_languages_yml_for_#{name}" do
|
||||||
|
|
||||||
languages.each do |name, options|
|
|
||||||
options['extensions'] ||= []
|
options['extensions'] ||= []
|
||||||
|
if extnames = Samples.cache['extnames'][name]
|
||||||
if extnames = extensions[name]
|
|
||||||
extnames.each do |extname|
|
extnames.each do |extname|
|
||||||
next if extname == '.script!'
|
next if extname == '.script!'
|
||||||
assert options['extensions'].include?(extname), "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml"
|
assert options['extensions'].include?(extname), "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
options['interpreters'] ||= []
|
||||||
|
if interpreters = Samples.cache['interpreters'][name]
|
||||||
|
interpreters.each do |interpreter|
|
||||||
|
# next if extname == '.script!'
|
||||||
|
assert options['interpreters'].include?(interpreter), "#{name} has a sample with an interpreter (#{interpreter}) that isn't explicitly defined in languages.yml"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user