summaryrefslogtreecommitdiff
path: root/test/scanners/coderay_suite.rb
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2009-04-20 21:14:35 +0000
committermurphy <murphy@rubychan.de>2009-04-20 21:14:35 +0000
commitd9d447e4d8c09943dc7832cdc921be7f2039471e (patch)
treef55b3838e28f678dba431738144f0e63baaf2804 /test/scanners/coderay_suite.rb
parent04e1ddf7e29af75c9b90da3153c77de6166d0ec7 (diff)
downloadcoderay-d9d447e4d8c09943dc7832cdc921be7f2039471e.tar.gz
Fixed some test suite problems.
* coderay_suite: UTF-8 output is compared as binary. * functional tests: cleaned up. * test/unit: prevent Ruby 1.9 warning about circular require.
Diffstat (limited to 'test/scanners/coderay_suite.rb')
-rw-r--r--test/scanners/coderay_suite.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb
index 6e6249b..5edf6be 100644
--- a/test/scanners/coderay_suite.rb
+++ b/test/scanners/coderay_suite.rb
@@ -297,9 +297,16 @@ module CodeRay
if File.exist?(expected_filename) && !(ENV['lang'] && ENV['new'] && name == ENV['new'])
expected = File.open(expected_filename, 'rb') { |f| break f.read }
+ if result.respond_to?(:bytesize) && result.bytesize != result.size
+ # for char, i in result.chars.with_index
+ # raise "result has non-ASCII-8BIT character in line #{result[0,i].count(?\n) + 1}" if char.bytesize != 1
+ # end
+ # UTF-8 encoded result; comparison needs to be done on binary level
+ result.force_encoding(:binary)
+ end
ok = expected == result
- actual_filename = expected_filename.sub('.expected.', '.actual.')
unless ok
+ actual_filename = expected_filename.sub('.expected.', '.actual.')
File.open(actual_filename, 'wb') { |f| f.write result }
diff = expected_filename.sub(/\.expected\..*/, '.debug.diff')
system "diff --unified=0 --text #{expected_filename} #{actual_filename} > #{diff}"