[DRE-commits] [ruby-simplecov] 04/05: Fix test failure due to encoding test

Christian Hofstaedtler zeha at moszumanska.debian.org
Mon Dec 23 23:14:31 UTC 2013


This is an automated email from the git hooks/post-receive script.

zeha pushed a commit to branch master
in repository ruby-simplecov.

commit 4756e1754f8ce1d7a77eb28da06914c783513114
Author: Christian Hofstaedtler <zeha at debian.org>
Date:   Tue Dec 24 00:04:23 2013 +0100

    Fix test failure due to encoding test
---
 debian/patches/open-source-files-in-binary-mode | 40 +++++++++++++++++++++++++
 debian/patches/series                           |  1 +
 2 files changed, 41 insertions(+)

diff --git a/debian/patches/open-source-files-in-binary-mode b/debian/patches/open-source-files-in-binary-mode
new file mode 100644
index 0000000..a3a2899
--- /dev/null
+++ b/debian/patches/open-source-files-in-binary-mode
@@ -0,0 +1,40 @@
+From 6abb79e6b3eeed02997cb356cf73647e97be0edc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?C=C3=A9dric=20F=C3=A9lizard?= <cedric at felizard.fr>
+Date: Tue, 12 Feb 2013 17:19:43 +0100
+Subject: [PATCH] Open source files in binary mode
+
+Opening non-UTF-8 files as UTF-8 succeeds in some cases and will throw
+<ArgumentError: invalid byte sequence in UTF-8> when comparing against a
+regexp. Forcing Ruby to use binary mode will keep strings as ASCII-8BIT
+and seems to work on all current versions of Ruby.
+
+Moreover, there is no way to know for sure which encoding is used
+without heuristics or parsing the potential encoding shebang thus binary
+mode is probably safer.
+
+[zeha at debian.org: Backport to simplecov 0.7]
+---
+ lib/simplecov/source_file.rb | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+Index: ruby-simplecov/lib/simplecov/source_file.rb
+===================================================================
+--- ruby-simplecov.orig/lib/simplecov/source_file.rb	2013-12-24 00:02:51.164975612 +0100
++++ ruby-simplecov/lib/simplecov/source_file.rb	2013-12-24 00:03:11.192909910 +0100
+@@ -30,7 +30,6 @@ module SimpleCov
+         raise ArgumentError, "Only Fixnum and nil accepted for coverage" unless coverage.kind_of?(Fixnum) or coverage.nil?
+         @src, @line_number, @coverage = src, line_number, coverage
+         @skipped = false
+-        @src.encode!('UTF-8', 'UTF-8', :invalid => :replace) if @src.respond_to?(:encode!)
+       end
+ 
+       # Returns true if this is a line that should have been covered, but was not
+@@ -79,7 +78,7 @@ module SimpleCov
+ 
+     def initialize(filename, coverage)
+       @filename, @coverage = filename, coverage
+-      File.open(filename, "r:UTF-8") {|f| @src = f.readlines }
++      File.open(filename, "rb") {|f| @src = f.readlines }
+     end
+ 
+     # Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
diff --git a/debian/patches/series b/debian/patches/series
index 94a931a..4d5e552 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 remove-rubygems-bundler.patch
 ignore-simplecov-html
+open-source-files-in-binary-mode

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-simplecov.git



More information about the Pkg-ruby-extras-commits mailing list