diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-03 22:09:20 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-03 22:09:20 +0000 |
commit | fa0a9eabf6604589053554656414f740e3722888 (patch) | |
tree | fc50c819b499d68166bfc8441b5b41f1dcd1c69a /test | |
parent | 7f8a1be2828d15ef06ab0dec396fe79506bae048 (diff) |
merge revision(s) 59602,59887: [Backport #13816]
High Sierra's APFS cannot use invalid filenames [Bug #13816]
added workaround for APFS file format.
* TestFileExhaustive#test_atime: It fails with nano-sec precise.
I changed to use unixtime for this assertion for APFS.
* TestFileExhaustive#test_expand_path: skip assertion when given
invalid charactor on APFS.
[Bug #13816][ruby-core:82383]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_dir_m17n.rb | 10 | ||||
-rw-r--r-- | test/ruby/test_file_exhaustive.rb | 11 |
2 files changed, 19 insertions, 2 deletions
diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb index 5d009aceb1..acfee815c7 100644 --- a/test/ruby/test_dir_m17n.rb +++ b/test/ruby/test_dir_m17n.rb @@ -1,6 +1,7 @@ # frozen_string_literal: false require 'test/unit' require 'tmpdir' +require '-test-/file' class TestDir_M17N < Test::Unit::TestCase def with_tmpdir @@ -59,6 +60,8 @@ class TestDir_M17N < Test::Unit::TestCase def test_filename_extutf8_invalid return if /cygwin/ =~ RUBY_PLATFORM + # High Sierra's APFS cannot use invalid filenames + return if Bug::File::Fs.fsname(Dir.tmpdir) == "apfs" with_tmpdir {|d| assert_separately(%w[-EASCII-8BIT], <<-'EOS', :chdir=>d) filename = "\xff".force_encoding("ASCII-8BIT") # invalid byte sequence as UTF-8 @@ -375,7 +378,12 @@ class TestDir_M17N < Test::Unit::TestCase a = "file_one*".force_encoding Encoding::IBM437 b = "file_two*".force_encoding Encoding::EUC_JP assert_equal([a, b].map(&:encoding), Dir[a, b].map(&:encoding)) - dir = "\u{76EE 5F551}" + if Bug::File::Fs.fsname(Dir.pwd) == "apfs" + # High Sierra's APFS cannot use filenames with undefined character + dir = "\u{76EE}" + else + dir = "\u{76EE 5F551}" + end Dir.mkdir(dir) list << dir bug12081 = '[ruby-core:73868] [Bug #12081]' diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index f3845f7f51..5be36063c4 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -3,6 +3,7 @@ require "test/unit" require "fileutils" require "tmpdir" require "socket" +require '-test-/file' class TestFileExhaustive < Test::Unit::TestCase DRIVE = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i] @@ -572,7 +573,13 @@ class TestFileExhaustive < Test::Unit::TestCase t2 = File.open(file) {|f| f.atime} assert_kind_of(Time, t1) assert_kind_of(Time, t2) - assert_equal(t1, t2) + # High Sierra's APFS can handle nano-sec precise. + # t1 value is difference from t2 on APFS. + if Bug::File::Fs.fsname(Dir.tmpdir) == "apfs" + assert_equal(t1.to_i, t2.to_i) + else + assert_equal(t1, t2) + end end assert_raise(Errno::ENOENT) { File.atime(nofile) } end @@ -749,6 +756,8 @@ class TestFileExhaustive < Test::Unit::TestCase begin open(file) {} rescue + # High Sierra's APFS cannot use filenames with undefined character + next if Bug::File::Fs.fsname(Dir.tmpdir) == "apfs" assert_equal(file, full_path, mesg) else assert_equal(regular_file, full_path, mesg) |