#!/usr/bin/python2

import optparse
import subprocess
import sys
from gporca import GporcaCommon

def make():
    ciCommon = GporcaCommon()
    return subprocess.call(["make",
                            "-j" + str(ciCommon.num_cpus())], cwd="gpdb_src")

def install(output_dir):
    subprocess.call(["make", "install"], cwd="gpdb_src")
    subprocess.call("mkdir -p " + output_dir, shell=True)
    return subprocess.call("cp -r /usr/local/gpdb/* " + output_dir, shell=True)
	

def main():
    parser = optparse.OptionParser()
    parser.add_option("--build_type", dest="build_type", default="RELEASE")
    parser.add_option("--compiler", dest="compiler")
    parser.add_option("--cxxflags", dest="cxxflags")
    parser.add_option("--output_dir", dest="output_dir", default="install")
    (options, args) = parser.parse_args()
    ciCommon = GporcaCommon()
    status = ciCommon.install_system_deps()
    if status:
        return status
    for dependency in args:
        status = ciCommon.install_dependency(dependency)
        if status:
            return status
    status = ciCommon.configure()
    if status:
        return status
    status = make()
    if status:
        return status
    status = install(options.output_dir)
    if status:
        return status
    return 0

if __name__ == "__main__":
    sys.exit(main())

@@ -469,16 +469,125 @@
 =True)%0A%09
+%0Adef unittest():%0A        return subprocess.call(%5B%22make%22, %22-s%22, %22unittest-check%22%5D, cwd=%22gpdb_src/src/backend%22)
 %0A%0Adef ma
@@ -1290,32 +1290,93 @@
   return status%0A
+    status = unittest()%0A    if status:%0A        return status%0A
     status = ins

Add unittests in the build step of GPDB in concourse. (#831)