2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 # Add your own tasks in files placed in lib/tasks ending in .rake,
7 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
9 require File.expand_path('../config/application', __FILE__)
10 require 'rake/testtask'
12 Server::Application.load_tasks
16 # Copied from the definition in Rails 3.2.
17 # This may need to be updated if we upgrade Rails.
19 errors = %w(test:units test:functionals test:integration test:tasks).collect do |task|
21 Rake::Task[task].invoke
24 { :task => task, :exception => e }
29 puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n")
36 namespace :structure do
39 origfnm = File.expand_path('../db/structure.sql', __FILE__)
40 tmpfnm = Tempfile.new 'structure.sql', File.expand_path('..', origfnm)
41 copyright_done = false
44 tmpfile = File.new tmpfnm, 'w'
45 origfile = File.new origfnm
46 origfile.each_line do |line|
48 if !/Copyright .* Arvados/.match(line)
49 tmpfile.write "-- Copyright (C) The Arvados Authors. All rights reserved.\n--\n-- SPDX-License-Identifier: AGPL-3.0\n\n"
54 if !started && /^[^-\n]/ !~ line
55 # Ignore the "PostgreSQL database dump" comment block,
56 # which varies from one client version to the next.
61 if /^SET (lock_timeout|idle_in_transaction_session_timeout|row_security) = / =~ line
62 # Avoid edit wars between versions that do/don't write (and can/can't execute) this line.
64 elsif /^COMMENT ON EXTENSION/ =~ line
65 # Avoid warning message when loading:
66 # "structure.sql:22: ERROR: must be owner of extension plpgsql"
73 File.rename tmpfnm, origfnm
76 File.unlink tmpfnm if tmpfnm
82 # Work around Rails3+PostgreSQL9.5 incompatibility (pg_dump used to
83 # accept -i as a no-op, but now it's not accepted at all).
85 alias_method :orig_backtick, :`
86 def `(*args) #`#` sorry, parsers
87 args[0].sub!(/\Apg_dump -i /, 'pg_dump ') rescue nil