113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/mrubyc-test.rb', line 113
def test(testfilepath = "")
Mrubyc::Test::Init.init_main_c
init_env
config = Mrubyc::Test::Config.read
method_name_pattern = (%r{\A/(.*)/\Z} =~ options[:name] ? Regexp.new($1) : options[:name])
test_path = if testfilepath == ""
File.join(Dir.pwd, config['test_dir'], "*.rb")
else
File.join(Dir.pwd, testfilepath)
end
mrbc_path = options[:mrbc_path] || config['mrbc_path']
unless mrbc_path
mruby_version = File.read('.ruby-version').gsub("\n", '').chomp
unless mruby_version.index('mruby')
puts '.ruby-version doesn\'t set `mruby-x.x.x It is recommended to use the latest version of https://github.com/hasumikin/mrubyc-utils`'
print 'You can specify the version name of mruby [mruby-x.x.x]: '
mruby_version = STDIN.gets.chomp
end
"RBENV_VERSION=#{mruby_version} mrbc"
end
exit_code = 0
Dir.glob(test_path).each_slice(options[:every]) do |test_files|
prepare(test_files, options[:verbose], method_name_pattern)
exit_code += make(mrbc_path)
end
if exit_code > 0
puts "\e[31mFinished with error(s)\e[0m"
exit 1
end
puts "\e[32mFinished without error\e[0m"
end
|