]> granicus.if.org Git - php/commitdiff
Fixed a few false positives on gcov for ext/pgsql
authorMatteo Beccati <mbeccati@php.net>
Tue, 30 Aug 2011 14:01:03 +0000 (14:01 +0000)
committerMatteo Beccati <mbeccati@php.net>
Tue, 30 Aug 2011 14:01:03 +0000 (14:01 +0000)
ext/pgsql/tests/09notice.phpt
ext/pgsql/tests/22pg_fetch_object.phpt
ext/pgsql/tests/80_bug32223.phpt
ext/pgsql/tests/80_bug32223b.phpt
ext/pgsql/tests/lcmess.inc [new file with mode: 0644]
ext/pgsql/tests/skipif.inc

index b7611b98c1145c040dce54be44dcb771925d8c60..316706916917f3a15cd04a5b9f6cb91d476c6ce2 100644 (file)
@@ -1,16 +1,25 @@
 --TEST--
 PostgreSQL notice function
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+
+include("skipif.inc");
+
+_skip_lc_messages();
+
+?>
 --INI--
 pgsql.log_notice=1
 pgsql.ignore_notices=0
 --FILE--
 <?php
 include 'config.inc';
+include 'lcmess.inc';
 
 $db = pg_connect($conn_str);
-pg_exec($db, "SET LC_MESSAGES='C';");
+
+_set_lc_messages();
+
 pg_query($db, "BEGIN;");
 pg_query($db, "BEGIN;");
 
index 4f2f5dc1842105d13c17501da0e3afd20050959d..76a3fbeed3355cb7044e00c59adca68b01bf43fe 100755 (executable)
@@ -16,7 +16,7 @@ class test_class {
 
 $db = pg_connect($conn_str);
 
-$sql = "SELECT * FROM $table_name";
+$sql = "SELECT * FROM $table_name WHERE num = 0";
 $result = pg_query($db, $sql) or die('Cannot qeury db');
 $rows = pg_num_rows($result);
 
index b201d320cebd7e728d2ff422644aed7c6b2e46f8..573742c6e4636a289ce270ab421691b7f7def818 100755 (executable)
@@ -3,6 +3,8 @@ Bug #32223 (weird behaviour of pg_last_notice)
 --SKIPIF--
 <?php 
 require_once('skipif.inc');
+
+_skip_lc_messages();
        
 @pg_query($conn, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'");
 $res = @pg_query($conn, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
@@ -17,14 +19,15 @@ if (!$res) die('skip PLPGSQL not available');
 <?php
 
 require_once('config.inc');
+require_once('lcmess.inc');
        
 $dbh = @pg_connect($conn_str);
 if (!$dbh) {
        die ("Could not connect to the server");
 }
-pg_exec($dbh, "SET LC_MESSAGES='C';");
 
-//@pg_query($dbh, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'");
+_set_lc_messages();
+
 $res = pg_query($dbh, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
 begin
         RAISE NOTICE ''11111'';
index 98e472388975a03f034936689214af9bcce0691d..aada3f01ba41db21b469c6b4cec5daa108396e40 100755 (executable)
@@ -3,6 +3,8 @@ Bug #32223 (weird behaviour of pg_last_notice using define)
 --SKIPIF--
 <?php 
 require_once('skipif.inc');
+
+_skip_lc_messages();
        
 @pg_query($conn, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'");
 $res = @pg_query($conn, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
@@ -17,14 +19,15 @@ if (!$res) die('skip PLPGSQL not available');
 <?php
 
 require_once('config.inc');
+require_once('lcmess.inc');
 
 define('dbh', pg_connect($conn_str));
 if (!dbh) {
         die ("Could not connect to the server");
 }
-pg_exec(dbh, "SET LC_MESSAGES='C';");
 
-//@pg_query(dbh, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'");
+_set_lc_messages();
+
 $res = pg_query(dbh, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
 begin
         RAISE NOTICE ''11111'';
diff --git a/ext/pgsql/tests/lcmess.inc b/ext/pgsql/tests/lcmess.inc
new file mode 100644 (file)
index 0000000..6e0ac25
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+function _skip_lc_messages($lc_messages = 'C')
+{
+       if (!_set_lc_messages($lc_messages)) {
+               die("skip Cannot set LC_MESSAGES to '{$lc_messages}'\n");
+       }
+}
+
+function _set_lc_messages($lc_messages = 'C')
+{
+       if (pg_result(pg_query("SHOW LC_MESSAGES"), 0, 0) != $lc_messages) {
+               if (!@pg_exec("SET LC_MESSAGES='{$lc_messages}'")) {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+?>
index 74b27b3ad8e9bd0a05f6046471999fc57a37b06f..7c5153e6f082243d8b995aa1eb96c3fd83e48c62 100644 (file)
@@ -7,6 +7,7 @@
 //   database
 
 include("config.inc");
+include("lcmess.inc");
 
 if (!extension_loaded("pgsql")) {
     die("skip\n");