diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d2e4601..2f6d613 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,6 +15,9 @@ Please note that this project is released with a [Contributor Code of Conduct](C 0. Build it and make sure the tests pass on your machine: `script/cibuild`. It will run both trilogy and ruby bindings suites in docker environment. To shorten the development loop you can: + + > [!TIP] + > If you haven't already, you will need to create a database named `test`. a) run trilogy tests locally with: `make test` b) run ruby binding tests with `cd contrib/ruby`, `bundle exec rake test`. It's possible to run a test single example by passing a `TESTOPTS` environment variable like so: `TESTOPTS=-n/test_packet_size_greater_than_trilogy_max_packet_len/`. diff --git a/contrib/ruby/Rakefile b/contrib/ruby/Rakefile index 4dd70fd..1e389d0 100644 --- a/contrib/ruby/Rakefile +++ b/contrib/ruby/Rakefile @@ -19,10 +19,25 @@ Rake::TestTask.new do |t| t.test_files = FileList['test/*_test.rb'] t.verbose = true end -task :test => :compile + +task :test => [:compile, "db:clean"] task :default => :test task :console => :compile do sh "ruby -I lib -r trilogy -S irb" end + +namespace :db do + task :create do + mysql_command = "mysql -uroot -e" + %x( #{mysql_command} "create DATABASE IF NOT EXISTS test DEFAULT CHARACTER SET utf8mb4" ) + end + + task :drop do + mysql_command = "mysql -uroot -e" + %x( #{mysql_command} "drop DATABASE IF EXISTS test" ) + end + + task :clean => ["db:drop", "db:create"] +end