From dd567a3537fc9571f3c5dd53f3058ebed64327d5 Mon Sep 17 00:00:00 2001
From: esha <shadrin.e@gmail.com>
Date: Wed, 19 Mar 2014 15:04:09 +0400
Subject: [PATCH] Fixed sql(common, pg, mysql) search for modules

purpose: OOS-build tests fail
---
 test/module/net_sql.common.result   |  2 +-
 test/module/net_sql.common.test.lua |  2 +-
 test/module/net_sql.mysql.result    | 16 +++++++++-------
 test/module/net_sql.mysql.skipcond  |  7 +++++--
 test/module/net_sql.mysql.test.lua  |  4 +++-
 test/module/net_sql.pg.result       | 15 +++++++++------
 test/module/net_sql.pg.skipcond     |  7 +++++--
 test/module/net_sql.pg.test.lua     |  4 +++-
 test/test-run.py                    | 11 +++--------
 9 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/test/module/net_sql.common.result b/test/module/net_sql.common.result
index 2ac6a13cf1..fcb0f13763 100644
--- a/test/module/net_sql.common.result
+++ b/test/module/net_sql.common.result
@@ -1,4 +1,4 @@
-package.path  = "../../src/module/sql/?.lua"
+package.path  = os.getenv("TARANTOOL_SRC_DIR").."/src/module/sql/?.lua"
 ---
 ...
 package.cpath  = "?.so"
diff --git a/test/module/net_sql.common.test.lua b/test/module/net_sql.common.test.lua
index 6354cdaf68..8a730b54ee 100644
--- a/test/module/net_sql.common.test.lua
+++ b/test/module/net_sql.common.test.lua
@@ -1,4 +1,4 @@
-package.path  = "../../src/module/sql/?.lua"
+package.path  = os.getenv("TARANTOOL_SRC_DIR").."/src/module/sql/?.lua"
 package.cpath  = "?.so"
 
 require("sql")
diff --git a/test/module/net_sql.mysql.result b/test/module/net_sql.mysql.result
index c19dd46de6..046e06737c 100644
--- a/test/module/net_sql.mysql.result
+++ b/test/module/net_sql.mysql.result
@@ -1,4 +1,5 @@
-package.path  = "../../src/module/sql/?.lua"
+--# push filter 'error: .*/src/module/sql/sql.lua' to 'error: src/module/sql/sql.lua'
+package.path  = os.getenv("TARANTOOL_SRC_DIR").."/src/module/sql/?.lua"
 ---
 ...
 package.cpath  = "?.so"
@@ -25,12 +26,12 @@ require("box.net.mysql")
 ...
 c = box.net.sql.connect('abcd')
 ---
-- error: '../../src/module/sql/sql.lua:29: Unknown driver ''abcd'''
+- error: src/module/sql/sql.lua:29: Unknown driver ''abcd'''
 ...
 c = box.net.sql.connect('mysql')
 ---
-- error: '../../src/module/sql/sql.lua:64: Usage: box.net.sql.connect(''mysql'', host,
-    port, user, password, db, ...)'
+- error: src/module/sql/sql.lua:64: Usage: box.net.sql.connect(''mysql'',
+    host, port, user, password, db, ...)'
 ...
 function dump(v) return box.cjson.encode(v) end
 ---
@@ -50,9 +51,9 @@ for k, v in pairs(c) do print(k, ': ', type(v)) end
 ...
 c:execute('SEL ECT 1')
 ---
-- error: '../../src/module/sql/sql.lua:105: You have an error in your SQL syntax;
-    check the manual that corresponds to your MySQL server version for the right syntax
-    to use near ''SEL ECT 1'' at line 1'
+- error: src/module/sql/sql.lua:105: You have an error in your
+    SQL syntax; check the manual that corresponds to your MySQL server version for
+    the right syntax to use near ''SEL ECT 1'' at line 1'
 ...
 dump({c:execute('SELECT ? AS bool1, ? AS bool2, ? AS nil, ? AS num, ? AS str', true, false, nil, 123, 'abc')})
 ---
@@ -106,3 +107,4 @@ os.execute("rm -rf box/net/")
 ---
 - 0
 ...
+--# clear filter
diff --git a/test/module/net_sql.mysql.skipcond b/test/module/net_sql.mysql.skipcond
index 1ca4e47baf..c3e469919b 100644
--- a/test/module/net_sql.mysql.skipcond
+++ b/test/module/net_sql.mysql.skipcond
@@ -1,6 +1,9 @@
 import os
+import os.path
 
 try:
-	(host, port, user, password, db) = os.getenv('MYSQL').split(':')
+    (host, port, user, password, db) = os.getenv('MYSQL').split(':')
+    if not os.path.exists(os.path.join(server.builddir, 'src/module/mysql/mysql.so')):
+        raise RuntimeError('No MySQL module found')
 except (RuntimeError, TypeError, NameError, AttributeError, ValueError):
-	self.skip = 1
+    self.skip = 1
diff --git a/test/module/net_sql.mysql.test.lua b/test/module/net_sql.mysql.test.lua
index 9b5539575c..af690469ba 100644
--- a/test/module/net_sql.mysql.test.lua
+++ b/test/module/net_sql.mysql.test.lua
@@ -1,4 +1,5 @@
-package.path  = "../../src/module/sql/?.lua"
+--# push filter 'error: .*/src/module/sql/sql.lua' to 'error: src/module/sql/sql.lua'
+package.path  = os.getenv("TARANTOOL_SRC_DIR").."/src/module/sql/?.lua"
 package.cpath  = "?.so"
 
 require("sql")
@@ -38,3 +39,4 @@ c:begin_work()
 c:commit()
 
 os.execute("rm -rf box/net/")
+--# clear filter
diff --git a/test/module/net_sql.pg.result b/test/module/net_sql.pg.result
index d503dd6a92..b9e722c36b 100644
--- a/test/module/net_sql.pg.result
+++ b/test/module/net_sql.pg.result
@@ -1,4 +1,5 @@
-package.path  = "../../src/module/sql/?.lua"
+--# push filter 'error: .*/src/module/sql/sql.lua' to 'error: src/module/sql/sql.lua'
+package.path  = os.getenv("TARANTOOL_SRC_DIR").."/src/module/sql/?.lua"
 ---
 ...
 package.cpath  = "?.so"
@@ -25,7 +26,7 @@ require("box.net.pg")
 ...
 c = box.net.sql.connect('abcd')
 ---
-- error: '../../src/module/sql/sql.lua:29: Unknown driver ''abcd'''
+- error: src/module/sql/sql.lua:29: Unknown driver ''abcd'''
 ...
 dump = function(v) return box.cjson.encode(v) end
 ---
@@ -94,7 +95,8 @@ dump({c:select('SELECT * FROM (VALUES (1,2), (2,3)) t')})
 ...
 dump({c:single('SELECT * FROM (VALUES (1,2), (2,3)) t')})
 ---
-- error: '../../src/module/sql/sql.lua:156: SQL request returned multiply rows'
+- error: src/module/sql/sql.lua:156: SQL request returned multiply
+    rows'
 ...
 dump({c:single('SELECT * FROM (VALUES (1,2)) t')})
 ---
@@ -106,12 +108,12 @@ dump({c:perform('SELECT * FROM (VALUES (1,2), (2,3)) t')})
 ...
 c:execute('SELEC T')
 ---
-- error: "../../src/module/sql/sql.lua:105: ERROR:  syntax error at or near \"SELEC\"\nLINE
-    1: SELEC T\n        ^\n"
+- error: src/module/sql/sql.lua:105: ERROR:  syntax error at
+    or near \"SELEC\"\nLINE 1: SELEC T\n        ^\n"
 ...
 c = box.net.sql.connect('abcd')
 ---
-- error: '../../src/module/sql/sql.lua:29: Unknown driver ''abcd'''
+- error: src/module/sql/sql.lua:29: Unknown driver ''abcd'''
 ...
 c:quote('abc\"cde\"def')
 ---
@@ -141,3 +143,4 @@ os.execute("rm -rf box/net/")
 ---
 - 0
 ...
+--# clear filter
diff --git a/test/module/net_sql.pg.skipcond b/test/module/net_sql.pg.skipcond
index e4648c2417..c8da9d2ff5 100644
--- a/test/module/net_sql.pg.skipcond
+++ b/test/module/net_sql.pg.skipcond
@@ -1,6 +1,9 @@
 import os
+import os.path
 
 try:
-	(host, port, user, password, db) = os.getenv('PG').split(':')
+    (host, port, user, password, db) = os.getenv('PG').split(':')
+    if not os.path.exists(os.path.join(server.builddir, 'src/module/pg/pg.so')):
+        raise RuntimeError('No PG module found')
 except (RuntimeError, TypeError, NameError, AttributeError, ValueError):
-	self.skip = 1
+    self.skip = 1
diff --git a/test/module/net_sql.pg.test.lua b/test/module/net_sql.pg.test.lua
index d888808e60..6ef277ee82 100644
--- a/test/module/net_sql.pg.test.lua
+++ b/test/module/net_sql.pg.test.lua
@@ -1,4 +1,5 @@
-package.path  = "../../src/module/sql/?.lua"
+--# push filter 'error: .*/src/module/sql/sql.lua' to 'error: src/module/sql/sql.lua'
+package.path  = os.getenv("TARANTOOL_SRC_DIR").."/src/module/sql/?.lua"
 package.cpath  = "?.so"
 
 require("sql")
@@ -47,3 +48,4 @@ c:commit()
 c:txn(function(dbi) dbi:single('SELECT 1') end)
 
 os.execute("rm -rf box/net/")
+--# clear filter
diff --git a/test/test-run.py b/test/test-run.py
index 47a9743ee3..0f15bf095a 100755
--- a/test/test-run.py
+++ b/test/test-run.py
@@ -130,13 +130,8 @@ class Options:
             exit(-1)
 
 
-def setenv(args):
-    os.putenv("TARANTOOL_PLUGIN_DIR",
-        ':'.join(
-            (os.path.join(os.getcwd(), '../src/plugin/mysql'),
-            os.path.join(os.getcwd(), '../src/plugin/pg'))
-        )
-    )
+def setenv():
+    os.putenv("TARANTOOL_SRC_DIR", os.path.abspath('..'))
 
 #######################################################################
 # Program body
@@ -144,7 +139,6 @@ def setenv(args):
 
 def main():
     options = Options()
-    setenv(options.args)
     oldcwd = os.getcwd()
     # Change the current working directory to where all test
     # collections are supposed to reside
@@ -154,6 +148,7 @@ def main():
     if not path:
         path = '.'
     os.chdir(path)
+    setenv()
 
     failed_tests = []
 
-- 
GitLab