handle Unicode filenames on Windows + test
by adding an argument "encoding: 'UTF-8'" to Dir.entries. Also add minimal test.
This commit is contained in:
parent
bb2e7bf4a7
commit
42342d0c96
@ -27,8 +27,16 @@ require "find"
|
|||||||
module Cmdtest
|
module Cmdtest
|
||||||
class FsSnapshot
|
class FsSnapshot
|
||||||
|
|
||||||
|
def _dir_entries(dir, &block)
|
||||||
|
if Cmdtest::Util.windows?
|
||||||
|
Dir.entries(dir, encoding: 'UTF-8', &block)
|
||||||
|
else
|
||||||
|
Dir.entries(dir, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def recursive_find(ignore, prefix, dir, &block)
|
def recursive_find(ignore, prefix, dir, &block)
|
||||||
for entry in Dir.entries(dir)
|
for entry in _dir_entries(dir)
|
||||||
next if entry == "."
|
next if entry == "."
|
||||||
next if entry == ".."
|
next if entry == ".."
|
||||||
path = File.join(dir, entry)
|
path = File.join(dir, entry)
|
||||||
|
25
t/CMDTEST_unicode.rb
Normal file
25
t/CMDTEST_unicode.rb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
require "selftest_utils"
|
||||||
|
|
||||||
|
class CMDTEST_unicode < Cmdtest::Testcase
|
||||||
|
|
||||||
|
include SelftestUtils
|
||||||
|
|
||||||
|
def test_unicode
|
||||||
|
|
||||||
|
create_CMDTEST_foo [
|
||||||
|
"cmd 'create_unicode_file.rb' do",
|
||||||
|
" created_files 'tmp-ΑΒΓ-αβγ-א-Њ-åäöÅÄÖ.txt'",
|
||||||
|
"end",
|
||||||
|
]
|
||||||
|
|
||||||
|
cmd_cmdtest do
|
||||||
|
stdout_equal [
|
||||||
|
"### create_unicode_file.rb",
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
5
t/bin/create_unicode_file.rb
Executable file
5
t/bin/create_unicode_file.rb
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
File.open('tmp-ΑΒΓ-αβγ-א-Њ-åäöÅÄÖ.txt', 'w', encoding: 'UTF-8') do |f|
|
||||||
|
f.puts 'this is tmp-ΑΒΓ-αβγ-א-Њ-åäöÅÄÖ.txt'
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user