[DRE-commits] [ruby-riddle] 01/04: Run specs during package build.

zeha at debian.org zeha at debian.org
Wed Mar 2 20:49:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

zeha pushed a commit to branch master
in repository ruby-riddle.

commit b3d4e18ec6eb6cf4a1e3681f5e38bcb4c4d2045c
Author: Christian Hofstaedtler <zeha at debian.org>
Date:   Wed Mar 2 21:27:28 2016 +0100

    Run specs during package build.
    
    Requires php, mysql, sphinxsearch to be available during build.
---
 debian/control                      |  2 +-
 debian/patches/spec_helper.rb.patch | 10 ++++++---
 debian/ruby-tests.rake              |  7 +++----
 debian/rules                        |  1 -
 debian/start_mysqld_and_run.sh      | 42 +++++++++++++++++++++++++++++++++++++
 5 files changed, 53 insertions(+), 9 deletions(-)

diff --git a/debian/control b/debian/control
index 2529929..bf8deef 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: ruby
 Priority: optional
 Maintainer: Debian Ruby Extras Maintainers <pkg-ruby-extras-maintainers at lists.alioth.debian.org>
 Uploaders: Andrew Lee (李健秋) <andrew.lee at collabora.co.uk>
-Build-Depends: debhelper (>= 9~), gem2deb, ruby-rspec, rake, ruby-mysql2
+Build-Depends: debhelper (>= 9~), gem2deb, ruby-rspec, rake, ruby-mysql2, mysql-server, sphinxsearch, php7.0-cli
 Standards-Version: 3.9.6
 Vcs-Git: git://anonscm.debian.org/pkg-ruby-extras/ruby-riddle.git
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-ruby-extras/ruby-riddle.git;a=summary
diff --git a/debian/patches/spec_helper.rb.patch b/debian/patches/spec_helper.rb.patch
index f3e8629..f3f1dc6 100644
--- a/debian/patches/spec_helper.rb.patch
+++ b/debian/patches/spec_helper.rb.patch
@@ -1,11 +1,15 @@
---- a/spec/spec_helper.rb
-+++ b/spec/spec_helper.rb
-@@ -1,12 +1,6 @@
+Index: ruby-riddle/spec/spec_helper.rb
+===================================================================
+--- ruby-riddle.orig/spec/spec_helper.rb
++++ ruby-riddle/spec/spec_helper.rb
+@@ -1,12 +1,8 @@
 -require 'rubygems'
 -require 'bundler'
 -
 -$:.unshift File.dirname(__FILE__) + '/../lib'
 -$:.unshift File.dirname(__FILE__) + '/..'
++require 'mysql2'
++require 'fileutils'
  
  Dir['spec/support/**/*.rb'].each { |f| require f }
  
diff --git a/debian/ruby-tests.rake b/debian/ruby-tests.rake
index 99987ae..97df3c8 100644
--- a/debian/ruby-tests.rake
+++ b/debian/ruby-tests.rake
@@ -1,7 +1,6 @@
 require 'rspec/core/rake_task'
 
-RSpec::Core::RakeTask.new(:spec) do |spec|
-  spec.pattern = './spec/*_spec.rb'
+task :default do
+  ruby = RbConfig::CONFIG['ruby_install_name']
+  sh "./debian/start_mysqld_and_run.sh #{ruby} -S rspec"
 end
-
-task :default => :spec
diff --git a/debian/rules b/debian/rules
index be53252..1990c52 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,7 +7,6 @@
 # Uncomment to ignore some test failures (but the tests will run anyway).
 # Valid values:
 #export DH_RUBY_IGNORE_TESTS=ruby2.1 require-rubygems
-export DH_RUBY_IGNORE_TESTS=ruby2.2
 #
 # If you need to specify the .gemspec (eg there is more than one)
 #export DH_RUBY_GEMSPEC=gem.gemspec
diff --git a/debian/start_mysqld_and_run.sh b/debian/start_mysqld_and_run.sh
new file mode 100755
index 0000000..295e70a
--- /dev/null
+++ b/debian/start_mysqld_and_run.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# start_mysqld_and_auto_install.sh - starts an instance of mysqld before
+# auto_installing and running do_mysql's test suite. It is inspired by
+# debian/test_mysql.sh from libdbi-drivers source package.
+
+
+
+set -e
+
+MYTEMP_DIR=`mktemp -d`
+ME=`whoami`
+
+export MYSQL_UNIX_PORT=${MYTEMP_DIR}/mysql.sock
+DO_MYSQL_USER=root
+DO_MYSQL_PASS=
+DO_MYSQL_DBNAME=test
+DO_MYSQL_DATABASE=/${DO_MYSQL_DBNAME}
+
+mysql_install_db --no-defaults --datadir=${MYTEMP_DIR} --force --skip-name-resolve --user=${DO_MYSQL_USER}
+/usr/sbin/mysqld --no-defaults --user=${DO_MYSQL_USER} --socket=${MYSQL_UNIX_PORT} --datadir=${MYTEMP_DIR} --skip-networking &
+echo -n pinging mysqld.
+attempts=0
+while ! /usr/bin/mysqladmin --socket=${MYSQL_UNIX_PORT} ping ; do
+  sleep 3
+  attempts=$((attempts+1))
+  if [ ${attempts} -gt 10 ] ; then
+    echo "skipping test, mysql server could not be contacted after 30 seconds"
+    exit 0
+  fi
+done
+
+cleanup() {
+  /usr/bin/mysqladmin --user=${DO_MYSQL_USER} --socket=${MYSQL_UNIX_PORT} shutdown
+  rm -rf ${MYTEMP_DIR}
+}
+trap cleanup INT EXIT TERM
+
+# database `test` is already created by default
+mysql --user=${DO_MYSQL_USER} --socket=${MYSQL_UNIX_PORT} --execute "GRANT ALL PRIVILEGES ON ${DO_MYSQL_DBNAME}.* TO '${DO_MYSQL_USER}'@'localhost' IDENTIFIED BY '${DO_MYSQL_PASS}';"
+
+"$@"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-riddle.git



More information about the Pkg-ruby-extras-commits mailing list