Commit: 71ba2b7c97108af3906ae0841448727cdafa9690 Author: Sergey Sharybin Date: Thu Jan 22 03:56:51 2015 +0500 Branches: cycles_ctests https://developer.blender.org/rB71ba2b7c97108af3906ae0841448727cdafa9690
Cycles ctests: Add runtime check for Cycles The idea is to check scene's render engine and if it's not Cycles report about this and stop running tests (because it's not likely Cycles will be loaded correctly). This way we'll fail Cycles tests real quick without install target and give quite nice error message about that. =================================================================== M tests/python/CMakeLists.txt A tests/python/cycles/render_tests.py A tests/python/cycles/runtime_check.py D tests/python/cycles_render_tests.py =================================================================== diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index f4dc1a2..242972e 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -362,7 +362,7 @@ add_test(export_fbx_all_objects ${TEST_BLENDER_EXE} if(WITH_CYCLES) add_test(cycles_shaders_test - ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py + ${CMAKE_CURRENT_LIST_DIR}/cycles/render_tests.py -blender "${TEST_BLENDER_EXE_BARE}" -testdir "${TEST_SRC_DIR}/cycles/ctests/shader" ) diff --git a/tests/python/cycles_render_tests.py b/tests/python/cycles/render_tests.py similarity index 76% rename from tests/python/cycles_render_tests.py rename to tests/python/cycles/render_tests.py index 6b49225..68a35f7 100755 --- a/tests/python/cycles_render_tests.py +++ b/tests/python/cycles/render_tests.py @@ -18,6 +18,8 @@ TEMP = tempfile.mkdtemp() TEMP_FILE_MASK = os.path.join(TEMP, "test") TEMP_FILE = TEMP_FILE_MASK + '0001.png' +TEST_SCRIPT = os.path.join(os.path.dirname(__file__), 'runtime_check.py') + def render_file(filepath): command = [BLENDER, @@ -25,17 +27,19 @@ def render_file(filepath): '-noaudio', '--factory-startup', filepath, - '-o', - TEMP_FILE_MASK, + '--python', TEST_SCRIPT, + '-o', TEMP_FILE_MASK, '-f', '1', ] try: subprocess.check_output(command) - return os.path.exists(TEMP_FILE) + return None if os.path.exists(TEMP_FILE) else "NOT_FOUND" + except subprocess.CalledProcessError as grepexc: + return "NO_CYCLES" if grepexc.returncode == 128 else "CRASH" except: if os.path.exists(TEMP_FILE): os.remove(TEMP_FILE) - return False + return "CRASH" def test_get_name(filepath): @@ -68,14 +72,15 @@ def run_test(filepath): spacer = "." * (32 - len(testname)) print(testname, spacer, end='') sys.stdout.flush() - if render_file(filepath): - ok = verify_output(filepath) - os.remove(TEMP_FILE) - print("PASS" if ok else "FAIL (VERIFY)") - return ok - else: - print("FAIL (RENDER)") - return False + error = render_file(filepath) + if not error: + if verify_output(filepath): + print('PAS') + else: + error = 'VERIFY' + if error: + print("FAIL", error) + return error def blend_list(path): @@ -91,7 +96,11 @@ def run_all_tests(dirpath): all_files = list(blend_list(dirpath)) all_files.sort() for filepath in all_files: - if not run_test(filepath): + error = run_test(filepath) + if error: + if error == 'NO_CYCLES': + print('Can not perform tests because Cycles can''t be loaed') + return False testname = test_get_name(filepath) failed_tests.append(testname) if failed_tests: diff --git a/tests/python/cycles/runtime_check.py b/tests/python/cycles/runtime_check.py new file mode 100644 index 0000000..960082c --- /dev/null +++ b/tests/python/cycles/runtime_check.py @@ -0,0 +1,6 @@ +import bpy +import sys + +scene = bpy.data.scenes[0] +if scene.render.engine != 'CYCLES': + sys.exit(128) _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs