THRIFT-2578 Moving 'make cross' from test.sh to test.py
diff --git a/test/py/TestClient.py b/test/py/TestClient.py
index 53b3ad7..87fede6 100755
--- a/test/py/TestClient.py
+++ b/test/py/TestClient.py
@@ -53,7 +53,8 @@
 parser.set_defaults(framed=False, http_path=None, verbose=1, host='localhost', port=9090, proto='binary')
 options, args = parser.parse_args()
 
-sys.path.insert(0, options.genpydir)
+script_dir = os.path.dirname(__file__)
+sys.path.insert(0, os.path.join(script_dir, options.genpydir))
 
 from ThriftTest import ThriftTest, SecondService
 from ThriftTest.ttypes import *
diff --git a/test/py/TestServer.py b/test/py/TestServer.py
index 98446a5..820b816 100755
--- a/test/py/TestServer.py
+++ b/test/py/TestServer.py
@@ -46,7 +46,8 @@
 parser.set_defaults(port=9090, verbose=1, proto='binary')
 options, args = parser.parse_args()
 
-sys.path.insert(0, options.genpydir)
+script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in
+sys.path.insert(0, os.path.join(script_dir, options.genpydir))
 
 from ThriftTest import ThriftTest
 from ThriftTest.ttypes import *
@@ -201,7 +202,6 @@
 
 # set up server transport and transport factory
 
-script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in
 rel_path = "../keys/server.pem"
 abs_key_path = os.path.join(script_dir, rel_path)
 
diff --git a/test/test.py b/test/test.py
index 00d2d0d..0068c81 100644
--- a/test/test.py
+++ b/test/test.py
@@ -60,14 +60,16 @@
   server_args = []
   cli_args = []
   if server_lib == 'java':
-    server_executable[2] = relfile(server_executable[2])
-    server_args.extend(server_executable)
+    server_args.append(server_executable[0])
+    server_args.append(server_executable[1])
+    server_args.append(relfile(server_executable[2]))
     server_args.extend(['-Dtestargs','\"'])
   else:
     server_args = [relfile(server_executable)]
   if client_lib == 'java':
-    client_executable[2] = relfile(client_executable[2])
-    cli_args.extend(client_executable)
+    cli_args.append(client_executable[0])
+    cli_args.append(client_executable[1])
+    cli_args.append(relfile(client_executable[2]))
     cli_args.extend(['-Dtestargs','\"'])
   else:
     cli_args = [relfile(client_executable)]
@@ -96,8 +98,8 @@
   server_args.extend(server_extra_args)
   cli_args.extend(client_extra_args)
 
-  server_log=open("log/" + test_name + "_server.log","a")
-  client_log=open("log/" + test_name + "_client.log","a")
+  server_log=open(relfile("log/" + test_name + "_server.log"),"a")
+  client_log=open(relfile("log/" + test_name + "_client.log"),"a")
 
   try:
     if options.verbose > 0:
@@ -169,8 +171,8 @@
              'processes to terminate via alarm'
              % (protocol, use_zlib, use_ssl, extra_sleep))
       time.sleep(extra_sleep)
-    os.kill(serverproc.pid, signal.SIGKILL)
-    serverproc.wait()
+    os.kill(serverproc.pid, signal.SIGTERM)
+    #serverproc.wait()
   client_log.flush()
   server_log.flush()
   client_log.close()
@@ -178,14 +180,15 @@
 
 test_count = 0
 failed = 0
+hard_fail_count = 0
 platform = platform.system()
-if os.path.exists('log'): shutil.rmtree('log')
-os.makedirs('log')
-if os.path.exists('results.json'): os.remove('results.json')
-results_json = open("results.json","a")
+if os.path.exists(relfile('log')): shutil.rmtree(relfile('log'))
+os.makedirs(relfile('log'))
+if os.path.exists(relfile('results.json')): os.remove(relfile('results.json'))
+results_json = open(relfile("results.json"),"a")
 results_json.write("[\n")
 
-with open('tests.json') as data_file:
+with open(relfile('tests.json')) as data_file:
     data = json.load(data_file)
 
 #subprocess.call("export NODE_PATH=../lib/nodejs/test:../lib/nodejs/lib:${NODE_PATH}")
@@ -217,6 +220,8 @@
                   ret = runServiceTest(test_name, server_lib, server_executable, server_extra_args, client_lib, client_executable, client_extra_args, protocol, protocol, transport, 9090, 0, sock)
                   if ret != None:
                     failed += 1
+                    if client["exit"] == "hard" and server["exit"] == "hard":
+                      hard_fail_count +=1
                     print "Error: %s" % ret
                     print "Using"
                     print (' Server: %s --protocol=%s --transport=%s %s %s'
@@ -240,6 +245,8 @@
 
                   if ret != None:
                     failed += 1
+                    if client["exit"] == "hard" and server["exit"] == "hard":
+                      hard_fail_count +=1
                     print "Error: %s" % ret
                     print "Using"
                     print (' Server: %s --protocol=%s --transport=%s %s %s'
@@ -262,6 +269,8 @@
                   ret = runServiceTest(test_name, server_lib,server_executable, server_extra_args, client_lib, client_executable, client_extra_args, protocol, 'binary', transport, 9090, 0, sock)
                   if ret != None:
                     failed += 1
+                    if client["exit"] == "hard" and server["exit"] == "hard":
+                      hard_fail_count +=1
                     print "Error: %s" % ret
                     print "Using"
                     print (' Server: %s --protocol=%s --transport=%s %s %s'
@@ -276,4 +285,5 @@
 results_json.write("\n]")
 results_json.flush()
 results_json.close()
-print '%s failed of %s tests in total' % (failed, test_count)
\ No newline at end of file
+print '%s failed of %s tests in total' % (failed, test_count)
+sys.exit(hard_fail_count)
\ No newline at end of file
diff --git a/test/tests.json b/test/tests.json
index 2c16a69..8d2b16c 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -4,7 +4,8 @@
             "description": "Python TestClient",
             "lib": "py",
             "executable": "py/TestClient.py",
-            "extra_args":  ["--genpydir=py/gen-py"],
+            "exit": "hard",
+            "extra_args":  ["--genpydir=gen-py"],
             "protocols": [
                 "binary",
                 "compact",
@@ -27,6 +28,7 @@
             "description": "C++ TestClient",
             "lib": "cpp",
             "executable": "cpp/TestClient",
+            "exit": "soft",
             "protocols": [
                 "binary",
                 "compact",
@@ -50,6 +52,7 @@
             "description": "Nodejs TestClient",
             "lib": "nodejs",
             "executable": "../lib/nodejs/test/client.js",
+            "exit": "soft",
             "protocols": [
                 "binary",
                 "compact",
@@ -71,6 +74,7 @@
             "description": "Ruby TestClient",
             "lib": "ruby",
             "executable": "rb/integration/TestClient.rb",
+            "exit": "soft",
             "protocols": [
                 "binary",
                 "compact",
@@ -93,6 +97,7 @@
             "lib": "java",
             "executable": ["ant","-f","../lib/java/build.xml","-Dno-gen-thrift=\"\""],
             "extra_args": ["run-testclient"],
+            "exit": "soft",
             "protocols": [
                 "binary",
                 "compact",
@@ -118,8 +123,9 @@
             "description": "Python TSimpleServer",
             "lib": "py",
             "executable": "py/TestServer.py",
-            "extra_args": ["--genpydir=py/gen-py", "TSimpleServer"],
+            "extra_args": ["--genpydir=gen-py", "TSimpleServer"],
             "extra_delay": 0,
+            "exit": "hard",
             "protocols": [
                 "binary",
                 "compact",
@@ -142,6 +148,7 @@
             "description": "C++ TestServer",
             "lib": "cpp",
             "executable": "cpp/TestServer",
+            "exit": "hard",
             "protocols": [
                 "binary",
                 "compact",
@@ -165,6 +172,7 @@
             "description": "Ruby TestServer",
             "lib": "ruby",
             "executable": "rb/integration/TestServer.rb",
+            "exit": "soft",
             "protocols": [
                 "binary",
                 "compact",
@@ -186,6 +194,7 @@
             "description": "Nodejs TestServer",
             "lib": "nodejs",
             "executable": "../lib/nodejs/test/server.js",
+            "exit": "soft",
             "protocols": [
                 "binary",
                 "compact",
@@ -208,6 +217,7 @@
             "lib": "java",
             "executable": ["ant","-f","../lib/java/build.xml","-Dno-gen-thrift=\"\""],
             "extra_args": ["run-testserver"],
+            "exit": "soft",
             "protocols": [
                 "binary",
                 "compact",