aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorScott J. Goldman <scottjg@github.com>2012-08-31 22:47:19 -0700
committerScott J. Goldman <scottjg@github.com>2012-08-31 22:47:19 -0700
commite415a1351bf3e7eff0a33574400fa89c0941d9bf (patch)
tree19500b0f8c2a160436176fe23dacbe738a482628 /test
parent6ec907a915bf3d18d8f7debb58e9e859cb9de16c (diff)
When testing if a blob is indexable, check size first
Otherwise, charlock_holmes will allocate another large binary buffer for testing the encoding, which is a problem if the binary blob is many hundreds of MB large. It'll just fail and crash ruby.
Diffstat (limited to 'test')
-rw-r--r--test/test_blob.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/test_blob.rb b/test/test_blob.rb
index 0832b8f..17e9ef8 100644
--- a/test/test_blob.rb
+++ b/test/test_blob.rb
@@ -2,6 +2,7 @@ require 'linguist/file_blob'
require 'linguist/samples'
require 'test/unit'
+require 'mocha'
require 'mime/types'
require 'pygments'
@@ -261,6 +262,12 @@ class TestBlob < Test::Unit::TestCase
assert !blob("Text/dump.sql").indexable?
assert !blob("Binary/github.po").indexable?
assert !blob("Binary/linguist.gem").indexable?
+
+ # large binary blobs should fail on size check first, not call
+ # into charlock_holmes and alloc big buffers for testing encoding
+ b = blob("Binary/octocat.ai")
+ b.expects(:binary?).never
+ assert !b.indexable?
end
def test_language