Unverified Commit 17623fd0 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4665 from dearblue/fix-4642

Create a symbolic link in the temporary directory; fix #4642
parents ce899746 6ad2442f
...@@ -179,20 +179,25 @@ end ...@@ -179,20 +179,25 @@ end
assert('File.symlink') do assert('File.symlink') do
target_name = "/usr/bin" target_name = "/usr/bin"
symlink_name = MRubyIOTestUtil.mktemp("test-bin-dummy-XXXXXXXX")
if !File.exist?(target_name) if !File.exist?(target_name)
skip("target directory of File.symlink is not found") skip("target directory of File.symlink is not found")
else end
begin begin
assert_equal 0, File.symlink(target_name, symlink_name) tmpdir = MRubyIOTestUtil.mkdtemp("mruby-io-test.XXXXXX")
rescue => e
skip e.message
end
symlink_name = "#{tmpdir}/test-bin-dummy"
begin begin
assert_equal 0, File.symlink(target_name, symlink_name)
assert_equal true, File.symlink?(symlink_name) assert_equal true, File.symlink?(symlink_name)
ensure
File.delete symlink_name
end
rescue NotImplementedError => e rescue NotImplementedError => e
skip e.message skip e.message
end ensure
File.delete symlink_name rescue nil
MRubyIOTestUtil.rmdir tmpdir rescue nil
end end
end end
......
...@@ -44,7 +44,6 @@ mkdtemp(char *temp) ...@@ -44,7 +44,6 @@ mkdtemp(char *temp)
return path; return path;
} }
#define mktemp(path) _mktemp(path)
#define umask(mode) _umask(mode) #define umask(mode) _umask(mode)
#define rmdir(path) _rmdir(path) #define rmdir(path) _rmdir(path)
#else #else
...@@ -199,20 +198,6 @@ mrb_io_test_file_cleanup(mrb_state *mrb, mrb_value self) ...@@ -199,20 +198,6 @@ mrb_io_test_file_cleanup(mrb_state *mrb, mrb_value self)
return mrb_nil_value(); return mrb_nil_value();
} }
static mrb_value
mrb_io_test_mktemp(mrb_state *mrb, mrb_value klass)
{
mrb_value str;
char *cp;
mrb_get_args(mrb, "S", &str);
cp = mrb_str_to_cstr(mrb, str);
if (mktemp(cp) == NULL) {
mrb_sys_fail(mrb, "mktemp");
}
return mrb_str_new_cstr(mrb, cp);
}
static mrb_value static mrb_value
mrb_io_test_mkdtemp(mrb_state *mrb, mrb_value klass) mrb_io_test_mkdtemp(mrb_state *mrb, mrb_value klass)
{ {
...@@ -263,7 +248,6 @@ mrb_mruby_io_gem_test(mrb_state* mrb) ...@@ -263,7 +248,6 @@ mrb_mruby_io_gem_test(mrb_state* mrb)
mrb_define_class_method(mrb, io_test, "file_test_setup", mrb_io_test_file_setup, MRB_ARGS_NONE()); mrb_define_class_method(mrb, io_test, "file_test_setup", mrb_io_test_file_setup, MRB_ARGS_NONE());
mrb_define_class_method(mrb, io_test, "file_test_cleanup", mrb_io_test_file_cleanup, MRB_ARGS_NONE()); mrb_define_class_method(mrb, io_test, "file_test_cleanup", mrb_io_test_file_cleanup, MRB_ARGS_NONE());
mrb_define_class_method(mrb, io_test, "mktemp", mrb_io_test_mktemp, MRB_ARGS_REQ(1));
mrb_define_class_method(mrb, io_test, "mkdtemp", mrb_io_test_mkdtemp, MRB_ARGS_REQ(1)); mrb_define_class_method(mrb, io_test, "mkdtemp", mrb_io_test_mkdtemp, MRB_ARGS_REQ(1));
mrb_define_class_method(mrb, io_test, "rmdir", mrb_io_test_rmdir, MRB_ARGS_REQ(1)); mrb_define_class_method(mrb, io_test, "rmdir", mrb_io_test_rmdir, MRB_ARGS_REQ(1));
mrb_define_class_method(mrb, io_test, "win?", mrb_io_win_p, MRB_ARGS_NONE()); mrb_define_class_method(mrb, io_test, "win?", mrb_io_win_p, MRB_ARGS_NONE());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment