mrubyc-test 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/bin/console +1 -1
- data/lib/mrubyc-test.rb +55 -19
- data/lib/mrubyc/test/generator/script.rb +18 -4
- data/lib/mrubyc/test/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f487ca59fe60282d05eefb7eaeee8b93971d690ac2b99985b473bb7c82d8ec50
|
4
|
+
data.tar.gz: 372db4c64cf31926758dbc249a2364972eccdbc9b620e38b446992821a261e8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ca5dc64f934ad214ee5e7ccc4426ade163771b85a0e245bf24f0b59c3f6a0cf12b43b0d37cb8536ad818b139975c7d58da7b94f261144ed92bab727c6c85400
|
7
|
+
data.tar.gz: d930234bca65fc38e5fa1fd8f26a71b6547b401560ada86df860d9aea0c34afd07af5012eb3222d5be165b976bbc99572a1beb01da8f2156ee13a4ace4fb7334
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mrubyc-test (0.
|
4
|
+
mrubyc-test (0.6.0)
|
5
5
|
activesupport (~> 6.0)
|
6
6
|
rufo (~> 0.12)
|
7
7
|
thor (~> 1.0)
|
@@ -9,23 +9,23 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (6.0.3.
|
12
|
+
activesupport (6.0.3.4)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
14
|
i18n (>= 0.7, < 2)
|
15
15
|
minitest (~> 5.1)
|
16
16
|
tzinfo (~> 1.1)
|
17
17
|
zeitwerk (~> 2.2, >= 2.2.2)
|
18
|
-
concurrent-ruby (1.1.
|
19
|
-
diff-lcs (1.
|
20
|
-
i18n (1.8.
|
18
|
+
concurrent-ruby (1.1.7)
|
19
|
+
diff-lcs (1.4.4)
|
20
|
+
i18n (1.8.5)
|
21
21
|
concurrent-ruby (~> 1.0)
|
22
|
-
minitest (5.14.
|
22
|
+
minitest (5.14.2)
|
23
23
|
rake (13.0.1)
|
24
24
|
rspec (3.9.0)
|
25
25
|
rspec-core (~> 3.9.0)
|
26
26
|
rspec-expectations (~> 3.9.0)
|
27
27
|
rspec-mocks (~> 3.9.0)
|
28
|
-
rspec-core (3.9.
|
28
|
+
rspec-core (3.9.3)
|
29
29
|
rspec-support (~> 3.9.3)
|
30
30
|
rspec-expectations (3.9.2)
|
31
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -39,7 +39,7 @@ GEM
|
|
39
39
|
thread_safe (0.3.6)
|
40
40
|
tzinfo (1.2.7)
|
41
41
|
thread_safe (~> 0.1)
|
42
|
-
zeitwerk (2.
|
42
|
+
zeitwerk (2.4.0)
|
43
43
|
|
44
44
|
PLATFORMS
|
45
45
|
ruby
|
@@ -51,4 +51,4 @@ DEPENDENCIES
|
|
51
51
|
rspec (~> 3.9)
|
52
52
|
|
53
53
|
BUNDLED WITH
|
54
|
-
2.1.
|
54
|
+
2.1.4
|
data/bin/console
CHANGED
data/lib/mrubyc-test.rb
CHANGED
@@ -25,30 +25,30 @@ module Mrubyc::Test
|
|
25
25
|
def prepare(test_files, verbose, method_name_pattern)
|
26
26
|
config = Mrubyc::Test::Config.read
|
27
27
|
model_files = Dir.glob(File.join(Dir.pwd, config['mruby_lib_dir'], 'models', '*.rb'))
|
28
|
-
|
29
28
|
# gather attributes from your implementations and tests
|
30
|
-
attributes = Mrubyc::Test::Generator::Attribute.run(
|
31
|
-
|
29
|
+
attributes = Mrubyc::Test::Generator::Attribute.run(
|
30
|
+
model_files: model_files,
|
31
|
+
test_files: test_files
|
32
|
+
)
|
32
33
|
# convert attributes into tast_cases
|
33
34
|
test_cases = Mrubyc::Test::Generator::TestCase.run(attributes)
|
34
|
-
|
35
35
|
# generate a ruby script that will be compiled by mrbc and executed in mruby/c VM
|
36
|
-
Mrubyc::Test::Generator::Script.run(
|
36
|
+
Mrubyc::Test::Generator::Script.run(
|
37
|
+
model_files: model_files,
|
38
|
+
test_files: test_files,
|
39
|
+
test_cases: test_cases,
|
40
|
+
verbose: verbose,
|
41
|
+
method_name_pattern: method_name_pattern
|
42
|
+
)
|
37
43
|
end
|
38
44
|
|
39
|
-
def make
|
45
|
+
def make(mrbc_path)
|
40
46
|
config = Mrubyc::Test::Config.read
|
41
47
|
tmp_dir = File.join(Dir.pwd, config['test_tmp_dir'])
|
42
48
|
puts "cd #{tmp_dir}"
|
43
49
|
puts
|
44
50
|
exit_code = 0
|
45
51
|
pwd = Dir.pwd
|
46
|
-
mruby_version = File.read('.ruby-version').gsub("\n", '').chomp
|
47
|
-
unless mruby_version.index('mruby')
|
48
|
-
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`'
|
49
|
-
print 'You can specify the version name of mruby [mruby-x.x.x]: '
|
50
|
-
mruby_version = STDIN.gets.chomp
|
51
|
-
end
|
52
52
|
hal_path = "#{pwd}/#{config['mrubyc_src_dir']}/hal"
|
53
53
|
hal_bak_path = "#{pwd}/#{config['mrubyc_src_dir']}/~hal"
|
54
54
|
FileUtils.mv(hal_path, hal_bak_path) if FileTest.exist?(hal_path)
|
@@ -56,8 +56,8 @@ module Mrubyc::Test
|
|
56
56
|
FileUtils.ln_s "#{pwd}/#{config['test_tmp_dir']}/hal", "#{pwd}/#{config['mrubyc_src_dir']}/hal"
|
57
57
|
Dir.chdir(tmp_dir) do
|
58
58
|
[
|
59
|
-
"
|
60
|
-
"
|
59
|
+
"#{mrbc_path} -E -B test test.rb",
|
60
|
+
"#{mrbc_path} -E -B models models.rb",
|
61
61
|
"cc -I #{pwd}/#{config['mrubyc_src_dir']} -o test main.c #{pwd}/#{config['mrubyc_src_dir']}/*.c #{pwd}/#{config['mrubyc_src_dir']}/hal/*.c #{ENV["CFLAGS"]} #{ENV["LDFLAGS"]}",
|
62
62
|
"./test"].each do |cmd|
|
63
63
|
puts cmd
|
@@ -84,10 +84,35 @@ module Mrubyc::Test
|
|
84
84
|
|
85
85
|
end
|
86
86
|
|
87
|
-
desc 'test',
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
desc 'test', <<~DESC
|
88
|
+
[Default command]
|
89
|
+
Execute test. You can specify a test file like
|
90
|
+
`mrubyc-test test test/array_test.rb`'
|
91
|
+
DESC
|
92
|
+
option :every, type: :numeric, default: 10, aliases: "-e",
|
93
|
+
banner: <<~DESC.chomp
|
94
|
+
NUMBER
|
95
|
+
To avoid Out of Memory, test will be devided up to
|
96
|
+
every specified NUMBER of xxx_test.rb files
|
97
|
+
DESC
|
98
|
+
option :verbose, type: :boolean, default: false, aliases: "-v",
|
99
|
+
banner: "[true/false] - Show test result verbosely"
|
100
|
+
option :name, type: :string, aliases: "-n",
|
101
|
+
banner: <<~DESC.chomp
|
102
|
+
NAME
|
103
|
+
Specify the NAME of tests you want to run. If you
|
104
|
+
write --name='/PATTERN/', it will be processed as a regular
|
105
|
+
expression. It must be single-quoted and doubled-backslash.
|
106
|
+
eg) --name='/a\\\\db/' will create Regexp object `/a\\db/`
|
107
|
+
and match strings like `a1b`
|
108
|
+
DESC
|
109
|
+
option :mrbc_path, type: :string, aliases: "-p",
|
110
|
+
banner: <<~DESC.chomp
|
111
|
+
PATH
|
112
|
+
Specify the path to mrbc.
|
113
|
+
eg: /home/hoge/mruby/build/host/bin/mrbc
|
114
|
+
RBENV_VERSION will be ignored if you specify this option.
|
115
|
+
DESC
|
91
116
|
def test(testfilepath = "test/*.rb")
|
92
117
|
init_env
|
93
118
|
method_name_pattern = (%r{\A/(.*)/\Z} =~ options[:name] ? Regexp.new($1) : options[:name])
|
@@ -96,9 +121,20 @@ module Mrubyc::Test
|
|
96
121
|
else
|
97
122
|
File.join(Dir.pwd, testfilepath)
|
98
123
|
end
|
124
|
+
mrbc_path = if options[:mrbc_path]
|
125
|
+
options[:mrbc_path]
|
126
|
+
else
|
127
|
+
mruby_version = File.read('.ruby-version').gsub("\n", '').chomp
|
128
|
+
unless mruby_version.index('mruby')
|
129
|
+
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`'
|
130
|
+
print 'You can specify the version name of mruby [mruby-x.x.x]: '
|
131
|
+
mruby_version = STDIN.gets.chomp
|
132
|
+
end
|
133
|
+
"RBENV_VERSION=#{mruby_version} mrbc"
|
134
|
+
end
|
99
135
|
Dir.glob(test_path).each_slice(options[:every]) do |test_files|
|
100
136
|
prepare(test_files, options[:verbose], method_name_pattern)
|
101
|
-
make
|
137
|
+
make(mrbc_path)
|
102
138
|
end
|
103
139
|
end
|
104
140
|
|
@@ -10,11 +10,25 @@ module Mrubyc
|
|
10
10
|
class << self
|
11
11
|
def run(model_files: [], test_files:, test_cases:, verbose:, method_name_pattern:)
|
12
12
|
config = Mrubyc::Test::Config.read
|
13
|
-
test_erb = ERB.new(
|
14
|
-
|
13
|
+
test_erb = ERB.new(
|
14
|
+
File.read(
|
15
|
+
File.expand_path('../../../../templates/test.rb.erb', __FILE__)
|
16
|
+
), nil, '-'
|
17
|
+
)
|
18
|
+
models_erb = ERB.new(
|
19
|
+
File.read(
|
20
|
+
File.expand_path('../../../../templates/models.rb.erb', __FILE__)
|
21
|
+
), nil, '-'
|
22
|
+
)
|
15
23
|
mrubyc_class_dir = File.expand_path('../../../../mrubyc-ext/', __FILE__)
|
16
|
-
File.write(File.join(
|
17
|
-
|
24
|
+
File.write(File.join(
|
25
|
+
config['test_tmp_dir'], 'test.rb'),
|
26
|
+
Rufo.format(test_erb.result(binding))
|
27
|
+
)
|
28
|
+
File.write(File.join(
|
29
|
+
config['test_tmp_dir'], 'models.rb'),
|
30
|
+
Rufo.format(models_erb.result(binding))
|
31
|
+
)
|
18
32
|
end
|
19
33
|
end
|
20
34
|
end
|
data/lib/mrubyc/test/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mrubyc-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HASUMI Hitoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|