mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Skip pygments tests if pygmentize isn't available
This commit is contained in:
@@ -8,6 +8,16 @@ module Linguist
|
|||||||
@name_index = {}
|
@name_index = {}
|
||||||
@alias_index = {}
|
@alias_index = {}
|
||||||
|
|
||||||
|
# Internal: Test if system has Pygments
|
||||||
|
#
|
||||||
|
# Only used in tests to disable tests that require Pygments.
|
||||||
|
#
|
||||||
|
# Returns true if `pygmentize` in is PATH otherwise false.
|
||||||
|
def self.has_pygments?
|
||||||
|
`which #{Albino.bin}`
|
||||||
|
$?.success?
|
||||||
|
end
|
||||||
|
|
||||||
# Public: Get all Lexers
|
# Public: Get all Lexers
|
||||||
#
|
#
|
||||||
# Returns an Array of Lexers
|
# Returns an Array of Lexers
|
||||||
|
|||||||
@@ -289,6 +289,7 @@ class TestBlob < Test::Unit::TestCase
|
|||||||
assert_equal nil, blob("foo.rb").shebang_language
|
assert_equal nil, blob("foo.rb").shebang_language
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Lexer.has_pygments?
|
||||||
def test_colorize
|
def test_colorize
|
||||||
assert_equal <<-HTML, blob("foo.rb").colorize
|
assert_equal <<-HTML, blob("foo.rb").colorize
|
||||||
<div class="highlight"><pre><span class="k">module</span> <span class="nn">Foo</span>
|
<div class="highlight"><pre><span class="k">module</span> <span class="nn">Foo</span>
|
||||||
@@ -304,4 +305,5 @@ class TestBlob < Test::Unit::TestCase
|
|||||||
<span class="k">end</span>
|
<span class="k">end</span>
|
||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -337,6 +337,7 @@ class TestLanguage < Test::Unit::TestCase
|
|||||||
assert !Language['SQL'].searchable?
|
assert !Language['SQL'].searchable?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Lexer.has_pygments?
|
||||||
def test_colorize
|
def test_colorize
|
||||||
assert_equal <<-HTML, Language['Text'].colorize("Hello")
|
assert_equal <<-HTML, Language['Text'].colorize("Hello")
|
||||||
<div class="highlight"><pre>Hello
|
<div class="highlight"><pre>Hello
|
||||||
@@ -364,4 +365,5 @@ Hello
|
|||||||
<span class="k">end</span>
|
<span class="k">end</span>
|
||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class TestLexer < Test::Unit::TestCase
|
|||||||
assert !Lexer['Ruby'].eql?(Lexer.new('Ruby'))
|
assert !Lexer['Ruby'].eql?(Lexer.new('Ruby'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Lexer.has_pygments?
|
||||||
def test_colorize
|
def test_colorize
|
||||||
assert_equal <<-HTML, Lexer['Text only'].colorize("Hello")
|
assert_equal <<-HTML, Lexer['Text only'].colorize("Hello")
|
||||||
<div class="highlight"><pre>Hello
|
<div class="highlight"><pre>Hello
|
||||||
@@ -77,4 +78,5 @@ Hello
|
|||||||
<span class="k">end</span>
|
<span class="k">end</span>
|
||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user