mrubyc-test 0.8.0 → 0.9.0

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: d22552c0a71b7399d7eae38faa8ae82b48b6553f8059e42f210dce7d75f127ae
4
- data.tar.gz: 90bcd3c1c4c76f1f1db76582bf181dd2550e6a78230e9ced1f5ed9f96abfdca8
3
+ metadata.gz: 56675156ca057519416d62929755a348cb2ba1340f7e6ad7a36066e0e2c2bf25
4
+ data.tar.gz: 5f7af355c9bc8760179b84976dcfd6c6be639ddc32cf78dca7c1e3f412f6b2d0
5
5
  SHA512:
6
- metadata.gz: 454e1ba5ee921f0829c5f44cf42f34c82c812585144ff703fee4042c1bba9f7953e0480ea21e14cc361c8acf75861f125299f3b4b2993c8c884b7a21d76b451a
7
- data.tar.gz: db8fdcfbf31995e6c3c9ca9964ebf813c09f4ad0757f9b0d5ef69f19f09e68ceb431ee1111bf5f83ce2d5d48451f3fb0a6a04519d42d1d88a7a95cabc2d7e8c6
6
+ metadata.gz: '09d6b1f937558236961b0543f34b7bfe319ea29719b6f7c844219c04e892627556f99a0dddfc718b9b4b9339869e49cccb5aa9d003e596bb1598ac55d8697f2a'
7
+ data.tar.gz: 3973153063d81e3b0367fab6d265dc47e674f06d799491b5aacc986bc73052c87d181bc8280cd35aa1e3a84ee1be751dee044f435738c4d075ee4e8ecef7abf7
data/.gitignore CHANGED
@@ -15,3 +15,5 @@
15
15
  /test/
16
16
  /mrblib/
17
17
  /mrubyc_src/
18
+
19
+ .rake_tasks~
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mrubyc-test (0.7.4)
4
+ mrubyc-test (0.9.0)
5
5
  activesupport (~> 7.0)
6
6
  rufo (~> 0.12)
7
7
  thor (~> 1.2)
@@ -9,7 +9,7 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (7.0.3.1)
12
+ activesupport (7.0.4)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
@@ -18,24 +18,24 @@ GEM
18
18
  diff-lcs (1.5.0)
19
19
  i18n (1.12.0)
20
20
  concurrent-ruby (~> 1.0)
21
- minitest (5.16.2)
21
+ minitest (5.16.3)
22
22
  rake (13.0.6)
23
- rspec (3.11.0)
24
- rspec-core (~> 3.11.0)
25
- rspec-expectations (~> 3.11.0)
26
- rspec-mocks (~> 3.11.0)
27
- rspec-core (3.11.0)
28
- rspec-support (~> 3.11.0)
29
- rspec-expectations (3.11.0)
23
+ rspec (3.12.0)
24
+ rspec-core (~> 3.12.0)
25
+ rspec-expectations (~> 3.12.0)
26
+ rspec-mocks (~> 3.12.0)
27
+ rspec-core (3.12.0)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-expectations (3.12.1)
30
30
  diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.11.0)
32
- rspec-mocks (3.11.1)
31
+ rspec-support (~> 3.12.0)
32
+ rspec-mocks (3.12.1)
33
33
  diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.11.0)
35
- rspec-support (3.11.0)
34
+ rspec-support (~> 3.12.0)
35
+ rspec-support (3.12.0)
36
36
  rufo (0.13.0)
37
37
  thor (1.2.1)
38
- tzinfo (2.0.4)
38
+ tzinfo (2.0.5)
39
39
  concurrent-ruby (~> 1.0)
40
40
 
41
41
  PLATFORMS
@@ -14,6 +14,13 @@ module Mrubyc
14
14
  raise 'Check if `Mrubycfile or .mrubycconfig` exists.'
15
15
  end
16
16
  end
17
+ if config && ENV['MRUBYCFILE']
18
+ config.each do |k, v|
19
+ if v && k != "mrbc_path"
20
+ config[k] = File.join File.dirname(ENV['MRUBYCFILE']), v
21
+ end
22
+ end
23
+ end
17
24
  config || {}
18
25
  end
19
26
 
@@ -24,9 +31,11 @@ module Mrubyc
24
31
  end
25
32
 
26
33
  def mrubycfile
27
- if File.exists? 'Mrubycfile'
34
+ if ENV['MRUBYCFILE']
35
+ ENV['MRUBYCFILE']
36
+ elsif File.exists? 'Mrubycfile'
28
37
  'Mrubycfile'
29
- elsif File.exists? '.mrubycconfig'
38
+ elsif File.exists? '.mrubycconfig'
30
39
  '.mrubycconfig'
31
40
  else
32
41
  FileUtils.touch 'Mrubycfile'
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/core_ext/string/inflections'
4
+ require 'i18n/locale/fallbacks'
5
+ require 'i18n/locale/tag/simple'
4
6
 
5
7
  module Mrubyc
6
8
  module Test
@@ -12,7 +12,7 @@ module Mrubyc
12
12
 
13
13
  def initialize(type, object, location)
14
14
  @type = type
15
- @klass = object.class
15
+ @klass = object.class == Class ? object : object.class
16
16
  @location = location
17
17
  end
18
18
 
@@ -63,7 +63,7 @@ module Mrubyc
63
63
  def init_main_c
64
64
  config = Mrubyc::Test::Config.read(check: false)
65
65
  puts ' cp test/tmp/main.c'
66
- erb = ERB.new(File.read(File.expand_path('../../../templates/main.c.erb', __FILE__)), nil, '-')
66
+ erb = ERB.new(File.read(File.expand_path('../../../templates/main.c.erb', __FILE__)))
67
67
  File.write(File.join(config['test_tmp_dir'], 'main.c'), erb.result(binding))
68
68
 
69
69
  end
@@ -1,5 +1,5 @@
1
1
  module Mrubyc
2
2
  module Test
3
- VERSION = "0.8.0"
3
+ VERSION = "0.9.0"
4
4
  end
5
5
  end
@@ -22,7 +22,7 @@ class MrubycTestCase
22
22
  description: @information[:description].to_s,
23
23
  message: message,
24
24
  assertion: assertion.to_s,
25
- expected: expected.to_s,
25
+ expected: expected.to_ss,
26
26
  actual: actual.to_ss,
27
27
  error: error
28
28
  }
@@ -7,7 +7,7 @@ class Object
7
7
  elsif self.class.to_s.end_with? "Error"
8
8
  "#<#{self.class}: #{self.message}>"
9
9
  else
10
- self.to_s + ' [' + self.class_name + ']'
10
+ self.inspect + ' [' + self.class_name + ']'
11
11
  end
12
12
  end
13
13
  def class_name
data/lib/mrubyc-test.rb CHANGED
@@ -48,30 +48,23 @@ module Mrubyc::Test
48
48
  puts "cd #{tmp_dir}"
49
49
  puts
50
50
  pwd = Dir.pwd
51
- hal_path = "#{pwd}/#{config['mrubyc_src_dir']}/hal"
52
- hal_bak_path = "#{pwd}/#{config['mrubyc_src_dir']}/~hal"
53
- FileUtils.rm_rf hal_bak_path
54
- FileUtils.mv(hal_path, hal_bak_path) if FileTest.exist?(hal_path)
55
51
  exit_code = 0
56
52
  cc = ENV['CC'].to_s.length > 0 ? ENV['CC'] : "gcc"
57
53
  qemu = ENV['QEMU']
58
- begin
59
- FileUtils.ln_sf "#{pwd}/#{config['test_tmp_dir']}/hal", "#{pwd}/#{config['mrubyc_src_dir']}/hal"
60
- Dir.chdir(tmp_dir) do
61
- [
62
- "#{mrbc_path} -B test test.rb",
63
- "#{mrbc_path} -B models models.rb",
64
- "#{cc} -O0 -g3 -Wall -I #{pwd}/#{config['mrubyc_src_dir']} -static -o test main.c #{pwd}/#{config['mrubyc_src_dir']}/*.c #{pwd}/#{config['mrubyc_src_dir']}/hal/*.c -DMRBC_INT64 -DMAX_SYMBOLS_COUNT=1000 -DMRBC_USE_MATH=1 -DMRBC_USE_HAL_POSIX #{ENV["CFLAGS"]} #{ENV["LDFLAGS"]}",
65
- "#{qemu} ./test"
66
- ].each do |cmd|
67
- puts cmd
68
- puts
69
- exit_code = 1 unless Kernel.system(cmd)
54
+ Dir.chdir(tmp_dir) do
55
+ [
56
+ "#{mrbc_path} -B test test.rb",
57
+ "#{mrbc_path} -B models models.rb",
58
+ "#{cc} -O0 -g3 -Wall -I #{pwd}/#{config['mrubyc_src_dir']} -static -o test main.c #{pwd}/#{config['mrubyc_src_dir']}/*.c #{pwd}/#{config['mrubyc_src_dir']}/hal_posix/*.c -DMRBC_INT64 -DMAX_SYMBOLS_COUNT=1000 -DMRBC_USE_MATH=1 -DMRBC_USE_HAL_POSIX #{ENV["CFLAGS"]} #{ENV["LDFLAGS"]} -Wl,--allow-multiple-definition",
59
+ "#{qemu} ./test"
60
+ ].each do |cmd|
61
+ puts cmd
62
+ puts
63
+ unless Kernel.system(cmd)
64
+ exit_code = 1
65
+ break
70
66
  end
71
67
  end
72
- ensure
73
- FileUtils.rm hal_path
74
- FileUtils.mv(hal_bak_path, hal_path) if FileTest.exist?(hal_bak_path)
75
68
  end
76
69
  return exit_code
77
70
  end
@@ -112,7 +105,7 @@ module Mrubyc::Test
112
105
  eg: /home/hoge/mruby/build/host/bin/mrbc
113
106
  RBENV_VERSION will be ignored if you specify this option.
114
107
  DESC
115
- def test(testfilepath = "test/*.rb")
108
+ def test(testfilepath = "")
116
109
  Mrubyc::Test::Init.init_main_c
117
110
  init_env
118
111
  config = Mrubyc::Test::Config.read
@@ -94,5 +94,8 @@ main(void) {
94
94
  mrbc_define_method(0, mrbc_class_object, "instance_variable_get", c_instance_variable_get);
95
95
  mrbc_load_model(models);
96
96
  mrbc_load_model(test);
97
+ /* test should be a task so that methods like sleep work */
98
+ mrbc_create_task(test, 0);
99
+ mrbc_run();
97
100
  return exit_code;
98
101
  }
@@ -43,7 +43,7 @@ def summerize
43
43
  puts "Pendings:\n"
44
44
  $pendings.each_with_index do |pending, index|
45
45
  puts $colors[:pending]
46
- puts "#{index+1}) " + pending[:class_and_method]
46
+ puts "#{index + 1}) " + pending[:class_and_method]
47
47
  print $colors[:info]
48
48
  puts " # " + pending[:path] + ":" + pending[:line]
49
49
  puts $colors[:reset]
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.8.0
4
+ version: 0.9.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: 2022-07-24 00:00:00.000000000 Z
11
+ date: 2022-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler