[Bf-blender-cvs] [718747c5895] master: Tests: auto download test files when running "make test"

Brecht Van Lommel noreply at git.blender.org
Fri Aug 30 18:04:18 CEST 2019


Commit: 718747c5895067c261a3fc11e9918fc1a8f1d385
Author: Brecht Van Lommel
Date:   Thu Aug 29 11:13:41 2019 +0200
Branches: master
https://developer.blender.org/rB718747c5895067c261a3fc11e9918fc1a8f1d385

Tests: auto download test files when running "make test"

===================================================================

M	build_files/utils/make_test.py
M	build_files/utils/make_update.py
M	build_files/utils/make_utils.py

===================================================================

diff --git a/build_files/utils/make_test.py b/build_files/utils/make_test.py
index 1522631de4b..0a5e4055a18 100755
--- a/build_files/utils/make_test.py
+++ b/build_files/utils/make_test.py
@@ -7,6 +7,7 @@ import os
 import shutil
 import sys
 
+import make_utils
 from make_utils import call
 
 # Parse arguments
@@ -14,17 +15,41 @@ from make_utils import call
 def parse_arguments():
     parser = argparse.ArgumentParser()
     parser.add_argument("--ctest-command", default="ctest")
+    parser.add_argument("--cmake-command", default="cmake")
+    parser.add_argument("--svn-command", default="svn")
+    parser.add_argument("--git-command", default="git")
     parser.add_argument("build_directory")
     return parser.parse_args()
 
 args = parse_arguments()
+git_command = args.git_command
+svn_command = args.svn_command
 ctest_command = args.ctest_command
+cmake_command = args.cmake_command
 build_dir = args.build_directory
 
 if shutil.which(ctest_command) is None:
     sys.stderr.write("ctest not found, can't run tests\n")
     sys.exit(1)
 
+# 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...")
+
+    if shutil.which(svn_command) is None:
+        sys.stderr.write("svn not found, can't checkout test files\n")
+        sys.exit(1)
+
+    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, "."])
+
 # Run tests
 os.chdir(build_dir)
 call([ctest_command, ".", "--output-on-failure"])
diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py
index a019e17e0a8..8a32fc013be 100755
--- a/build_files/utils/make_update.py
+++ b/build_files/utils/make_update.py
@@ -8,11 +8,10 @@
 
 import argparse
 import os
-import re
 import shutil
-import subprocess
 import sys
 
+import make_utils
 from make_utils import call
 
 # Parse arguments
@@ -43,27 +42,12 @@ def print_stage(text):
     print("")
 
 # Test if we are building a specific release version.
-try:
-    branch = subprocess.check_output([git_command, "rev-parse", "--abbrev-ref", "HEAD"])
-except subprocess.CalledProcessError as e:
-    sys.stderr.write("Failed to get Blender git branch\n")
-    sys.exit(1)
-
-branch = branch.strip().decode('utf8')
-release_version = re.search("^blender-v(.*)-release$", branch)
-if release_version:
-    release_version = release_version.group(1)
-    print("Using Release Blender v" + release_version)
+release_version = make_utils.git_branch_release_version(git_command)
 
 # Setup for precompiled libraries and tests from svn.
 if not only_code:
     lib_dirpath = os.path.join('..', 'lib')
-
-    if release_version:
-        svn_branch = "tags/blender-" + release_version + "-release"
-    else:
-        svn_branch = "trunk"
-    svn_url = "https://svn.blender.org/svnroot/bf-blender/" + svn_branch + "/lib/"
+    svn_url = make_utils.svn_libraries_base_url(release_version)
 
     # Checkout precompiled libraries
     if sys.platform == 'darwin':
diff --git a/build_files/utils/make_utils.py b/build_files/utils/make_utils.py
index 98536879b91..d05c1e6f838 100755
--- a/build_files/utils/make_utils.py
+++ b/build_files/utils/make_utils.py
@@ -2,6 +2,7 @@
 #
 # Utility functions for make update and make tests.
 
+import re
 import subprocess
 import sys
 
@@ -15,3 +16,24 @@ def call(cmd):
     retcode = subprocess.call(cmd)
     if retcode != 0:
       sys.exit(retcode)
+
+def git_branch_release_version(git_command):
+    # Test if we are building a specific release version.
+    try:
+        branch = subprocess.check_output([git_command, "rev-parse", "--abbrev-ref", "HEAD"])
+    except subprocess.CalledProcessError as e:
+        sys.stderr.write("Failed to get Blender git branch\n")
+        sys.exit(1)
+
+    branch = branch.strip().decode('utf8')
+    release_version = re.search("^blender-v(.*)-release$", branch)
+    if release_version:
+        release_version = release_version.group(1)
+    return release_version
+
+def svn_libraries_base_url(release_version):
+    if release_version:
+        svn_branch = "tags/blender-" + release_version + "-release"
+    else:
+        svn_branch = "trunk"
+    return "https://svn.blender.org/svnroot/bf-blender/" + svn_branch + "/lib/"



More information about the Bf-blender-cvs mailing list