From ca10c362c622c1d9a6d5e61d515797e519e47a57 Mon Sep 17 00:00:00 2001 From: HASUMI Hitoshi Date: Thu, 22 Dec 2022 20:15:33 +0900 Subject: [PATCH] Restore mrubyc-test && move steep check to lib/picoruby --- Gemfile | 7 +- Gemfile.lock | 76 +------------------ Rakefile | 67 +++++----------- Steepfile | 18 ----- lib/picoruby | 2 +- sig/machine.rbs | 6 -- sig/object.rbs | 25 ------ sig/pico_ruby_vm.rbs | 3 - sig/usb.rbs | 12 --- src/ruby/Mrubycfile | 6 -- test/Mrubycfile | 6 ++ {src/ruby => test}/Rakefile | 0 test/models/_require.rb | 2 + test/models/consumer_key.rb | 1 + test/models/debounce.rb | 1 + test/models/float.rb | 1 + test/models/joystick.rb | 1 + test/models/keyboard.rb | 1 + test/models/mml.rb | 1 + test/models/rgb.rb | 1 + test/models/rotary_encoder.rb | 1 + test/models/sounder.rb | 1 + test/models/usb.rb | 2 + test/models/via.rb | 1 + .../ruby/test => test/tests}/keyboard_test.rb | 12 +-- {src/ruby/test => test/tests}/mml_test.rb | 0 {src/ruby/test => test/tests}/via_test.rb | 0 {src/ruby/test => test}/tmp/.gitignore | 0 28 files changed, 49 insertions(+), 205 deletions(-) delete mode 100644 Steepfile delete mode 100644 sig/machine.rbs delete mode 100644 sig/object.rbs delete mode 100644 sig/pico_ruby_vm.rbs delete mode 100644 sig/usb.rbs delete mode 100644 src/ruby/Mrubycfile create mode 100644 test/Mrubycfile rename {src/ruby => test}/Rakefile (100%) create mode 100644 test/models/_require.rb create mode 120000 test/models/consumer_key.rb create mode 120000 test/models/debounce.rb create mode 120000 test/models/float.rb create mode 120000 test/models/joystick.rb create mode 120000 test/models/keyboard.rb create mode 120000 test/models/mml.rb create mode 120000 test/models/rgb.rb create mode 120000 test/models/rotary_encoder.rb create mode 120000 test/models/sounder.rb create mode 100644 test/models/usb.rb create mode 120000 test/models/via.rb rename {src/ruby/test => test/tests}/keyboard_test.rb (96%) rename {src/ruby/test => test/tests}/mml_test.rb (100%) rename {src/ruby/test => test/tests}/via_test.rb (100%) rename {src/ruby/test => test}/tmp/.gitignore (100%) diff --git a/Gemfile b/Gemfile index bde6b929..9373f966 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,4 @@ source 'https://rubygems.org' gem 'rake' -gem 'steep' -gem 'typeprof' -gem "rbs" -gem "mrubyc-test", "0.8.1" -gem "guard" -gem "guard-process" +gem "mrubyc-test", ">= 0.9.0" diff --git a/Gemfile.lock b/Gemfile.lock index c820c5d0..7252260a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,98 +6,26 @@ GEM i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - ast (2.4.2) - coderay (1.1.3) concurrent-ruby (1.1.10) - csv (3.2.6) - ffi (1.15.5) - fileutils (1.7.0) - formatador (1.1.0) - guard (2.18.0) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - lumberjack (>= 1.0.12, < 2.0) - nenv (~> 0.1) - notiffany (~> 0.0) - pry (>= 0.13.0) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-process (1.2.1) - guard-compat (~> 1.2, >= 1.2.1) - spoon (~> 0.0.1) i18n (1.12.0) concurrent-ruby (~> 1.0) - json (2.6.3) - language_server-protocol (3.17.0.2) - listen (3.7.1) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - logger (1.5.3) - lumberjack (1.2.8) - method_source (1.0.0) minitest (5.16.3) - mrubyc-test (0.8.1) + mrubyc-test (0.9.0) activesupport (~> 7.0) rufo (~> 0.12) thor (~> 1.2) - nenv (0.3.0) - notiffany (0.1.3) - nenv (~> 0.1) - shellany (~> 0.0) - parallel (1.22.1) - parser (3.1.3.0) - ast (~> 2.4.1) - pry (0.14.1) - coderay (~> 1.1) - method_source (~> 1.0) - rainbow (3.1.1) rake (13.0.6) - rb-fsevent (0.11.2) - rb-inotify (0.10.1) - ffi (~> 1.0) - rbs (2.8.1) rufo (0.13.0) - securerandom (0.2.2) - shellany (0.0.1) - spoon (0.0.6) - ffi - steep (1.3.0) - activesupport (>= 5.1) - csv (>= 3.0.9) - fileutils (>= 1.1.0) - json (>= 2.1.0) - language_server-protocol (>= 3.15, < 4.0) - listen (~> 3.0) - logger (>= 1.3.0) - parallel (>= 1.0.0) - parser (>= 3.1) - rainbow (>= 2.2.2, < 4.0) - rbs (>= 2.8.0) - securerandom (>= 0.1) - strscan (>= 1.0.0) - terminal-table (>= 2, < 4) - strscan (3.0.5) - terminal-table (3.0.2) - unicode-display_width (>= 1.1.1, < 3) thor (1.2.1) - typeprof (0.21.3) - rbs (>= 1.8.1) tzinfo (2.0.5) concurrent-ruby (~> 1.0) - unicode-display_width (2.3.0) PLATFORMS x86_64-linux DEPENDENCIES - guard - guard-process - mrubyc-test (= 0.8.1) + mrubyc-test (>= 0.9.0) rake - rbs - steep - typeprof BUNDLED WITH 2.3.26 diff --git a/Rakefile b/Rakefile index b4af3f65..2d070cef 100644 --- a/Rakefile +++ b/Rakefile @@ -1,14 +1,14 @@ require "fileutils" -MRUBY_CONFIG = "prk_firmware" +MRUBY_CONFIG = "prk_firmware-cortex-m0plus" task :default => :all desc "build production" -task :all => [:check_setup, :libmruby, :test_all, :cmake_production, :build] +task :all => [:libmruby, :test, :cmake_production, :build] desc "build debug (you may need to rake clean before this)" -task :debug => [:check_setup, :libmruby, :test_all, :cmake_debug, :build] +task :debug => [:libmruby, :test, :cmake_debug, :build] file "lib/picoruby" do sh "git submodule update --init --recursive" @@ -16,12 +16,14 @@ end task :libmruby_no_msc => "lib/picoruby" do FileUtils.cd "lib/picoruby" do + sh "rake test" sh "CFLAGS='-DPRK_NO_MSC=1' MRUBY_CONFIG=#{MRUBY_CONFIG} rake" end end task :libmruby => "lib/picoruby" do FileUtils.cd "lib/picoruby" do + sh "rake test" sh "MRUBY_CONFIG=#{MRUBY_CONFIG} rake" end end @@ -40,7 +42,7 @@ task :build do end desc "build PRK Firmware inclusive of keymap.rb (without mass storage)" -task :build_with_keymap, ['keyboard_name'] => [:check_setup, :libmruby_no_msc, :test_all] do |_t, args| +task :build_with_keymap, ['keyboard_name'] => [:libmruby_no_msc, :test] do |_t, args| unless args.keyboard_name raise "Argument `keyboard_name` missing.\nUsage: rake build_with_keymap[prk_meishi2]" end @@ -60,54 +62,23 @@ task :clean_with_keymap , ['keyboard_name'] do |_t, args| end -desc "run :steep_check and :mrubyc_test" -task :test_all => %i(steep_check mrubyc_test) - -desc "run steep check for ruby program" -task :steep_check do - sh "bundle exec steep check" -end - -task :setup do - sh "git submodule update" - FileUtils.cd "lib/picoruby" do - sh "rake" - end - FileUtils.cd "src/ruby" do - sh "bundle install" - end - FileUtils.cd "src/ruby/test/tmp" do - FileUtils.ln_sf "../../../../lib/picoruby/mrbgems/picoruby-mrubyc/repos/mrubyc/src/hal_posix", "hal" - end -end +desc "run :mrubyc_test" +task :test => %i(mrubyc_test) desc "run unit test for ruby program" -task :mrubyc_test do -# FileUtils.cd "src/ruby" do -# sh "rake test" -# end +task :mrubyc_test => :setup_test do + sh %q(CFLAGS=-DMAX_SYMBOLS_COUNT=1000 MRUBYCFILE=test/Mrubycfile bundle exec mrubyc-test) end -desc "check whether you need to setup" -task :check_setup do - count = 0 - begin - FileUtils.cd "src/ruby" do - sh "bundle exec steep -h > /dev/null 2>&1", verbose: false - sh "bundle exec mrubyc-test -h > /dev/null 2>&1", verbose: false - sh "ls test/tmp/hal/ > /dev/null 2>&1", verbose: false - end - rescue => e - if 0 == count - count += 1 - puts "You may need `rake setup`, let me try once" - Rake::Task['setup'].invoke - Rake::Task['symlinks'].invoke - retry - else - puts e.message - exit 1 +task :setup_test do + FileUtils.cd "test/models" do + Dir.glob("../../lib/picoruby/mrbgems/picoruby-prk-*").each do |dir| + Dir.glob("#{dir}/mrblib/*.rb").each do |model| + FileUtils.ln_sf model, File.basename(model) + end end + FileUtils.ln_sf "../../lib/picoruby/mrbgems/picoruby-float-ext/mrblib/float.rb", "float.rb" + FileUtils.ln_sf "../../lib/picoruby/mrbgems/picoruby-music-macro-language/mrblib/mml.rb", "mml.rb" end end @@ -149,7 +120,7 @@ task :guard do end # Add a new tag then push it -task :release => :test_all do +task :release => :test do git_status = `git status` branch = git_status.split("\n")[0].match(/\AOn branch (.+)\z/)[1] if branch != "master" diff --git a/Steepfile b/Steepfile deleted file mode 100644 index 29ee52de..00000000 --- a/Steepfile +++ /dev/null @@ -1,18 +0,0 @@ -target :lib do - library "io-console" - - signature "sig" - Dir.glob("lib/picoruby/mrbgems/**/sig/*.rbs").each { |rb| signature rb } - - check "mrblib" - Dir.glob([ - "lib/picoruby/mrbgems/**/mrblib/*.rb", - "lib/picoruby/mrbgems/**/task/*.rb" - ]).each { |rb| check rb } - - ignore "lib/picoruby/mrbgems/picoruby-mrubyc/repos/mrubyc/mrblib/*.rb" - ignore "lib/picoruby/mrbgems/picoruby-vfs/mrblib/file.rb" - ignore "lib/picoruby/mrbgems/picoruby-vfs/mrblib/dir.rb" - ignore "lib/picoruby/mrbgems/picoruby-shell/mrblib/0_out_of_steep.rb" - ignore "mrblib/object-ext.rb" -end diff --git a/lib/picoruby b/lib/picoruby index 7b0bfd22..1c06de2f 160000 --- a/lib/picoruby +++ b/lib/picoruby @@ -1 +1 @@ -Subproject commit 7b0bfd22b298abb6aece4a3766c5976966e0ab66 +Subproject commit 1c06de2f07b3d296fb065e17b93c3b1199ef1fdd diff --git a/sig/machine.rbs b/sig/machine.rbs deleted file mode 100644 index ce085e7b..00000000 --- a/sig/machine.rbs +++ /dev/null @@ -1,6 +0,0 @@ -class Machine - def self.reset_usb_boot: () -> void - def self.srand: (Integer) -> void - def self.rand: () -> Integer - def self.board_millis: () -> Integer -end diff --git a/sig/object.rbs b/sig/object.rbs deleted file mode 100644 index 9342d8a4..00000000 --- a/sig/object.rbs +++ /dev/null @@ -1,25 +0,0 @@ -class Object - PRK_DESCRIPTION: String - - # mrbc - def relinquish : -> bool - def sleep_ms : (Integer) -> void - def suspend_task : () -> void - def sandbox_state : () -> Integer - def sandbox_result : () -> untyped - def sandbox_picorbc: (String) -> bool - def sandbox_resume: () -> bool - - # Raspi - def gpio_init : (Integer) -> void - def gpio_set_dir : (Integer, Integer) -> void - def gpio_pull_up : (Integer) -> void - def gpio_put : (Integer, Integer) -> void - def gpio_get : (Integer) -> bool - def write_file_internal : (String, String) -> void - def find_file : (String) -> ( [Integer, Integer] | nil ) - def read_file : (Integer, Integer) -> String - - # PRK - def required? : (String) -> bool -end diff --git a/sig/pico_ruby_vm.rbs b/sig/pico_ruby_vm.rbs deleted file mode 100644 index a54f4ee0..00000000 --- a/sig/pico_ruby_vm.rbs +++ /dev/null @@ -1,3 +0,0 @@ -class PicoRubyVM - def self.alloc_stats: () -> Hash[Symbol, Integer] -end diff --git a/sig/usb.rbs b/sig/usb.rbs deleted file mode 100644 index 050bdf60..00000000 --- a/sig/usb.rbs +++ /dev/null @@ -1,12 +0,0 @@ -class USB - def self.report_raw_hid : (Array[Integer]) -> void - def self.raw_hid_report_received?: -> bool - def self.get_last_received_raw_hid_report: -> Array[Integer] - def self.hid_task : (Integer, String, Integer, Integer, Integer) -> void - def self.tud_mounted? : () -> bool - def self.tud_task : -> void - def self.output_report_changed: () { (Integer) -> void } -> void - def self.start_observing_output_report: () -> void - def self.stop_observing_output_report: () -> void - def self.output_report: () -> Integer -end diff --git a/src/ruby/Mrubycfile b/src/ruby/Mrubycfile deleted file mode 100644 index 1dd3978a..00000000 --- a/src/ruby/Mrubycfile +++ /dev/null @@ -1,6 +0,0 @@ ---- -test_dir: test -test_tmp_dir: test/tmp -mrubyc_src_dir: ../../lib/picoruby/mrbgems/picoruby-mrubyc/repos/mrubyc/src -mruby_lib_dir: app -mrbc_path: ../../../../lib/picoruby/bin/picorbc # Relative path from test/tmp/ diff --git a/test/Mrubycfile b/test/Mrubycfile new file mode 100644 index 00000000..2fb28aab --- /dev/null +++ b/test/Mrubycfile @@ -0,0 +1,6 @@ +--- +test_dir: tests +test_tmp_dir: tmp +mrubyc_src_dir: ../lib/picoruby/mrbgems/picoruby-mrubyc/repos/mrubyc/src +mruby_lib_dir: ./ +mrbc_path: ../../lib/picoruby/bin/picorbc # Relative path from test/tmp/ diff --git a/src/ruby/Rakefile b/test/Rakefile similarity index 100% rename from src/ruby/Rakefile rename to test/Rakefile diff --git a/test/models/_require.rb b/test/models/_require.rb new file mode 100644 index 00000000..de1fb4f3 --- /dev/null +++ b/test/models/_require.rb @@ -0,0 +1,2 @@ +def require(name) +end diff --git a/test/models/consumer_key.rb b/test/models/consumer_key.rb new file mode 120000 index 00000000..17e0e899 --- /dev/null +++ b/test/models/consumer_key.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-prk-consumer_key/mrblib/consumer_key.rb \ No newline at end of file diff --git a/test/models/debounce.rb b/test/models/debounce.rb new file mode 120000 index 00000000..9bb7906d --- /dev/null +++ b/test/models/debounce.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-prk-debounce/mrblib/debounce.rb \ No newline at end of file diff --git a/test/models/float.rb b/test/models/float.rb new file mode 120000 index 00000000..90714ee6 --- /dev/null +++ b/test/models/float.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-float-ext/mrblib/float.rb \ No newline at end of file diff --git a/test/models/joystick.rb b/test/models/joystick.rb new file mode 120000 index 00000000..64d8754d --- /dev/null +++ b/test/models/joystick.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-prk-joystick/mrblib/joystick.rb \ No newline at end of file diff --git a/test/models/keyboard.rb b/test/models/keyboard.rb new file mode 120000 index 00000000..8775c79d --- /dev/null +++ b/test/models/keyboard.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-prk-keyboard/mrblib/keyboard.rb \ No newline at end of file diff --git a/test/models/mml.rb b/test/models/mml.rb new file mode 120000 index 00000000..1f67f998 --- /dev/null +++ b/test/models/mml.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-music-macro-language/mrblib/mml.rb \ No newline at end of file diff --git a/test/models/rgb.rb b/test/models/rgb.rb new file mode 120000 index 00000000..fb6d837a --- /dev/null +++ b/test/models/rgb.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-prk-rgb/mrblib/rgb.rb \ No newline at end of file diff --git a/test/models/rotary_encoder.rb b/test/models/rotary_encoder.rb new file mode 120000 index 00000000..e6d59718 --- /dev/null +++ b/test/models/rotary_encoder.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-prk-rotary_encoder/mrblib/rotary_encoder.rb \ No newline at end of file diff --git a/test/models/sounder.rb b/test/models/sounder.rb new file mode 120000 index 00000000..e020f6f6 --- /dev/null +++ b/test/models/sounder.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-prk-sounder/mrblib/sounder.rb \ No newline at end of file diff --git a/test/models/usb.rb b/test/models/usb.rb new file mode 100644 index 00000000..e0622b45 --- /dev/null +++ b/test/models/usb.rb @@ -0,0 +1,2 @@ +class USB +end diff --git a/test/models/via.rb b/test/models/via.rb new file mode 120000 index 00000000..24c02ae8 --- /dev/null +++ b/test/models/via.rb @@ -0,0 +1 @@ +../../lib/picoruby/mrbgems/picoruby-prk-via/mrblib/via.rb \ No newline at end of file diff --git a/src/ruby/test/keyboard_test.rb b/test/tests/keyboard_test.rb similarity index 96% rename from src/ruby/test/keyboard_test.rb rename to test/tests/keyboard_test.rb index 0833d90e..1fd2fcde 100644 --- a/src/ruby/test/keyboard_test.rb +++ b/test/tests/keyboard_test.rb @@ -207,12 +207,12 @@ def lower_layer assert_equal :raise, @kbd.instance_variable_get("@locked_layer") end - description "@ruby_mode should switch" - def ruby_mode - assert_not_equal true, @kbd.instance_variable_get("@ruby_mode") - @kbd.ruby - assert_equal true, @kbd.instance_variable_get("@ruby_mode") - end +# description "@ruby_mode should switch" +# def ruby_mode +# assert_not_equal true, @kbd.instance_variable_get("@ruby_mode") +# @kbd.ruby +# assert_equal true, @kbd.instance_variable_get("@ruby_mode") +# end description "raise an error" def raise_error_case diff --git a/src/ruby/test/mml_test.rb b/test/tests/mml_test.rb similarity index 100% rename from src/ruby/test/mml_test.rb rename to test/tests/mml_test.rb diff --git a/src/ruby/test/via_test.rb b/test/tests/via_test.rb similarity index 100% rename from src/ruby/test/via_test.rb rename to test/tests/via_test.rb diff --git a/src/ruby/test/tmp/.gitignore b/test/tmp/.gitignore similarity index 100% rename from src/ruby/test/tmp/.gitignore rename to test/tmp/.gitignore