diff options
| author | takahashim <[email protected]> | 2015-12-06 00:07:16 +0900 |
|---|---|---|
| committer | takahashim <[email protected]> | 2015-12-08 00:29:42 +0900 |
| commit | dd754220ce2a53f8cf44362a2b2d1f59f40e62d5 (patch) | |
| tree | 645df51d35e9932b74f6d8503c34a61670cff987 /test/file.rb | |
| parent | 68de1e4fc5a124689e3ad975172c77071e4e63dc (diff) | |
| download | mruby-dd754220ce2a53f8cf44362a2b2d1f59f40e62d5.tar.gz mruby-dd754220ce2a53f8cf44362a2b2d1f59f40e62d5.zip | |
Fix for windows(mingw)
* File.expand_path: support drive letter and ALT_SEPARATOR
* File.dirname: support ALT_SEPARATOR
* File.basename: ditto.
* IO.popen: raise NotImplementedError
* IO.pipe: ditto.
* `cmd`: ditto.
* File#flock: ditto.
* FileTest.pipe?: ditto.
* FileTest.symlink?: ditto.
* FileTest.socket?: ditto.
Diffstat (limited to 'test/file.rb')
| -rw-r--r-- | test/file.rb | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/test/file.rb b/test/file.rb index ef8be37ec..ebb515cbf 100644 --- a/test/file.rb +++ b/test/file.rb @@ -56,12 +56,16 @@ end assert('IO#flock') do f = File.open $mrbtest_io_rfname - assert_equal(f.flock(File::LOCK_SH), 0) - assert_equal(f.flock(File::LOCK_UN), 0) - assert_equal(f.flock(File::LOCK_EX | File::LOCK_NB), 0) - assert_equal(f.flock(File::LOCK_UN), 0) - f.close - true + begin + assert_equal(f.flock(File::LOCK_SH), 0) + assert_equal(f.flock(File::LOCK_UN), 0) + assert_equal(f.flock(File::LOCK_EX | File::LOCK_NB), 0) + assert_equal(f.flock(File::LOCK_UN), 0) + rescue NotImplementedError => e + skip e.message + ensure + f.close + end end assert('File.join') do @@ -76,8 +80,13 @@ assert('File.join') do end assert('File.realpath') do - usrbin = IO.popen("cd bin; /bin/pwd -P") { |f| f.read.chomp } - assert_equal usrbin, File.realpath("bin") + if File.const_defined?(:ALT_SEPARATOR) && File::ALT_SEPARATOR + readme_path = File._getwd + File::ALT_SEPARATOR + "README.md" + assert_equal readme_path, File.realpath("README.md") + else + usrbin = IO.popen("cd bin; /bin/pwd -P") { |f| f.read.chomp } + assert_equal usrbin, File.realpath("bin") + end end assert('File TEST CLEANUP') do @@ -95,7 +104,12 @@ assert('File.expand_path') do assert_equal "/hoge", File.expand_path("////tmp/..///////hoge") assert_equal "/", File.expand_path("../../../..", "/") - assert_equal "/", File.expand_path(([".."] * 100).join("/")) + if File._getwd[1] == ":" + drive_letter = File._getwd[0] + assert_equal drive_letter + ":\\", File.expand_path(([".."] * 100).join("/")) + else + assert_equal "/", File.expand_path(([".."] * 100).join("/")) + end end assert('File.expand_path (with ENV)') do |
