mrubyc-test 0.5.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80096778ca2a86911aca010ec509d7b5b38e00c6fc8700248c2af49df8ae27e9
4
- data.tar.gz: 80b9f7b1e569a2188a4db828ce923509705a9a850683f5b2d7d6696af5f18688
3
+ metadata.gz: f6b6e64b49572a4c4a90f6a5a43d25309c42c91e004f6b6fc4e31ad84555d9c8
4
+ data.tar.gz: 1df134d8e5a19dc3b1c46e6ee97f5a25c89df2cf4287cac84589383b831dcb3b
5
5
  SHA512:
6
- metadata.gz: 61d8df8a6941f9f9df0df6efce1f8b39622b3f15ad1b9d7711472292fe970ad08953b2cfa07ceecc02ccc529dc4fa1d39a4b6489a9d63ba58f31e5ff8a0caa5c
7
- data.tar.gz: c90ff2c1955380504432038fc6cb4eaa6ff6722c3872f2101bcbb2c606345c4cbd5a66c7944e5acdd843bcb0b8889ae5806b9c9c5d882c26ce0ff63b35b574de
6
+ metadata.gz: fcb5ed97c767cb27084ccb99b5108e9556f196be113770369162362391304b46997ead657bf290b91eacb0aced27dc06051a11848b2a2570a9d69a3928d714a2
7
+ data.tar.gz: a7dc49998b925f0871819bcbd2d15eeb821d35ce2a7ebb48402a412f20cfa6c57012e8cd64cd556e8d91947ed96e4546e0a8400998d316f0832eca4deb99ed5c
@@ -1,9 +1,8 @@
1
1
  ---
2
- sudo: false
3
2
  language: ruby
4
- bundler_args: --deployment
5
- cache: bundler
6
3
  rvm:
7
- - 2.6.2
8
- before_install: gem install bundler --no-document
4
+ - 2.7.0
5
+ before_install:
6
+ - gem install bundler -v 2.1.2
7
+ - bundle install
9
8
  script: bundle exec rake spec
@@ -1,43 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mrubyc-test (0.5.0)
5
- activesupport (~> 5.2)
4
+ mrubyc-test (0.6.0)
5
+ activesupport (~> 6.0)
6
6
  rufo (~> 0.12)
7
7
  thor (~> 1.0)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (5.2.4.1)
12
+ activesupport (6.1.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- concurrent-ruby (1.1.6)
18
- diff-lcs (1.3)
19
- i18n (1.8.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
+ concurrent-ruby (1.1.7)
19
+ diff-lcs (1.4.4)
20
+ i18n (1.8.7)
20
21
  concurrent-ruby (~> 1.0)
21
- minitest (5.14.0)
22
- rake (13.0.1)
23
- rspec (3.9.0)
24
- rspec-core (~> 3.9.0)
25
- rspec-expectations (~> 3.9.0)
26
- rspec-mocks (~> 3.9.0)
27
- rspec-core (3.9.1)
28
- rspec-support (~> 3.9.1)
29
- rspec-expectations (3.9.1)
22
+ minitest (5.14.3)
23
+ rake (13.0.3)
24
+ rspec (3.10.0)
25
+ rspec-core (~> 3.10.0)
26
+ rspec-expectations (~> 3.10.0)
27
+ rspec-mocks (~> 3.10.0)
28
+ rspec-core (3.10.1)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-expectations (3.10.1)
30
31
  diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.9.0)
32
- rspec-mocks (3.9.1)
32
+ rspec-support (~> 3.10.0)
33
+ rspec-mocks (3.10.1)
33
34
  diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.9.0)
35
- rspec-support (3.9.2)
35
+ rspec-support (~> 3.10.0)
36
+ rspec-support (3.10.1)
36
37
  rufo (0.12.0)
37
38
  thor (1.0.1)
38
- thread_safe (0.3.6)
39
- tzinfo (1.2.6)
40
- thread_safe (~> 0.1)
39
+ tzinfo (2.0.4)
40
+ concurrent-ruby (~> 1.0)
41
+ zeitwerk (2.4.2)
41
42
 
42
43
  PLATFORMS
43
44
  ruby
@@ -49,4 +50,4 @@ DEPENDENCIES
49
50
  rspec (~> 3.9)
50
51
 
51
52
  BUNDLED WITH
52
- 2.1.2
53
+ 2.2.5
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # mrubyc-test
2
2
 
3
- [![Build Status](https://travis-ci.com/mrubyc/mrubyc-test.svg?branch=master)](https://travis-ci.com/mrubyc/mrubyc-test)
3
+ [![Build Status](https://travis-ci.org/mrubyc/mrubyc-test.svg?branch=master)](https://travis-ci.org/mrubyc/mrubyc-test)
4
4
 
5
5
  mrubyc-test is an unit test framework for [mruby/c](https://github.com/mrubyc/mrubyc), supporting basic assertions, stub and mock.
6
6
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "mrubyc/test"
4
+ require "mrubyc-test"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -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(model_files: model_files, test_files: test_files)
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(model_files: model_files, test_files: test_files, test_cases: test_cases, verbose: verbose, method_name_pattern: method_name_pattern)
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,9 +56,9 @@ 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
- "RBENV_VERSION=#{mruby_version} mrbc -E -B test test.rb",
60
- "RBENV_VERSION=#{mruby_version} mrbc -E -B models models.rb",
61
- "cc #{ENV["CFLAGS"]} #{ENV["LDFLAGS"]} -I #{pwd}/#{config['mrubyc_src_dir']} -o test main.c #{pwd}/#{config['mrubyc_src_dir']}/*.c #{pwd}/#{config['mrubyc_src_dir']}/hal/*.c",
59
+ "#{mrbc_path} -E -B test test.rb",
60
+ "#{mrbc_path} -E -B models models.rb",
61
+ "cc -O0 -g3 -Wall -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
64
64
  puts
@@ -78,16 +78,41 @@ module Mrubyc::Test
78
78
  end
79
79
 
80
80
  def init_env
81
- ENV["CFLAGS"] = "-std=gnu99 -DMRBC_DEBUG -DMRBC_USE_MATH=1 -Wall #{ENV["CFLAGS"]}"
82
- ENV["LDFLAGS"] = "-Wl,--no-as-needed -lm #{ENV["LDFLAGS"]}"
81
+ ENV["CFLAGS"] = "-std=gnu99 -Wall #{ENV["CFLAGS"]}"
82
+ ENV["LDFLAGS"] = "-lm #{ENV["LDFLAGS"]}"
83
83
  end
84
84
 
85
85
  end
86
86
 
87
- desc 'test', '[Default command] Execute test. You can specify a test file like `mrubyc-test test test/array_test.rb`'
88
- option :every, type: :numeric, default: 10, aliases: "-e", banner: "NUMBER - To avoid Out of Memory, test will be devided up to every specified NUMBER of xxx_test.rb files"
89
- option :verbose, type: :boolean, default: false, aliases: "-v", banner: "[true/false] - Show test result verbosely"
90
- option :name, type: :string, aliases: "-n", banner: "NAME - Specify the NAME of tests you want to run. If you write --name='/PATTERN/', it will be processed as a regular expression. It must be single-quoted and doubled-backslash. eg) --name='/a\\\\db/' will create Regexp object `/a\\db/` and match strings like `a1b`"
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,6 +10,7 @@ module Mrubyc
10
10
  def run(model_files: [], test_files:)
11
11
  # get information from model files(application code)
12
12
  model_files.each do |model_file|
13
+ puts "loading #{model_file}"
13
14
  load model_file
14
15
  class_name = File.basename(model_file, '.rb').camelize
15
16
  begin
@@ -18,6 +19,7 @@ module Mrubyc
18
19
  print "\e[33m"
19
20
  puts "[WARN] #{model_file} doesn't have corresponding class `#{class_name}`."
20
21
  print "\e[m"
22
+ next
21
23
  end
22
24
  model_class.class_eval do
23
25
  def method_missing(_method_name, *_args)
@@ -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(File.read(File.expand_path('../../../../templates/test.rb.erb', __FILE__)), nil, '-')
14
- models_erb = ERB.new(File.read(File.expand_path('../../../../templates/models.rb.erb', __FILE__)), nil, '-')
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(config['test_tmp_dir'], 'test.rb'), Rufo.format(test_erb.result(binding)))
17
- File.write(File.join(config['test_tmp_dir'], 'models.rb'), Rufo.format(models_erb.result(binding)))
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
@@ -1,5 +1,5 @@
1
1
  module Mrubyc
2
2
  module Test
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.1"
4
4
  end
5
5
  end
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "rspec", "~> 3.9"
29
29
 
30
30
  spec.add_dependency "thor", "~> 1.0"
31
- spec.add_dependency "activesupport", "~> 5.2"
31
+ spec.add_dependency "activesupport", "~> 6.0"
32
32
  spec.add_dependency "rufo", "~> 0.12"
33
33
  end
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.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - HASUMI Hitoshi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-16 00:00:00.000000000 Z
11
+ date: 2021-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '5.2'
75
+ version: '6.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '5.2'
82
+ version: '6.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rufo
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -137,7 +137,7 @@ homepage: https://github.com/mrubyc/mrubyc-test
137
137
  licenses:
138
138
  - BSD-3-Clause
139
139
  metadata: {}
140
- post_install_message:
140
+ post_install_message:
141
141
  rdoc_options: []
142
142
  require_paths:
143
143
  - lib
@@ -152,8 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubygems_version: 3.1.2
156
- signing_key:
155
+ rubygems_version: 3.2.3
156
+ signing_key:
157
157
  specification_version: 4
158
158
  summary: Test Framework for mruby/c
159
159
  test_files: []