Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
f8a3af80
Commit
f8a3af80
authored
Feb 28, 2017
by
Tomoyuki Sahara
Committed by
GitHub
Feb 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74 from iij/run-test-outside-source-tree
run mrbtest outside of source tree.
parents
74fe87c2
3ae5fea2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
15 deletions
+72
-15
test/file.rb
test/file.rb
+19
-4
test/file_test.rb
test/file_test.rb
+14
-4
test/io.rb
test/io.rb
+7
-6
test/mruby_io_test.c
test/mruby_io_test.c
+32
-1
No files found.
test/file.rb
View file @
f8a3af80
...
...
@@ -86,14 +86,20 @@ assert('File.realpath') do
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"
)
dir
=
MRubyIOTestUtil
.
mkdtemp
(
"mruby-io-test.XXXXXX"
)
begin
dir1
=
File
.
realpath
(
$mrbtest_io_rfname
)
dir2
=
File
.
realpath
(
"./
#{
dir
}
//./../
#{
$mrbtest_io_symlinkname
}
"
)
assert_equal
dir1
,
dir2
ensure
MRubyIOTestUtil
.
rmdir
dir
end
end
end
assert
(
"File.readlink"
)
do
begin
assert_equal
'hoge'
,
File
.
readlink
(
$mrbtest_io_symlinkname
)
assert_equal
$mrbtest_io_rfname
,
File
.
readlink
(
$mrbtest_io_symlinkname
)
rescue
NotImplementedError
=>
e
skip
e
.
message
end
...
...
@@ -101,7 +107,16 @@ end
assert
(
"File.readlink fails with non-symlink"
)
do
begin
assert_raise
(
RuntimeError
)
{
File
.
readlink
(
$mrbtest_io_rfname
)
}
assert_raise
(
RuntimeError
)
{
begin
File
.
readlink
(
$mrbtest_io_rfname
)
rescue
=>
e
if
Object
.
const_defined?
(
:SystemCallError
)
and
e
.
kind_of?
(
SystemCallError
)
raise
RuntimeError
,
"SystemCallError converted to RuntimeError"
end
raise
e
end
}
rescue
NotImplementedError
=>
e
skip
e
.
message
end
...
...
test/file_test.rb
View file @
f8a3af80
...
...
@@ -6,8 +6,13 @@ assert('FileTest TEST SETUP') do
end
assert
(
"FileTest.directory?"
)
do
assert_equal
true
,
FileTest
.
directory?
(
File
.
join
(
File
.
_getwd
,
"mrblib"
))
assert_equal
false
,
FileTest
.
directory?
(
File
.
join
(
File
.
_getwd
,
"README.md"
))
dir
=
MRubyIOTestUtil
.
mkdtemp
(
"mruby-io-test.XXXXXX"
)
begin
assert_true
FileTest
.
directory?
(
dir
)
assert_false
FileTest
.
directory?
(
$mrbtest_io_rfname
)
ensure
MRubyIOTestUtil
.
rmdir
dir
end
end
assert
(
"FileTest.exist?"
)
do
...
...
@@ -23,8 +28,13 @@ assert("FileTest.exist?") do
end
assert
(
"FileTest.file?"
)
do
assert_equal
false
,
FileTest
.
file?
(
File
.
join
(
File
.
_getwd
,
"mrblib"
))
assert_equal
true
,
FileTest
.
file?
(
File
.
join
(
File
.
_getwd
,
"README.md"
))
dir
=
MRubyIOTestUtil
.
mkdtemp
(
"mruby-io-test.XXXXXX"
)
begin
assert_true
FileTest
.
file?
(
$mrbtest_io_rfname
)
assert_false
FileTest
.
file?
(
dir
)
ensure
MRubyIOTestUtil
.
rmdir
dir
end
end
assert
(
"FileTest.pipe?"
)
do
...
...
test/io.rb
View file @
f8a3af80
...
...
@@ -387,13 +387,13 @@ end
assert
(
'IO.popen'
)
do
begin
$?
=
nil
io
=
IO
.
popen
(
"
ls
"
)
io
=
IO
.
popen
(
"
echo mruby-io
"
)
assert_true
io
.
close_on_exec?
assert_equal
Fixnum
,
io
.
pid
.
class
ls
=
io
.
read
assert_equal
ls
.
class
,
String
assert_
include
ls
,
'AUTHORS'
assert_include
ls
,
'mrblib
'
out
=
io
.
read
assert_
equal
out
.
class
,
String
assert_include
out
,
'mruby-io
'
io
.
close
if
Object
.
const_defined?
:Process
...
...
@@ -401,7 +401,8 @@ assert('IO.popen') do
else
assert_equal
0
,
$?
end
io
.
closed?
assert_true
io
.
closed?
rescue
NotImplementedError
=>
e
skip
e
.
message
end
...
...
test/mruby_io_test.c
View file @
f8a3af80
...
...
@@ -16,6 +16,7 @@
#include "mruby.h"
#include "mruby/array.h"
#include "mruby/error.h"
#include "mruby/string.h"
#include "mruby/variable.h"
...
...
@@ -72,7 +73,7 @@ mrb_io_test_io_setup(mrb_state *mrb, mrb_value self)
#ifndef _WIN32
unlink
(
symlinkname
);
close
(
fd2
);
if
(
symlink
(
"hoge"
,
symlinkname
)
==
-
1
)
{
if
(
symlink
(
rfname
,
symlinkname
)
==
-
1
)
{
mrb_raise
(
mrb
,
E_RUNTIME_ERROR
,
"can't make a symbolic link"
);
}
...
...
@@ -147,6 +148,34 @@ mrb_io_test_file_cleanup(mrb_state *mrb, mrb_value self)
return
mrb_nil_value
();
}
static
mrb_value
mrb_io_test_mkdtemp
(
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
(
mkdtemp
(
cp
)
==
NULL
)
{
mrb_sys_fail
(
mrb
,
"mkdtemp"
);
}
return
mrb_str_new_cstr
(
mrb
,
cp
);
}
static
mrb_value
mrb_io_test_rmdir
(
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
(
rmdir
(
cp
)
==
-
1
)
{
mrb_sys_fail
(
mrb
,
"rmdir"
);
}
return
mrb_true_value
();
}
void
mrb_mruby_io_gem_test
(
mrb_state
*
mrb
)
{
...
...
@@ -157,4 +186,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_cleanup"
,
mrb_io_test_file_cleanup
,
MRB_ARGS_NONE
());
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
));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment