From a8524b6e363e719691df4d7b692705e85bfd4560 Mon Sep 17 00:00:00 2001 From: alesapin Date: Thu, 24 Jan 2019 14:02:55 +0300 Subject: [PATCH] Fix wrong code in clickhouse-test --- dbms/tests/clickhouse-test | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dbms/tests/clickhouse-test b/dbms/tests/clickhouse-test index ac745c894c2..c66eb51317c 100755 --- a/dbms/tests/clickhouse-test +++ b/dbms/tests/clickhouse-test @@ -328,6 +328,14 @@ def main(args): print(colored("\n{passed_total} tests passed. {skipped_total} tests skipped.".format(passed_total = passed_total, skipped_total = skipped_total), "green", attrs=["bold"])) sys.exit(0) +def find_binary(name): + paths = os.environ.get("PATH").split(':') + for path in paths: + if os.access(os.path.join(path, name), os.X_OK): + return True + + # maybe it wasn't in PATH + return os.access(os.path.join('/usr/bin', name), os.X_OK) if __name__ == '__main__': parser = ArgumentParser(description = 'ClickHouse functional tests') @@ -370,14 +378,15 @@ if __name__ == '__main__': if args.tmp is None: args.tmp = args.queries if args.client is None: - if os.access(args.binary + '-client', os.X_OK): + if find_binary(args.binary + '-client'): args.client = args.binary + '-client' - elif os.access(args.binary,os.X_OK): + elif find_binary(args.binary): args.client = args.binary + ' client' else: - print("No clickhouse binary found") - parser.print_help(); - exit(0); + print("No 'clickhouse' binary found in PATH") + parser.print_help() + exit(1) + if args.configclient: args.client += ' --config-file=' + args.configclient if os.getenv("CLICKHOUSE_HOST"):