From 6472662d6661a447be37588ade2d12e3eea97e79 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 12 Sep 2019 20:13:47 +0200 Subject: [PATCH] Build: add "make test" command for Windows, output log file Differential Revision: https://developer.blender.org/D5715 --- GNUmakefile | 3 +-- build_files/utils/make_test.py | 15 ++++++++++++++- build_files/windows/find_dependencies.cmd | 4 +++- build_files/windows/parse_arguments.cmd | 3 +++ build_files/windows/reset_variables.cmd | 1 + build_files/windows/show_help.cmd | 1 + build_files/windows/test.cmd | 13 +++++++++++++ make.bat | 5 +++++ 8 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 build_files/windows/test.cmd diff --git a/GNUmakefile b/GNUmakefile index ef1b6b711d2..d960a67e407 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,8 +62,7 @@ Testing Targets Not associated with building Blender. * test: - Run ctest, currently tests import/export, - operator execution and that python modules load + Run automated tests with ctest. * test_cmake: Runs our own cmake file checker which detects errors in the cmake file list definitions diff --git a/build_files/utils/make_test.py b/build_files/utils/make_test.py index 0a5e4055a18..a18b1c8814a 100755 --- a/build_files/utils/make_test.py +++ b/build_files/utils/make_test.py @@ -18,6 +18,7 @@ def parse_arguments(): parser.add_argument("--cmake-command", default="cmake") parser.add_argument("--svn-command", default="svn") parser.add_argument("--git-command", default="git") + parser.add_argument("--config", default="") parser.add_argument("build_directory") return parser.parse_args() @@ -26,12 +27,17 @@ git_command = args.git_command svn_command = args.svn_command ctest_command = args.ctest_command cmake_command = args.cmake_command +config = args.config 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) +if shutil.which(git_command) is None: + sys.stderr.write("git 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") @@ -43,6 +49,10 @@ if not os.path.exists(lib_tests_dirpath): sys.stderr.write("svn not found, can't checkout test files\n") sys.exit(1) + if shutil.which(cmake_command) is None: + sys.stderr.write("cmake 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]) @@ -52,4 +62,7 @@ if not os.path.exists(lib_tests_dirpath): # Run tests os.chdir(build_dir) -call([ctest_command, ".", "--output-on-failure"]) +command = [ctest_command, ".", "--output-on-failure"] +if len(config): + command += ["-C", config] +call(command) diff --git a/build_files/windows/find_dependencies.cmd b/build_files/windows/find_dependencies.cmd index 6a2233ecff7..7419a0bc77e 100644 --- a/build_files/windows/find_dependencies.cmd +++ b/build_files/windows/find_dependencies.cmd @@ -1,15 +1,17 @@ REM find all dependencies and set the corresponding environment variables. for %%X in (svn.exe) do (set SVN=%%~$PATH:X) for %%X in (cmake.exe) do (set CMAKE=%%~$PATH:X) +for %%X in (ctest.exe) do (set CTEST=%%~$PATH:X) for %%X in (git.exe) do (set GIT=%%~$PATH:X) set PYTHON=%BLENDER_DIR%\..\lib\win64_vc14\python\37\bin\python.exe if NOT "%verbose%" == "" ( echo svn : "%SVN%" echo cmake : "%CMAKE%" + echo ctest : "%CTEST%" echo git : "%GIT%" echo python : "%PYTHON%" ) if "%CMAKE%" == "" ( echo Cmake not found in path, required for building, exiting... exit /b 1 -) \ No newline at end of file +) diff --git a/build_files/windows/parse_arguments.cmd b/build_files/windows/parse_arguments.cmd index acbbc355f57..47c6f81adb3 100644 --- a/build_files/windows/parse_arguments.cmd +++ b/build_files/windows/parse_arguments.cmd @@ -92,6 +92,9 @@ if NOT "%1" == "" ( set MUST_CLEAN=1 ) else if "%1" == "verbose" ( set VERBOSE=1 + ) else if "%1" == "test" ( + set TEST=1 + set NOBUILD=1 ) else if "%1" == "format" ( set FORMAT=1 set FORMAT_ARGS=%2 %3 %4 %5 %6 %7 %8 %9 diff --git a/build_files/windows/reset_variables.cmd b/build_files/windows/reset_variables.cmd index 8b74cec238d..48a61aff44a 100644 --- a/build_files/windows/reset_variables.cmd +++ b/build_files/windows/reset_variables.cmd @@ -29,3 +29,4 @@ set ASAN_CMAKE_ARGS= set WITH_PYDEBUG= set PYDEBUG_CMAKE_ARGS= set FORMAT= +set TEST= diff --git a/build_files/windows/show_help.cmd b/build_files/windows/show_help.cmd index d0469688b5a..30f75316499 100644 --- a/build_files/windows/show_help.cmd +++ b/build_files/windows/show_help.cmd @@ -13,6 +13,7 @@ echo - update ^(Update both SVN and GIT^) echo - code_update ^(Update only GIT^) echo - nobuild ^(only generate project files^) echo - showhash ^(Show git hashes of source tree^) +echo - test ^(Run automated tests with ctest^) echo - format [path] ^(Format the source using clang-format, path is optional, requires python 3.x to be available^) echo. echo Configuration options diff --git a/build_files/windows/test.cmd b/build_files/windows/test.cmd new file mode 100644 index 00000000000..cad6b50e8bb --- /dev/null +++ b/build_files/windows/test.cmd @@ -0,0 +1,13 @@ +if EXIST %PYTHON% ( + goto detect_python_done +) + +echo python not found in lib folder +exit /b 1 + +:detect_python_done + +REM Use -B to avoid writing __pycache__ in lib directory and causing update conflicts. +%PYTHON% -B %BLENDER_DIR%\build_files\utils\make_test.py --git-command "%GIT%" --svn-command "%SVN%" --cmake-command="%CMAKE%" --ctest-command="%CTEST%" --config="%BUILD_TYPE%" %BUILD_DIR% + +:EOF diff --git a/make.bat b/make.bat index 3f09718ab4f..ea80bd591f7 100644 --- a/make.bat +++ b/make.bat @@ -63,6 +63,11 @@ echo Building blender with VS%BUILD_VS_YEAR% for %BUILD_ARCH% in %BUILD_DIR% call "%BLENDER_DIR%\build_files\windows\check_libraries.cmd" if errorlevel 1 goto EOF +if "%TEST%" == "1" ( + call "%BLENDER_DIR%\build_files\windows\test.cmd" + goto EOF +) + call "%BLENDER_DIR%\build_files\windows\check_submodules.cmd" if errorlevel 1 goto EOF