Class: Mrubyc::Test::Tool

Inherits:
Thor
  • Object
show all
Defined in:
lib/mrubyc-test.rb

Instance Method Summary collapse

Instance Method Details

#help(arg = nil) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/mrubyc-test.rb', line 110

def help(arg = nil)
  super(arg)
  init_env
  if arg == "test"
    puts
    puts "Default environment variables you can change:"
    puts "  CFLAGS='#{ENV['CFLAGS']}'"
    puts "  LDFLAGS='#{ENV['LDFLAGS']}'"
    puts
  end
  exit if arg
  puts "\e[33m  Note:"
  puts '  It is recommended to use mrubyc-utils as a wrapper of this gem'
  puts '  see https://github.com/hasumikin/mrubyc-utils#wrapper-of-gem-mrubyc-test-and-mrubyc-debugger'
  puts "\e[0m"
end

#init ⇒ Object



20
21
22
# File 'lib/mrubyc-test.rb', line 20

def init
  Mrubyc::Test::Init.run
end

#test(testfilepath = "test/*.rb") ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/mrubyc-test.rb', line 91

def test(testfilepath = "test/*.rb")
  init_env
  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
  Dir.glob(test_path).each_slice(options[:every]) do |test_files|
    prepare(test_files, options[:verbose], method_name_pattern)
    make
  end
end

#version ⇒ Object



106
107
108
# File 'lib/mrubyc-test.rb', line 106

def version
  puts "mrubyc-test v#{Mrubyc::Test::VERSION}"
end