Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ryenus
Copy link
Contributor

@ryenus ryenus commented May 6, 2012

This is for #JRUBY-6606.

There're just too many places with hard-coded assumption of UTF-8 as the default encoding.

I've attached the test source/resources and the eclipse *.launch files. Running ant test is also successful (on Ubuntu 12.04), no test failure.

Things hopefully someone could check:

  1. for directory check, I replaced runtime.getPosix().stat(file.getAbsolutePath()).isDirectory() with direct file.isDirectory() call, which works but I'm not sure why the original code fails with non UTF-8 locales.
  2. for Java String -> Ruby String conversion, I modified the involved constructor to be encoding sensitive, this also works but I'm not sure if there's other code assuming the result to be always in UTF-8
  3. how to make ant test executes these tests as well? or should there be a separate test suite/target for encoding related tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file itself is fine, just GitHub website has header <meta charset='utf-8'>, that's why it looks garbled. This applies to all other non-Unicode resources.

@headius
Copy link
Member

headius commented May 14, 2012

Finally cycling around to this one.

The fixes look mostly ok, but I had to make a few modifications:

  • I put back the posix dir check but fixed a few areas that might have actually been causing the issue you saw. Specifically, I made sure all paths that got a java.lang.String file path from the incoming argument were using toJavaString or toString to decode properly, which included a few places in RubyFile that were still using getUnicodeString.
  • I modified your changes to the RubyString constructor that takes a CharSequence to attempt to use the Ruby "local encoding" and then fall back on UTF-8. This is similar to what you had using external encoding, but I believe this is the correct one to use.

With these changes our tests pass, but I have not yet been able to get your tests to run. That's next.

headius added a commit that referenced this pull request May 14, 2012
@headius
Copy link
Member

headius commented May 14, 2012

Ok, I'm going to take the fixes with my modifications, but I need you to wire your tests into one of our suites. I don't really care how you do it, but you might follow the pattern under spec/regression, which is where we keep bug-specific tests. If they fit somewhere else, that's good too, or you could try to submit them to RubySpec.

In any case, your changes have been pushed to master and I'll mark the bug resolved, but hope to see a pull request to wire your tests up.

@headius headius closed this May 14, 2012
@ryenus
Copy link
Contributor Author

ryenus commented May 17, 2012

Cool, I'd like to rerun my test and try to wire them, surely.

eregon added a commit that referenced this pull request Nov 28, 2015
cfdf72f add a spec that an object captured by a block, itself captured by #define_method is reachable
9f24088 Add spec for round-tripping Time through to_r.
882c628 incorrect string % spec - introduced at adcec1d (one too many 0s)
41aebc0 Spec for %f with precision as a fraction.
134753b Add more examples and assertions about $!
b7fc313 Fix style in rescue spec
9db1753 Expand abbreviation
1644bc7 Add a few more examples for Float#round
e78454c Module.remove_const returns nil when removing autoload constant
17214e1 Specify that Module#module_eval yields the module as the first block argument
4a44211 Organize String#unicode_normalize specs
a4024ae Wrap lines to < 80 chars
9ecee7a Add a note about where I took the unicode examples
521008e Add specs for unicode_normalized?
89d11be Add specs for exceptions
bb6be50 Add spec for unicode_normalize!
662fd46 Add specs for unicode_normalize
f45bed6 add spec for Process.spawn redirecting STDERR to child STDOUT
ffe74c3 Module#prepend is private in 2.0.0
0f69dd1 Add a spec for the latest change in Module#prepend_features
cc0da42 Fix file organization for String#unicode_normalize{,!,d?}
6927f8d Add a spec to specifically test for ObjectSpace iterating singleton classes
9f84a7f Singleton classes are walked on Ruby >= 2.3
739ddbe Revert "singleton class is yielded"
b8cb80b Merge pull request #163 from nobu/bug/ObjectSpace#each_object-singleton_class
73496fa singleton class is yielded
f724d7d Add spec for each_object(cls.singleton_class).
60664b0 include ruby.h prior to C standard headers
d439436 Merge pull request #160 from JuanitoFatas/ruby-23/core/hash-comparison
7f3b584 [Core/hash] Add specs for Hash #<=, #>=, #<, #> for Ruby 2.3
1a1fcb6 Literal strings as literal hash keys must preserve encoding.
ea1335c Add examples to specify #dig calls
c0a4a73 Merge pull request #161 from kares/master
788bb96 add a nested missing Hash key retrieval assert
fd7383a clarify Array#at method is meant in spec desc
d9f2120 Remove extra dot
94d39de Fix typos in Hash#to_proc spec
a1a040a Get rid of sleep in require specs and just synchronize instead
f94fff6 Remove usage of sleep in Process.wait spec
907c462 Remove usage of sleep in IO#select spec
bfc40c3 NetFTPSpecs::DummyFTP should not use hardcoded port number.
5607f17 Remove trailing whitespace from description
f039c77 Add "Enumerator" to "#enum_for" and "#to_enum" descriptions
643a506 tag dig specs with ruby_version_is 2.3
5473e04 spec nested type-mixed dig behaviour (including raw def-d obj.dig) on Ruby 2.3
ce93264 [core/hash] Hash#dig feature specs for Ruby 2.3
8600c67 [core/array] invented some Array#dig specs for Ruby 2.3
5f89c6d Add String# to the unicode_normalized? description
175c53e Merge pull request #159 from kachick/hash-to_proc
e97d589 Write Hash#to_proc specs
9686345 Merge pull request #158 from shugo/master
03a6d80 Check whether Net::FTP.default_passive is defined.
9b8931a Set Net::FTP.default_passive to false.
971924f Like FreeBSD, such simple spec can't pass on Solaris.
1f9b065 Socket option shoud be set as CRuby's test does.
cfbd946 Ruby 2.3 changes the default of Net::HTTP#open_timeout at r52480
1dab981 Fix typo in Marshal#load specdoc
73c4c70 Do not rely on stdlib in core Marshal specs
5b6334e Remove old duplicated fixture file
e7a5299 Merge Marshal fixtures for 1.9 with common fixtures
dc53709 Some plaftorms do not have Dir#fileno
3fcbce7 Remove rare case because rubyspec is not tzdata-spec
bdd83f3 Use File.realpath in case /dev/null is symlink like i386-solaris
e5ee977 Revert "/dev/null is symbolic link on i386-solaris"
11f13e4 Add more specs for a Method generated with respond_to_missing?
999d719 Remove dead code
bc7db44 Do not rely on any order for directory entries.
14b420f don't test features solaris doesn't support
89c50a2 /dev/null is symbolic link on i386-solaris
46d97ad don't run timezone rare case on Solaris
63b52ac Solaris doesn't have http definition in services by default
9940991 Solaris's syslog related constants are also different
3816a19 pow(3) behavior depends on compile-time options on Solaris.

git-subtree-dir: spec/ruby
git-subtree-split: cfdf72f32b206cf170e9de479e2cff1d79c8865e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants