mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Language detection test for non-sample files
This commit is contained in:
22
test-files/Python/run_tests.module
Normal file
22
test-files/Python/run_tests.module
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import sys, os
|
||||||
|
|
||||||
|
# Set the current working directory to the directory where this script is located
|
||||||
|
os.chdir(os.path.abspath(os.path.dirname(sys.argv[0])))
|
||||||
|
|
||||||
|
#### Set the name of the application here and moose directory relative to the application
|
||||||
|
app_name = 'stork'
|
||||||
|
|
||||||
|
MODULE_DIR = os.path.abspath('..')
|
||||||
|
MOOSE_DIR = os.path.abspath(os.path.join(MODULE_DIR, '..'))
|
||||||
|
#### See if MOOSE_DIR is already in the environment instead
|
||||||
|
if os.environ.has_key("MOOSE_DIR"):
|
||||||
|
MOOSE_DIR = os.environ['MOOSE_DIR']
|
||||||
|
|
||||||
|
sys.path.append(os.path.join(MOOSE_DIR, 'python'))
|
||||||
|
import path_tool
|
||||||
|
path_tool.activate_module('TestHarness')
|
||||||
|
|
||||||
|
from TestHarness import TestHarness
|
||||||
|
# Run the tests!
|
||||||
|
TestHarness.buildAndRun(sys.argv, app_name, MOOSE_DIR)
|
||||||
1505
test-files/Shell/mintleaf.module
Normal file
1505
test-files/Shell/mintleaf.module
Normal file
File diff suppressed because it is too large
Load Diff
@@ -407,6 +407,25 @@ class TestBlob < Test::Unit::TestCase
|
|||||||
assert blob.language, "No language for #{sample[:path]}"
|
assert blob.language, "No language for #{sample[:path]}"
|
||||||
assert_equal sample[:language], blob.language.name, blob.name
|
assert_equal sample[:language], blob.language.name, blob.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Test language detection for files which shouldn't be used as samples
|
||||||
|
root = File.expand_path('../../test-files', __FILE__)
|
||||||
|
Dir.entries(root).each do |language|
|
||||||
|
next if language == '.' || language == '..'
|
||||||
|
|
||||||
|
# Each directory contains test files of a language
|
||||||
|
dirname = File.join(root, language)
|
||||||
|
Dir.entries(dirname).each do |filename|
|
||||||
|
next if filename == '.' || filename == '..'
|
||||||
|
|
||||||
|
# By default blob search the file in the samples;
|
||||||
|
# thus, we need to give it the absolute path
|
||||||
|
filepath = File.join(dirname, filename)
|
||||||
|
blob = blob(filepath)
|
||||||
|
assert blob.language, "No language for #{filepath}"
|
||||||
|
assert_equal language, blob.language.name, blob.name
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lexer
|
def test_lexer
|
||||||
|
|||||||
Reference in New Issue
Block a user