Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests fail in chroot with C/ASCII locale #102

Closed
pravi opened this issue Jun 1, 2016 · 6 comments
Closed

tests fail in chroot with C/ASCII locale #102

pravi opened this issue Jun 1, 2016 · 6 comments

Comments

@pravi
Copy link
Contributor

pravi commented Jun 1, 2016

tests fail in a clean chroot. I could fix this by forcing a different locale, but I thought of reporting it anyway.

/build/ruby-licensee-8.0.0/lib/licensee/license.rb:151:in `match': invalid byte sequence in US-ASCII (ArgumentError)
    from /build/ruby-licensee-8.0.0/lib/licensee/license.rb:151:in `match'
    from /build/ruby-licensee-8.0.0/lib/licensee/license.rb:151:in `parts'
    from /build/ruby-licensee-8.0.0/lib/licensee/license.rb:82:in `meta'
    from /build/ruby-licensee-8.0.0/lib/licensee/license.rb:113:in `hidden?'
    from /build/ruby-licensee-8.0.0/lib/licensee/license.rb:18:in `reject!'
    from /build/ruby-licensee-8.0.0/lib/licensee/license.rb:18:in `all'
    from /build/ruby-licensee-8.0.0/lib/licensee.rb:36:in `licenses'
    from /build/ruby-licensee-8.0.0/test/test_licensee_license.rb:127:in `block in <class:TestLicenseeLicense>'
    from /usr/lib/ruby/vendor_ruby/minitest/spec.rb:83:in `class_eval'
    from /usr/lib/ruby/vendor_ruby/minitest/spec.rb:83:in `describe'
    from /build/ruby-licensee-8.0.0/test/test_licensee_license.rb:113:in `<class:TestLicenseeLicense>'
    from /build/ruby-licensee-8.0.0/test/test_licensee_license.rb:3:in `<top (required)>'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb:15:in `block in <main>'
    from /usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb:4:in `select'
    from /usr/lib/ruby/vendor_ruby/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
@pravi
Copy link
Contributor Author

pravi commented Jun 1, 2016

its working after setting LC_ALL=C.UTF-8

@benbalter
Copy link
Contributor

@pravi Is there a change we can/should make within licensee to guard against this?

@pravi
Copy link
Contributor Author

pravi commented Jun 1, 2016

@benbalter I have manually set locale to UTF-8 in debian package build script. You could check the locale being used and see if you can force UTF-8.

@pravi
Copy link
Contributor Author

pravi commented Jun 1, 2016

I I make these changes, then tests succeed in chroot as well. Include it, if you think its worth including.

Index: ruby-licensee-8.0.0/lib/licensee/license.rb
===================================================================
--- ruby-licensee-8.0.0.orig/lib/licensee/license.rb
+++ ruby-licensee-8.0.0/lib/licensee/license.rb
@@ -148,7 +148,7 @@ module Licensee

     def parts
       return unless raw_content
-      @parts ||= raw_content.match(/\A(---\n.*\n---\n+)?(.*)/m).to_a
+      @parts ||= raw_content.force_encoding('utf-8').match(/\A(---\n.*\n---\n+)?(.*)/m).to_a
     end
   end
 end
--- ruby-licensee-8.0.0.orig/test/functions.rb
+++ ruby-licensee-8.0.0/test/functions.rb
@@ -12,7 +12,7 @@ def fixture_path(fixture)
 end

 def license_from_path(path)
-  license = File.open(path).read.match(/\A(---\n.*\n---\n+)?(.*)/m).to_a[2]
+  license = File.open(path).read.force_encoding('utf-8').match(/\A(---\n.*\n---\n+)?(.*)/m).to_a[2]
   license.sub! '[fullname]', 'Ben Balter'
   license.sub! '[year]', '2014'
   license.sub! '[email]', 'ben@github.invalid'

@benbalter
Copy link
Contributor

@pravi awesome. Thanks Would you be able to submit a pull request with that patch?

@stale stale bot added the wontfix label Apr 6, 2017
@stale
Copy link

stale bot commented Apr 6, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants