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
335602e8
Unverified
Commit
335602e8
authored
May 02, 2019
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
May 02, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4416 from shuujii/small-fix-in-mruby-bin-mruby
Small fix in `mruby-bin-mruby`
parents
a7871ce7
2a94bf8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
16 deletions
+21
-16
mrbgems/mruby-bin-mruby/bintest/mruby.rb
mrbgems/mruby-bin-mruby/bintest/mruby.rb
+19
-14
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
+2
-2
No files found.
mrbgems/mruby-bin-mruby/bintest/mruby.rb
View file @
335602e8
require
'tempfile'
require
'open3'
assert_mruby
=
->
(
exp_out
_pattern
,
exp_err_pattern
,
exp_success
,
args
)
do
assert_mruby
=
->
(
exp_out
,
exp_err
,
exp_success
,
args
)
do
out
,
err
,
stat
=
Open3
.
capture3
(
cmd
(
"mruby"
),
*
args
)
assert_
match
(
exp_out_pattern
,
out
,
"standard output"
)
assert_
match
(
exp_err_pattern
,
err
,
"standard error"
)
assert_
operator
(
exp_out
,
:===
,
out
,
"standard output"
)
assert_
operator
(
exp_err
,
:===
,
err
,
"standard error"
)
assert_equal
(
exp_success
,
stat
.
success?
,
"exit success?"
)
end
assert
(
'regression for #1564'
)
do
assert_mruby
.
(
""
,
"-e:1:2: syntax error, *"
,
false
,
%w[-e <<]
)
assert_mruby
.
(
""
,
"-e:1:3: syntax error, *"
,
false
,
%w[-e <<-]
)
assert_mruby
.
(
""
,
/\A-e:1:2: syntax error, .*\n\z/
,
false
,
%w[-e <<]
)
assert_mruby
.
(
""
,
/\A-e:1:3: syntax error, .*\n\z/
,
false
,
%w[-e <<-]
)
end
assert
(
'regression for #1572'
)
do
...
...
@@ -74,7 +74,7 @@ end
assert
(
'mruby -c option'
)
do
assert_mruby
.
(
"Syntax OK
\n
"
,
""
,
true
,
[
"-c"
,
"-e"
,
"p 1"
])
assert_mruby
.
(
""
,
"-e:1:7: syntax error, *"
,
false
,
[
"-c"
,
"-e"
,
"p 1; 1."
])
assert_mruby
.
(
""
,
/\A-e:1:7: syntax error, .*\n\z/
,
false
,
[
"-c"
,
"-e"
,
"p 1; 1."
])
end
assert
(
'mruby -d option'
)
do
...
...
@@ -85,11 +85,11 @@ assert('mruby -d option') do
end
assert
(
'mruby -e option (no code specified)'
)
do
assert_mruby
.
(
""
,
"* No code specified for -e
\n
"
,
false
,
%w[-e]
)
assert_mruby
.
(
""
,
/\A.*: No code specified for -e\n\z/
,
false
,
%w[-e]
)
end
assert
(
'mruby -h option'
)
do
assert_mruby
.
(
"Usage: *mruby*"
,
""
,
true
,
%w[-h]
)
assert_mruby
.
(
/\AUsage:
#{
Regexp
.
escape
cmd
(
"mruby"
)
}
.*/m
,
""
,
true
,
%w[-h]
)
end
assert
(
'mruby -r option'
)
do
...
...
@@ -116,25 +116,30 @@ EOS
end
assert
(
'mruby -r option (no library specified)'
)
do
assert_mruby
.
(
""
,
"*: No library specified for -r
\n
"
,
false
,
%w[-r]
)
assert_mruby
.
(
""
,
/\A.*: No library specified for -r\n\z/
,
false
,
%w[-r]
)
end
assert
(
'mruby -r option (file not found)'
)
do
assert_mruby
.
(
""
,
"*: Cannot open library file: *"
,
false
,
%w[-r _no_exists_]
)
assert_mruby
.
(
""
,
/\A.*: Cannot open library file: .*\n\z/
,
false
,
%w[-r _no_exists_]
)
end
assert
(
'mruby invalid short option'
)
do
assert_mruby
.
(
""
,
"*: invalid option -1 *"
,
false
,
%w[-1]
)
assert_mruby
.
(
""
,
/\A.*: invalid option -1 .*\n\z/
,
false
,
%w[-1]
)
end
assert
(
'mruby invalid long option'
)
do
assert_mruby
.
(
""
,
"*: invalid option --longopt *"
,
false
,
%w[--longopt]
)
assert_mruby
.
(
""
,
/\A.*: invalid option --longopt .*\n\z/
,
false
,
%w[--longopt]
)
end
assert
(
'unhandled exception'
)
do
assert_mruby
.
(
""
,
"* EXCEPTION!*"
,
false
,
%w[-e raise("EXCEPTION!
")]
)
assert_mruby
.
(
""
,
/\bEXCEPTION\b.*\n\z/
,
false
,
%w[-e raise("EXCEPTION
")]
)
end
assert
(
'program file not found'
)
do
assert_mruby
.
(
""
,
"*: Cannot open program file*"
,
false
,
%w[_no_exists_]
)
assert_mruby
.
(
""
,
/\A.*: Cannot open program file: .*\n\z/
,
false
,
%w[_no_exists_]
)
end
assert
(
'codegen error'
)
do
code
=
"def f(
#{
(
1
..
100
).
map
{
|
n
|
"a
#{
n
}
"
}
* "
,
"}); end"
assert_mruby
.
(
""
,
/\Acodegen error:.*\n\z/
,
false
,
[
"-e"
,
code
])
end
mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
View file @
335602e8
...
...
@@ -158,7 +158,7 @@ append_cmdline:
else
{
args
->
rfp
=
fopen
(
argv
[
0
],
args
->
mrbfile
?
"rb"
:
"r"
);
if
(
args
->
rfp
==
NULL
)
{
fprintf
(
stderr
,
"%s: Cannot open program file
. (%s)
\n
"
,
*
origargv
,
*
argv
);
fprintf
(
stderr
,
"%s: Cannot open program file
: %s
\n
"
,
*
origargv
,
*
argv
);
return
EXIT_FAILURE
;
}
args
->
fname
=
TRUE
;
...
...
@@ -285,7 +285,7 @@ main(int argc, char **argv)
n
=
EXIT_FAILURE
;
}
else
if
(
args
.
check_syntax
)
{
p
rintf
(
"Syntax OK
\n
"
);
p
uts
(
"Syntax OK
"
);
}
}
cleanup
(
mrb
,
&
args
);
...
...
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