From 01ad574b3018e85e41fdfd917e31363219ee9828 Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Fri, 8 Dec 2017 12:06:50 +0100 Subject: [PATCH] Fix failed tests for PostgreSQL-10. --- ....21.0-adjust-tests-for-postgresql-10.patch | 57 +++++++++++++++++++ rubygem-pg.spec | 27 ++++++--- 2 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 rubygem-pg-0.21.0-adjust-tests-for-postgresql-10.patch diff --git a/rubygem-pg-0.21.0-adjust-tests-for-postgresql-10.patch b/rubygem-pg-0.21.0-adjust-tests-for-postgresql-10.patch new file mode 100644 index 0000000..d9f488d --- /dev/null +++ b/rubygem-pg-0.21.0-adjust-tests-for-postgresql-10.patch @@ -0,0 +1,57 @@ +From 55ca6dd8c1e0925f617b8f9e9042cbea01cf0eb8 Mon Sep 17 00:00:00 2001 +From: Lars Kanis +Date: Mon, 23 Oct 2017 13:02:45 +0200 +Subject: [PATCH] Adjust tests for PostgreSQL-10 + +--- + spec/helpers.rb | 2 +- + spec/pg/connection_spec.rb | 13 +++++++++---- + 2 files changed, 10 insertions(+), 5 deletions(-) + +diff --git a/spec/helpers.rb b/spec/helpers.rb +index d13df5e..e9856de 100755 +--- a/spec/helpers.rb ++++ b/spec/helpers.rb +@@ -251,7 +251,7 @@ module PG::TestingHelpers + + def check_for_lingering_connections( conn ) + conn.exec( "SELECT * FROM pg_stat_activity" ) do |res| +- conns = res.find_all {|row| row['pid'].to_i != conn.backend_pid } ++ conns = res.find_all {|row| row['pid'].to_i != conn.backend_pid && ["client backend", nil].include?(row["backend_type"]) } + unless conns.empty? + puts "Lingering connections remain:" + conns.each do |row| +diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb +index d055673..0924ca4 100755 +--- a/spec/pg/connection_spec.rb ++++ b/spec/pg/connection_spec.rb +@@ -219,7 +219,7 @@ describe PG::Connection do + described_class.connect(@conninfo).finish + sleep 0.5 + res = @conn.exec(%[SELECT COUNT(*) AS n FROM pg_stat_activity +- WHERE usename IS NOT NULL]) ++ WHERE usename IS NOT NULL AND application_name != '']) + # there's still the global @conn, but should be no more + expect( res[0]['n'] ).to eq( '1' ) + end +@@ -1524,9 +1524,14 @@ describe PG::Connection do + end + + it "shouldn't type map params unless requested" do +- expect{ +- @conn.exec_params( "SELECT $1", [5] ) +- }.to raise_error(PG::IndeterminateDatatype) ++ if @conn.server_version < 100000 ++ expect{ ++ @conn.exec_params( "SELECT $1", [5] ) ++ }.to raise_error(PG::IndeterminateDatatype) ++ else ++ # PostgreSQL-10 maps to TEXT type (OID 25) ++ expect( @conn.exec_params( "SELECT $1", [5] ).ftype(0)).to eq(25) ++ end + end + + it "should raise an error on invalid encoder to put_copy_data" do +-- +2.14.3 + diff --git a/rubygem-pg.spec b/rubygem-pg.spec index ffdb46e..071c27f 100644 --- a/rubygem-pg.spec +++ b/rubygem-pg.spec @@ -3,7 +3,7 @@ Name: rubygem-%{gem_name} Version: 0.21.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A Ruby interface to the PostgreSQL RDBMS # Upstream license clarification (https://bitbucket.org/ged/ruby-pg/issue/72/) # @@ -16,6 +16,9 @@ Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem # Disable RPATH. # https://bitbucket.org/ged/ruby-pg/issue/183 Patch0: rubygem-pg-0.17.1-remove-rpath.patch +# Fix tests for PostgreSQL-10. +# https://github.com/ged/ruby-pg/commit/fe24a71 +Patch1: rubygem-pg-0.21.0-adjust-tests-for-postgresql-10.patch BuildRequires: ruby(release) BuildRequires: rubygems-devel BuildRequires: ruby-devel @@ -78,16 +81,23 @@ for file in `find %{buildroot}%{gem_libdir} -type f -name "*.rb"`; do done # Fix spec shebangs. -# https://bitbucket.org/ged/ruby-pg/issue/74/ -for file in `find %{buildroot}%{gem_instdir}/spec -type f ! -perm /a+x -name "*.rb"`; do - [ ! -z "`head -n 1 $file | grep \"^#!/\"`" ] \ - && sed -i -e 's/^#!\/usr\/bin\/env spec/#!\/usr\/bin\/env rspec/' $file \ - && chmod -v 755 $file +# https://bitbucket.org/ged/ruby-pg/issues/269/ +for file in `find %{buildroot}%{gem_instdir}/spec -type f -name "*.rb"`; do + if [ ! -z "`head -n 1 $file | grep \"^#!/\"`" ]; then + sed -i '/^#!\/usr\/bin\/env/ d' $file + chmod -v 644 $file + fi done %check pushd .%{gem_instdir} -rspec -I$(dirs +1)%{gem_extdir_mri} spec +cat "%{PATCH1}" | patch -p1 +# Set LANG to prevent encoding warnings. See spec/pg/connection_spec.rb +# test case: "receives properly encoded messages in the notice callbacks". +# Set --verbose to show detail log by $VERBOSE. +# See https://github.com/ged/ruby-pg/blob/master/spec/helpers.rb $VERBOSE +LANG=en_US.UTF-8 ruby -S --verbose \ + rspec -I$(dirs +1)%{gem_extdir_mri} -f d spec popd %files @@ -115,6 +125,9 @@ popd %{gem_instdir}/spec %changelog +* Fri Dec 08 2017 Jun Aruga - 0.21.0-2 +- Fix failed tests for PostgreSQL-10. + * Thu Aug 17 2017 Vít Ondruch - 0.21.0-1 - Update to pg 1.21.0.