2019-08-30 12:20:29 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# "make test" for all platforms, running automated tests.
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import sys
|
|
|
|
|
2019-08-29 09:13:41 +00:00
|
|
|
import make_utils
|
2019-08-30 12:20:29 +00:00
|
|
|
from make_utils import call
|
|
|
|
|
|
|
|
# Parse arguments
|
|
|
|
|
|
|
|
def parse_arguments():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("--ctest-command", default="ctest")
|
2019-08-29 09:13:41 +00:00
|
|
|
parser.add_argument("--cmake-command", default="cmake")
|
|
|
|
parser.add_argument("--svn-command", default="svn")
|
|
|
|
parser.add_argument("--git-command", default="git")
|
2019-09-12 18:13:47 +00:00
|
|
|
parser.add_argument("--config", default="")
|
2019-08-30 12:20:29 +00:00
|
|
|
parser.add_argument("build_directory")
|
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
args = parse_arguments()
|
2019-08-29 09:13:41 +00:00
|
|
|
git_command = args.git_command
|
|
|
|
svn_command = args.svn_command
|
2019-08-30 12:20:29 +00:00
|
|
|
ctest_command = args.ctest_command
|
2019-08-29 09:13:41 +00:00
|
|
|
cmake_command = args.cmake_command
|
2019-09-12 18:13:47 +00:00
|
|
|
config = args.config
|
2019-08-30 12:20:29 +00:00
|
|
|
build_dir = args.build_directory
|
|
|
|
|
2019-09-30 08:19:55 +00:00
|
|
|
if make_utils.command_missing(ctest_command):
|
2019-08-30 12:20:29 +00:00
|
|
|
sys.stderr.write("ctest not found, can't run tests\n")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2019-09-30 08:19:55 +00:00
|
|
|
if make_utils.command_missing(git_command):
|
2019-09-12 18:13:47 +00:00
|
|
|
sys.stderr.write("git not found, can't run tests\n")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2019-08-29 09:13:41 +00:00
|
|
|
# Test if we are building a specific release version.
|
|
|
|
release_version = make_utils.git_branch_release_version(git_command)
|
|
|
|
lib_tests_dirpath = os.path.join('..', 'lib', "tests")
|
|
|
|
|
|
|
|
if not os.path.exists(lib_tests_dirpath):
|
|
|
|
print("Tests files not found, downloading...")
|
|
|
|
|
2019-09-30 08:19:55 +00:00
|
|
|
if make_utils.command_missing(svn_command):
|
2019-08-29 09:13:41 +00:00
|
|
|
sys.stderr.write("svn not found, can't checkout test files\n")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2019-09-30 08:19:55 +00:00
|
|
|
if make_utils.command_missing(cmake_command):
|
2019-09-12 18:13:47 +00:00
|
|
|
sys.stderr.write("cmake not found, can't checkout test files\n")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2019-08-29 09:13:41 +00:00
|
|
|
svn_url = make_utils.svn_libraries_base_url(release_version) + "/tests"
|
|
|
|
call([svn_command, "checkout", svn_url, lib_tests_dirpath])
|
|
|
|
|
|
|
|
# Run cmake again to detect tests files.
|
|
|
|
os.chdir(build_dir)
|
|
|
|
call([cmake_command, "."])
|
|
|
|
|
2019-08-30 12:20:29 +00:00
|
|
|
# Run tests
|
2019-09-13 08:22:44 +00:00
|
|
|
tests_dir = os.path.join(build_dir, "tests")
|
|
|
|
os.makedirs(tests_dir, exist_ok=True)
|
|
|
|
|
2019-08-30 12:20:29 +00:00
|
|
|
os.chdir(build_dir)
|
2019-09-12 18:13:47 +00:00
|
|
|
command = [ctest_command, ".", "--output-on-failure"]
|
|
|
|
if len(config):
|
|
|
|
command += ["-C", config]
|
2019-09-13 08:22:44 +00:00
|
|
|
tests_log = "log_" + config + ".txt"
|
|
|
|
else:
|
|
|
|
tests_log = "log.txt"
|
|
|
|
command += ["-O", os.path.join(tests_dir, tests_log)]
|
2019-09-12 18:13:47 +00:00
|
|
|
call(command)
|