|
2 | 2 |
|
3 | 3 | require 'rake/testtask' |
4 | 4 |
|
| 5 | +RUBY_WARNING_FLAGS = ['-w'].freeze |
| 6 | +STRICT_BLOCK_WARNING_FLAGS = RUBY_VERSION >= '3.4' ? ['-W:strict_unused_block'].freeze : [].freeze |
| 7 | + |
5 | 8 | Rake::TestTask.new do |t| |
6 | 9 | t.libs << 'test' |
7 | 10 | t.pattern = 'test/**/*_test.rb' |
| 11 | + t.warning = true |
| 12 | + t.ruby_opts.concat(STRICT_BLOCK_WARNING_FLAGS) |
8 | 13 | end |
9 | 14 |
|
10 | | -task :default => :test |
| 15 | +task :default => :check |
| 16 | + |
| 17 | +desc 'Run syntax and method-visibility checks, then warning-enabled native tests' |
| 18 | +task :check => [:lint, :test] |
| 19 | + |
| 20 | +desc 'Run the syntax and method-visibility checks used by Sequel' |
| 21 | +task :lint => [:check_syntax, :check_visibility] |
| 22 | + |
| 23 | +desc 'Check Ruby syntax with warnings (project files only)' |
| 24 | +task :check_syntax do |
| 25 | + require 'open3' |
| 26 | + files = FileList['lib/**/*.rb', 'test/**/*.rb', 'examples/**/*.rb', 'tasks/**/*.rb', '*.gemspec', 'Gemfile', 'Rakefile'].sort |
| 27 | + files.each do |file| |
| 28 | + stdout, stderr, status = Open3.capture3(RbConfig.ruby, *RUBY_WARNING_FLAGS, *STRICT_BLOCK_WARNING_FLAGS, '-c', file) |
| 29 | + next if status.success? && stderr.empty? |
| 30 | + warn stdout unless status.success? |
| 31 | + warn stderr unless stderr.empty? |
| 32 | + abort "Ruby syntax/warning check failed: #{file}" |
| 33 | + end |
| 34 | + puts "Syntax and warnings checked: #{files.length} project files" |
| 35 | +end |
| 36 | + |
| 37 | +desc 'Check adapter method visibility with Jeremy Evans\' visibility_checker' |
| 38 | +task :check_visibility do |
| 39 | + ruby(*RUBY_WARNING_FLAGS, *STRICT_BLOCK_WARNING_FLAGS, '-Ilib', 'tasks/check_visibility.rb') |
| 40 | +end |
11 | 41 |
|
12 | 42 | desc 'Run Sequel upstream SQLite and integration specs (requires tmp/upstream/sequel)' |
13 | 43 | task :upstream do |
14 | | - ruby 'test/upstream.rb' |
| 44 | + ruby(*RUBY_WARNING_FLAGS, *STRICT_BLOCK_WARNING_FLAGS, 'test/upstream.rb') |
15 | 45 | end |
16 | 46 |
|
17 | 47 | desc 'Run opt-in HTTP/Turso tests using LIBSQL_TEST_URL and LIBSQL_TEST_AUTH_TOKEN' |
18 | 48 | task :remote do |
19 | | - ruby '-Ilib', 'test/remote.rb' |
| 49 | + ruby(*RUBY_WARNING_FLAGS, *STRICT_BLOCK_WARNING_FLAGS, '-Ilib', 'test/remote.rb') |
20 | 50 | end |
21 | 51 |
|
22 | 52 | desc 'Run the native HTTP tests against the local upstream Hrana fixture' |
23 | 53 | task :remote_local do |
24 | 54 | sh({'LIBSQL_TEST_URL' => 'http://localhost:8080', 'LIBSQL_TEST_AUTH_TOKEN' => ''}, |
25 | 55 | 'tmp/hrana-venv/bin/python', 'test/support/hrana_server.py', |
26 | | - RbConfig.ruby, '-Ilib', 'test/remote.rb') |
| 56 | + RbConfig.ruby, *RUBY_WARNING_FLAGS, *STRICT_BLOCK_WARNING_FLAGS, '-Ilib', 'test/remote.rb') |
27 | 57 | end |
0 commit comments