Skip to content

Commit 46f3bea

Browse files
committed
[test] patch around JRuby 1.7 incompat with system(pg_dump) on AR 4.2
1 parent 15e87a7 commit 46f3bea

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/db/postgresql/rake_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,19 @@ def psql(args)
140140
`#{PSQL_EXE} #{args}`
141141
end
142142

143+
if ActiveRecord::VERSION::STRING.start_with?('4.2') && JRUBY_VERSION.start_with?('1.7')
144+
warn "NOTE: patching structure_dump due on JRuby #{JRUBY_VERSION}"
145+
# NOTE: a hack around structure_dump failing due system(cmd, *args) on 1.7 (not going to get fixed)
146+
# RuntimeError: failed to execute:
147+
# pg_dump -s -x -O -f db/structure.sql test_rake_db
148+
require 'active_record/tasks/postgresql_database_tasks.rb'
149+
ActiveRecord::Tasks::PostgreSQLDatabaseTasks.module_eval do
150+
def run_cmd(cmd, args, action)
151+
# fail run_cmd_error(cmd, args, action) unless Kernel.system(cmd, *args)
152+
cmd_full = "#{cmd} #{args.map { |arg| Shellwords.escape(arg) }.join(' ')}"
153+
fail run_cmd_error(cmd, args, action) unless Kernel.system(cmd_full)
154+
end
155+
end
156+
end
157+
143158
end

0 commit comments

Comments
 (0)