mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 20:38:47 +00:00
Merge remote-tracking branch 'origin/master' into interpreters-in-samples
* origin/master: (30 commits) Add byebug Link to Lightshow in CONTRIBUTING.md Switch to a better F# grammar Bump Rugged again Checkout the master for testing Rugged 0.22.0b3 Reordering Bump version to 4.0.3 Add some docs for tm_scope Change NONE to none Checking other case for Chart.jS Test that all languages have grammars Fix RHTML's tm_scope Chart JS is vendored Switch to a better grammar for Bro reorder again… put cjsx at the top Use a SQF grammar for SQF files move cjsx before iced move cjsx before iced ... Conflicts: lib/linguist/languages.yml
This commit is contained in:
4
test/helper.rb
Normal file
4
test/helper.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require "bundler/setup"
|
||||
require "test/unit"
|
||||
require "mocha/setup"
|
||||
require "linguist"
|
||||
@@ -1,9 +1,4 @@
|
||||
require 'linguist/file_blob'
|
||||
require 'linguist/samples'
|
||||
|
||||
require 'test/unit'
|
||||
require 'mocha/setup'
|
||||
require 'mime/types'
|
||||
require_relative "./helper"
|
||||
|
||||
class TestBlob < Test::Unit::TestCase
|
||||
include Linguist
|
||||
@@ -297,6 +292,10 @@ class TestBlob < Test::Unit::TestCase
|
||||
assert blob("deps/http_parser/http_parser.c").vendored?
|
||||
assert blob("deps/v8/src/v8.h").vendored?
|
||||
|
||||
# Chart.js
|
||||
assert blob("some/vendored/path/Chart.js").vendored?
|
||||
assert !blob("some/vendored/path/chart.js").vendored?
|
||||
|
||||
# Codemirror deps
|
||||
assert blob("codemirror/mode/blah.js").vendored?
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
require 'linguist/classifier'
|
||||
require 'linguist/language'
|
||||
require 'linguist/samples'
|
||||
require 'linguist/tokenizer'
|
||||
|
||||
require 'test/unit'
|
||||
require_relative "./helper"
|
||||
|
||||
class TestClassifier < Test::Unit::TestCase
|
||||
include Linguist
|
||||
|
||||
10
test/test_file_blob.rb
Normal file
10
test/test_file_blob.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'linguist/file_blob'
|
||||
require 'test/unit'
|
||||
|
||||
class TestFileBlob < Test::Unit::TestCase
|
||||
def test_extensions
|
||||
assert_equal [".gitignore"], Linguist::FileBlob.new(".gitignore").extensions
|
||||
assert_equal [".xml"], Linguist::FileBlob.new("build.xml").extensions
|
||||
assert_equal [".html.erb", ".erb"], Linguist::FileBlob.new("dotted.dir/index.html.erb").extensions
|
||||
end
|
||||
end
|
||||
@@ -1,9 +1,4 @@
|
||||
require 'linguist/heuristics'
|
||||
require 'linguist/language'
|
||||
require 'linguist/samples'
|
||||
require 'linguist/file_blob'
|
||||
|
||||
require 'test/unit'
|
||||
require_relative "./helper"
|
||||
|
||||
class TestHeuristcs < Test::Unit::TestCase
|
||||
include Linguist
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
require 'linguist/language'
|
||||
require 'test/unit'
|
||||
require_relative "./helper"
|
||||
|
||||
class TestLanguage < Test::Unit::TestCase
|
||||
include Linguist
|
||||
@@ -222,6 +221,7 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal [Language['Clojure']], Language.find_by_filename('riemann.config')
|
||||
assert_equal [Language['HTML+Django']], Language.find_by_filename('index.jinja')
|
||||
assert_equal [Language['Chapel']], Language.find_by_filename('examples/hello.chpl')
|
||||
assert_equal [Language['Ant Build System']], Language.find_by_filename('build.ant.xml')
|
||||
end
|
||||
|
||||
def test_find_by_shebang
|
||||
@@ -359,4 +359,15 @@ class TestLanguage < Test::Unit::TestCase
|
||||
def test_by_type
|
||||
assert !Language.by_type(:prose).nil?
|
||||
end
|
||||
|
||||
def test_all_languages_have_grammars
|
||||
scopes = YAML.load(File.read(File.expand_path("../../grammars.yml", __FILE__))).values.flatten
|
||||
missing = Language.all.reject { |language| language.tm_scope == "none" || scopes.include?(language.tm_scope) }
|
||||
message = "The following languages' scopes are not listed in grammars.yml. Please add grammars for all new languages.\n"
|
||||
message << "If no grammar exists for a language, mark the language with `tm_scope: none` in lib/linguist/languages.yml.\n"
|
||||
|
||||
width = missing.map { |language| language.name.length }.max
|
||||
message << missing.map { |language| sprintf("%-#{width}s %s", language.name, language.tm_scope) }.sort.join("\n")
|
||||
assert missing.empty?, message
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
require 'linguist/md5'
|
||||
|
||||
require 'test/unit'
|
||||
require_relative "./helper"
|
||||
|
||||
class TestMD5 < Test::Unit::TestCase
|
||||
include Linguist
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
require 'test/unit'
|
||||
require 'yaml'
|
||||
require_relative "./helper"
|
||||
|
||||
class TestPedantic < Test::Unit::TestCase
|
||||
filename = File.expand_path("../../lib/linguist/languages.yml", __FILE__)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
require 'linguist/repository'
|
||||
require 'linguist/lazy_blob'
|
||||
require 'test/unit'
|
||||
require_relative "./helper"
|
||||
|
||||
class TestRepository < Test::Unit::TestCase
|
||||
def rugged_repository
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
require 'linguist/samples'
|
||||
require 'linguist/language'
|
||||
require 'tempfile'
|
||||
require 'yajl'
|
||||
require 'test/unit'
|
||||
require_relative "./helper"
|
||||
require "tempfile"
|
||||
|
||||
class TestSamples < Test::Unit::TestCase
|
||||
include Linguist
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
require 'linguist/tokenizer'
|
||||
|
||||
require 'test/unit'
|
||||
require_relative "./helper"
|
||||
|
||||
class TestTokenizer < Test::Unit::TestCase
|
||||
include Linguist
|
||||
|
||||
Reference in New Issue
Block a user