Allow classifier to run on symlinks as usual (#3948)

* Fixups for symlink detection, incl. test

* assert the heuristics return none for symlink
This commit is contained in:
Ashe Connor
2018-01-08 09:01:16 +11:00
committed by GitHub
parent a840668599
commit 5fbe9c0902
5 changed files with 15 additions and 5 deletions

View File

@@ -13,8 +13,9 @@ class TestHeuristics < Minitest::Test
end
def all_fixtures(language_name, file="*")
Dir.glob("#{samples_path}/#{language_name}/#{file}") -
["#{samples_path}/#{language_name}/filenames"]
fixs = Dir.glob("#{samples_path}/#{language_name}/#{file}") -
["#{samples_path}/#{language_name}/filenames"]
fixs.reject { |f| File.symlink?(f) }
end
def test_no_match
@@ -23,6 +24,10 @@ class TestHeuristics < Minitest::Test
assert_equal [], results
end
def test_symlink_empty
assert_equal [], Heuristics.call(file_blob("Markdown/symlink.md"), [Language["Markdown"]])
end
def assert_heuristics(hash)
candidates = hash.keys.map { |l| Language[l] }