mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge branch 'master' into 1285-local
Conflicts: lib/linguist/language.rb lib/linguist/samples.json
This commit is contained in:
@@ -140,6 +140,13 @@ class TestBlob < Test::Unit::TestCase
|
||||
assert !blob("Perl/script.pl").binary?
|
||||
end
|
||||
|
||||
def test_all_binary
|
||||
Samples.each do |sample|
|
||||
blob = blob(sample[:path])
|
||||
assert ! (blob.likely_binary? || blob.binary?), "#{sample[:path]} is a binary file"
|
||||
end
|
||||
end
|
||||
|
||||
def test_text
|
||||
assert blob("Text/README").text?
|
||||
assert blob("Text/dump.sql").text?
|
||||
@@ -247,6 +254,13 @@ class TestBlob < Test::Unit::TestCase
|
||||
# Generated VCR
|
||||
assert blob("YAML/vcr_cassette.yml").generated?
|
||||
|
||||
# Generated by Zephir
|
||||
assert blob("Zephir/filenames/exception.zep.c").generated?
|
||||
assert blob("Zephir/filenames/exception.zep.h").generated?
|
||||
assert blob("Zephir/filenames/exception.zep.php").generated?
|
||||
assert !blob("Zephir/Router.zep").generated?
|
||||
|
||||
|
||||
assert Linguist::Generated.generated?("node_modules/grunt/lib/grunt.js", nil)
|
||||
end
|
||||
|
||||
@@ -271,6 +285,10 @@ class TestBlob < Test::Unit::TestCase
|
||||
# 'thirdparty' directory
|
||||
assert blob("thirdparty/lib/main.c").vendored?
|
||||
|
||||
# 'extern(al)' directory
|
||||
assert blob("extern/util/__init__.py").vendored?
|
||||
assert blob("external/jquery.min.js").vendored?
|
||||
|
||||
# C deps
|
||||
assert blob("deps/http_parser/http_parser.c").vendored?
|
||||
assert blob("deps/v8/src/v8.h").vendored?
|
||||
@@ -375,6 +393,12 @@ class TestBlob < Test::Unit::TestCase
|
||||
# NuGet Packages
|
||||
assert blob("packages/Modernizr.2.0.6/Content/Scripts/modernizr-2.0.6-development-only.js").vendored?
|
||||
|
||||
# Normalize
|
||||
assert blob("some/asset/path/normalize.css").vendored?
|
||||
|
||||
# Cocoapods
|
||||
assert blob('Pods/blah').vendored?
|
||||
|
||||
# Html5shiv
|
||||
assert blob("Scripts/html5shiv.js").vendored?
|
||||
assert blob("Scripts/html5shiv.min.js").vendored?
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
require 'linguist/heuristics'
|
||||
require 'linguist/language'
|
||||
require 'linguist/samples'
|
||||
require 'linguist/file_blob'
|
||||
|
||||
require 'test/unit'
|
||||
|
||||
@@ -35,7 +36,8 @@ class TestHeuristcs < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_detect_still_works_if_nothing_matches
|
||||
match = Language.detect("Hello.m", fixture("Objective-C/hello.m"))
|
||||
blob = Linguist::FileBlob.new(File.join(samples_path, "Objective-C/hello.m"))
|
||||
match = Language.detect(blob)
|
||||
assert_equal Language["Objective-C"], match
|
||||
end
|
||||
|
||||
|
||||
@@ -3,22 +3,24 @@ require 'linguist/repository'
|
||||
require 'test/unit'
|
||||
|
||||
class TestRepository < Test::Unit::TestCase
|
||||
include Linguist
|
||||
|
||||
def repo(base_path)
|
||||
Repository.from_directory(base_path)
|
||||
def rugged_repository
|
||||
@rugged ||= Rugged::Repository.new(File.expand_path("../../.git", __FILE__))
|
||||
end
|
||||
|
||||
def linguist_repo
|
||||
repo(File.expand_path("../..", __FILE__))
|
||||
def master_oid
|
||||
'd40b4a33deba710e2f494db357c654fbe5d4b419'
|
||||
end
|
||||
|
||||
def linguist_repo(oid = master_oid)
|
||||
Linguist::Repository.new(rugged_repository, oid)
|
||||
end
|
||||
|
||||
def test_linguist_language
|
||||
# assert_equal Language['Ruby'], linguist_repo.language
|
||||
assert_equal 'Ruby', linguist_repo.language
|
||||
end
|
||||
|
||||
def test_linguist_languages
|
||||
# assert linguist_repo.languages[Language['Ruby']] > 10_000
|
||||
assert linguist_repo.languages['Ruby'] > 10_000
|
||||
end
|
||||
|
||||
def test_linguist_size
|
||||
@@ -31,7 +33,18 @@ class TestRepository < Test::Unit::TestCase
|
||||
assert linguist_repo.breakdown_by_file["Ruby"].include?("lib/linguist/language.rb")
|
||||
end
|
||||
|
||||
def test_binary_override
|
||||
assert_equal repo(File.expand_path("../../samples/Nimrod", __FILE__)).language, Language["Nimrod"]
|
||||
def test_incremental_stats
|
||||
old_commit = '3d7364877d6794f6cc2a86b493e893968a597332'
|
||||
old_repo = linguist_repo(old_commit)
|
||||
|
||||
assert old_repo.languages['Ruby'] > 10_000
|
||||
assert old_repo.size > 30_000
|
||||
|
||||
new_repo = Linguist::Repository.incremental(rugged_repository, master_oid, old_commit, old_repo.cache)
|
||||
|
||||
assert new_repo.languages['Ruby'] > old_repo.languages['Ruby']
|
||||
assert new_repo.size > old_repo.size
|
||||
|
||||
assert_equal linguist_repo.cache, new_repo.cache
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user