<gh_stars>0
import subprocess as sb
import os

cwd = os.getcwd()

os.environ['LD_LIBRARY_PATH'] = cwd

tests_dir = "../install/"

projects = [
('renderalgo', './'),
]

results = list()

def fail_test(tag:str):
    results.append((tag, "==FAILED=="))
    return

def pass_test(tag:str):
    results.append((tag, "+"))
    return

def chdir(path: str) -> str:
    if path == './':
        return os.path.join(cwd, tests_dir)
    return os.path.join(cwd, tests_dir + path)


for p_name, p_path in projects:
    dir = chdir(p_path)
    print("test is executable in ", dir)
    if not os.path.exists(dir):
        print("Could not find target dir ", p_path)
        fail_test(p_name)
    if not os.path.exists(dir + p_name):
        print("Could not find target executable ", p_name)
        fail_test(p_name)
    else:
        print(">> run: ", p_name, " in dir: ", dir)       
        code = sb.check_call([dir+p_name+' test\n'], shell=True, cwd="/workspace/install")
        print( "  return code << ", code);
        pass_test(p_name)
        
        # notes how to run 
        
        #proc = sb.Popen(['./'+dir+p_name], shell=True, stdin=sb.PIPE, stdout=sb.PIPE, stderr=sb.PIPE)
        #out, err = proc.communicate('test\n')
        #print("ReturnCode: ", proc.returncode)
        #assert proc.returncode == 0

        # out, err = proc.communicate('hello\n')
        # assert out == 'hello\n'
        # assert err == ''

        # result = sb.run([dir + p_name], stdout=sb.PIPE, cwd=cwd)
        # if result.returncode != 0:
             #print("error: \nargs: ", result.args, "\nstdout: ", result.stdout, "\nreturncode: {}", result.returncode)
             #break
        

for rec in results:
    print(rec)



import subprocess as sb
import os

cwd = os.getcwd()

os.environ['LD_LIBRARY_PATH'] = cwd

tests_dir = "../install/"

projects = [
('renderalgo', './'),
]

results = list()

def fail_test(tag:str):
    results.append((tag, "==FAILED=="))
    return

def pass_test(tag:str):
    results.append((tag, "+"))
    return

def chdir(path: str) -> str:
    if path == './':
        return os.path.join(cwd, tests_dir)
    return os.path.join(cwd, tests_dir + path)


for p_name, p_path in projects:
    dir = chdir(p_path)
    print("test is executable in ", dir)
    if not os.path.exists(dir):
        print("Could not find target dir ", p_path)
        fail_test(p_name)
    if not os.path.exists(dir + p_name):
        print("Could not find target executable ", p_name)
        fail_test(p_name)
    else:
        print(">> run: ", p_name, " in dir: ", dir)       
        code = sb.check_call([dir+p_name+' test\n'], shell=True, cwd="/workspace/install")
        print( "  return code << ", code);
        pass_test(p_name)
        
        # notes how to run 
        
        #proc = sb.Popen(['./'+dir+p_name], shell=True, stdin=sb.PIPE, stdout=sb.PIPE, stderr=sb.PIPE)
        #out, err = proc.communicate('test\n')
        #print("ReturnCode: ", proc.returncode)
        #assert proc.returncode == 0

        # out, err = proc.communicate('hello\n')
        # assert out == 'hello\n'
        # assert err == ''

        # result = sb.run([dir + p_name], stdout=sb.PIPE, cwd=cwd)
        # if result.returncode != 0:
             #print("error: \nargs: ", result.args, "\nstdout: ", result.stdout, "\nreturncode: {}", result.returncode)
             #break
        

for rec in results:
    print(rec)
# notes how to run #proc = sb.Popen(['./'+dir+p_name], shell=True, stdin=sb.PIPE, stdout=sb.PIPE, stderr=sb.PIPE) #out, err = proc.communicate('test\n') #print("ReturnCode: ", proc.returncode) #assert proc.returncode == 0 # out, err = proc.communicate('hello\n') # assert out == 'hello\n' # assert err == '' # result = sb.run([dir + p_name], stdout=sb.PIPE, cwd=cwd) # if result.returncode != 0: #print("error: \nargs: ", result.args, "\nstdout: ", result.stdout, "\nreturncode: {}", result.returncode) #break