Adding test to check that languages.yml includes all extensions represented in samples folder

This commit is contained in:
Arfon Smith
2014-08-11 14:16:25 -07:00
parent 41c880afc7
commit 43923976c2
4 changed files with 30636 additions and 30457 deletions

View File

@@ -532,6 +532,7 @@ module Linguist
if extnames = extensions[name]
extnames.each do |extname|
if !options['extensions'].include?(extname)
warn "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml" unless extname == '.script!'
options['extensions'] << extname
end
end

View File

@@ -260,6 +260,7 @@ C:
extensions:
- .c
- .cats
- .h
- .w
C#:
@@ -288,6 +289,7 @@ C++:
- .cc
- .cxx
- .H
- .h
- .h++
- .hh
- .hpp
@@ -444,6 +446,7 @@ Coq:
type: programming
extensions:
- .coq
- .v
Cpp-ObjDump:
type: data
@@ -539,6 +542,7 @@ Dart:
Diff:
extensions:
- .diff
- .patch
Dogescript:
type: programming
@@ -623,6 +627,7 @@ Erlang:
color: "#0faf8d"
extensions:
- .erl
- .escript
- .hrl
F#:
@@ -698,6 +703,7 @@ Forth:
extensions:
- .fth
- .4th
- .forth
Frege:
type: programming
@@ -806,6 +812,9 @@ Gosu:
color: "#82937f"
extensions:
- .gs
- .gst
- .gsx
- .vark
Grace:
type: programming
@@ -841,6 +850,7 @@ Groovy:
color: "#e69f56"
extensions:
- .groovy
- .gradle
- .grt
- .gtpl
- .gvy
@@ -945,6 +955,7 @@ IDL:
color: "#e3592c"
extensions:
- .pro
- .dlm
INI:
type: data
@@ -1019,6 +1030,7 @@ JSON:
searchable: false
extensions:
- .json
- .lock
- .sublime-keymap
- .sublime-mousemap
- .sublime-project
@@ -1147,6 +1159,9 @@ Lasso:
color: "#2584c3"
extensions:
- .lasso
- .las
- .lasso9
- .ldml
Latte:
type: markup
@@ -1232,6 +1247,7 @@ Lua:
extensions:
- .lua
- .nse
- .pd_lua
- .rbxs
interpreters:
- lua
@@ -1377,6 +1393,7 @@ Myghty:
NSIS:
extensions:
- .nsi
- .nsh
Nemerle:
type: programming
@@ -1441,6 +1458,7 @@ OCaml:
color: "#3be133"
extensions:
- .ml
- .eliom
- .eliomi
- .ml4
- .mli
@@ -1461,6 +1479,7 @@ Objective-C:
- objc
extensions:
- .m
- .h
Objective-C++:
type: programming
@@ -1508,6 +1527,7 @@ OpenEdge ABL:
- abl
extensions:
- .p
- .cls
Org:
type: prose
@@ -1546,6 +1566,7 @@ PHP:
- .php
- .aw
- .ctp
- .module
- .php3
- .php4
- .php5
@@ -1594,6 +1615,7 @@ Pascal:
extensions:
- .pas
- .dfm
- .dpr
- .lpr
Perl:
@@ -1603,12 +1625,14 @@ Perl:
extensions:
- .pl
- .PL
- .fcgi
- .perl
- .ph
- .plx
- .pm
- .pod
- .psgi
- .t
interpreters:
- perl
@@ -1817,6 +1841,7 @@ Racket:
- .rkt
- .rktd
- .rktl
- .scrbl
Ragel in Ruby Host:
type: programming
@@ -1886,7 +1911,10 @@ Ruby:
- .god
- .irbrc
- .mspec
- .pluginspec
- .podspec
- .rabl
- .rake
- .rbuild
- .rbw
- .rbx
@@ -1960,6 +1988,7 @@ Sass:
group: CSS
extensions:
- .sass
- .scss
Scala:
type: programming
@@ -1967,6 +1996,7 @@ Scala:
color: "#7dd3b0"
extensions:
- .scala
- .sbt
- .sc
Scaml:
@@ -1982,6 +2012,7 @@ Scheme:
- .scm
- .sld
- .sls
- .sps
- .ss
interpreters:
- guile
@@ -1993,6 +2024,8 @@ Scilab:
type: programming
extensions:
- .sci
- .sce
- .tst
Self:
type: programming
@@ -2012,8 +2045,10 @@ Shell:
- zsh
extensions:
- .sh
- .bash
- .bats
- .tmux
- .zsh
interpreters:
- bash
- sh
@@ -2080,6 +2115,7 @@ Standard ML:
extensions:
- .ML
- .fun
- .sig
- .sml
Stata:
@@ -2280,6 +2316,7 @@ Visual Basic:
extensions:
- .vb
- .bas
- .cls
- .frm
- .frx
- .vba
@@ -2308,6 +2345,7 @@ XML:
- wsdl
extensions:
- .xml
- .ant
- .axml
- .ccxml
- .clixml
@@ -2321,6 +2359,7 @@ XML:
- .fsproj
- .glade
- .grxml
- .ivy
- .jelly
- .kml
- .launch

File diff suppressed because it is too large Load Diff

View File

@@ -35,15 +35,33 @@ class TestSamples < Test::Unit::TestCase
assert_equal data['tokens_total'], data['language_tokens'].inject(0) { |n, (_, c)| n += c }
assert_equal data['tokens_total'], data['tokens'].inject(0) { |n, (_, ts)| n += ts.inject(0) { |m, (_, c)| m += c } }
end
# Check that there aren't samples with extensions that aren't explicitly defined in languages.yml
def test_parity
extensions = Samples::DATA['extnames']
languages_yml = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
languages = YAML.load_file(languages_yml)
languages.each do |name, options|
options['extensions'] ||= []
if extnames = extensions[name]
extnames.each do |extname|
next if extname == '.script!'
assert options['extensions'].include?(extname), "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml"
end
end
end
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}")
# If there is more than one language match for a given extension
# then check that there are examples for that language with the extension
# then check that there are examples for that language with the extension
if language_matches.length > 1
language_matches.each do |language|
assert File.directory?("samples/#{language.name}"), "#{language.name} is missing a samples directory"