X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7fb83a3380e62721801a4980c48ba78208c7b2e2..e56ae6aad06c37d5512537047871d7363dd97620:/services/api/Rakefile diff --git a/services/api/Rakefile b/services/api/Rakefile index 223f5ca216..67e4202ba2 100644 --- a/services/api/Rakefile +++ b/services/api/Rakefile @@ -4,10 +4,66 @@ require File.expand_path('../config/application', __FILE__) -begin - ok = PgPower -rescue - abort "Hm, pg_power is missing. Make sure you use 'bundle exec rake ...'" +Server::Application.load_tasks + +namespace :test do + task(:run).clear + # Copied from the definition in Rails 3.2. + # This may need to be updated if we upgrade Rails. + task :run do + errors = %w(test:units test:functionals test:integration test:tasks).collect do |task| + begin + Rake::Task[task].invoke + nil + rescue => e + { :task => task, :exception => e } + end + end.compact + + if errors.any? + puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n") + abort + end + end end -Server::Application.load_tasks +namespace :db do + namespace :structure do + task :dump do + require 'tempfile' + origfnm = File.expand_path('../db/structure.sql', __FILE__) + tmpfnm = Tempfile.new 'structure.sql', File.expand_path('..', origfnm) + begin + tmpfile = File.new tmpfnm, 'w' + origfile = File.new origfnm + origfile.each_line do |line| + if /^SET lock_timeout = 0;/ =~ line + # Avoid edit wars between versions that do/don't write this line. + next + elsif /^COMMENT ON EXTENSION/ =~ line + # Avoid warning message when loading: + # "structure.sql:22: ERROR: must be owner of extension plpgsql" + tmpfile.write "-- " + end + tmpfile.write line + end + origfile.close + tmpfile.close + File.rename tmpfnm, origfnm + tmpfnm = false + ensure + File.unlink tmpfnm if tmpfnm + end + end + end +end + +# Work around Rails3+PostgreSQL9.5 incompatibility (pg_dump used to +# accept -i as a no-op, but now it's not accepted at all). +module Kernel + alias_method :orig_backtick, :` + def `(*args) #`#` sorry, parsers + args[0].sub!(/\Apg_dump -i /, 'pg_dump ') rescue nil + orig_backtick(*args) + end +end