11# frozen_string_literal: true
2+ # typed: true
3+
4+ require "sorbet-runtime"
5+ T . bind ( self , T . all ( Rake ::DSL , Object ) )
6+ extend T ::Sig
27
38$jobs = ENV [ "JOBS" ] . nil? ? 1 : ENV [ "JOBS" ] . to_i
49Rake . application . options . thread_pool_size = $jobs
2328
2429directory "#{ $root} /.stamps"
2530
31+ sig { params ( config : T . any ( String , Pathname ) ) . returns ( ConfiguredArchitecture ) }
2632def cfg_arch_for ( config )
27- raise ArgumentError , "excpecting String or Pathname" unless config . is_a? ( String ) || config . is_a? ( Pathname )
2833 config = config . to_s
2934
3035 $cfg_archs ||= { }
@@ -146,26 +151,28 @@ namespace :serve do
146151 end
147152end
148153
154+ sig { params ( test_files : T ::Array [ String ] ) . returns ( String ) }
155+ def make_test_cmd ( test_files )
156+ "-Ilib:test -w -e 'require \" minitest/autorun\" ; #{ test_files . map { |f | "require \" #{ f } \" " } . join ( "; " ) } ' --"
157+ end
158+
149159namespace :test do
150160 # "Run the IDL compiler test suite"
151161 task :idl_compiler do
152- t = Minitest ::TestTask . new ( :lib_test )
153- t . test_globs = [ "#{ $root} /lib/idl/tests/test_*.rb" ]
154- t . process_env
155- ruby t . make_test_cmd
162+ test_files = Dir [ "#{ $root} /lib/idl/tests/test_*.rb" ]
163+ ruby make_test_cmd ( test_files )
156164 end
157165
158166 # "Run the Ruby library test suite"
159167 task :lib do
160- t = Minitest ::TestTask . new ( :lib_test )
161- t . test_globs = [ "#{ $root} /lib/test/test_*.rb" ]
162- t . process_env
163- ruby t . make_test_cmd
168+ test_files = Dir [ "#{ $root} /lib/test/test_*.rb" ]
169+
170+ ruby make_test_cmd ( test_files )
164171 end
165172
166173 desc "Type-check the Ruby library"
167174 task :sorbet do
168- sh "srb tc --no-config @.sorbet-config "
175+ sh "srb tc"
169176 end
170177end
171178
@@ -187,13 +194,13 @@ namespace :test do
187194
188195 cfg_arch = cfg_arch_for ( "_" )
189196 insts = cfg_arch . instructions
190- failed = false
197+ failed = T . let ( false , T :: Boolean )
191198 insts . each_with_index do |inst , idx |
192199 [ 32 , 64 ] . each do |xlen |
193200 next unless inst . defined_in_base? ( xlen )
194201
195202 ( idx ...insts . size ) . each do |other_idx |
196- other_inst = insts [ other_idx ]
203+ other_inst = T . must ( insts [ other_idx ] )
197204 next unless other_inst . defined_in_base? ( xlen )
198205 next if other_inst == inst
199206
@@ -215,13 +222,13 @@ namespace :test do
215222
216223 cfg_arch = cfg_arch_for ( "_" )
217224 csrs = cfg_arch . csrs
218- failed = false
225+ failed = T . let ( false , T :: Boolean )
219226 csrs . each_with_index do |csr , idx |
220227 [ 32 , 64 ] . each do |xlen |
221228 next unless csr . defined_in_base? ( xlen )
222229
223230 ( idx ...csrs . size ) . each do |other_idx |
224- other_csr = csrs [ other_idx ]
231+ other_csr = T . must ( csrs [ other_idx ] )
225232 next unless other_csr . defined_in_base? ( xlen )
226233 next if other_csr == csr
227234
@@ -266,7 +273,6 @@ def insert_warning(str, from)
266273 first_line = lines . shift
267274 lines . unshift ( first_line , "\n # WARNING: This file is auto-generated from #{ Pathname . new ( from ) . relative_path_from ( $root) } " ) . join ( "" )
268275end
269- private :insert_warning
270276
271277( 3 ..31 ) . each do |hpm_num |
272278 file "#{ $root} /arch/csr/Zihpm/mhpmcounter#{ hpm_num } .yaml" => [
0 commit comments