Revision: 30330 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30330 Author: leifandersen Date: 2010-07-14 18:41:44 +0200 (Wed, 14 Jul 2010)
Log Message: ----------- 1. Changed the CMake files to match the new format. 2. Cleaned up more code, so that it goes down for distinct branches (well...six, maybe I can clean up some more), being: Images (w, w/o animations), Hashcodes (w, w/o animations), and those too options again with user defined paths. Although the hashcode paths are currently stuck off, and may or may not actually make it into the mid-term evaulations. Most of the bugs are removed at this point. Modified Paths: -------------- branches/soc-2010-leifandersen/tests/pyunit/ops/physics/CMakeLists.txt branches/soc-2010-leifandersen/tests/render/run.py Modified: branches/soc-2010-leifandersen/tests/pyunit/ops/physics/CMakeLists.txt =================================================================== --- branches/soc-2010-leifandersen/tests/pyunit/ops/physics/CMakeLists.txt 2010-07-14 16:38:09 UTC (rev 30329) +++ branches/soc-2010-leifandersen/tests/pyunit/ops/physics/CMakeLists.txt 2010-07-14 16:41:44 UTC (rev 30330) @@ -4,7 +4,7 @@ PROPERTIES PASS_REGULAR_EXPRESSION "OK" ) -ADD_TEST(Ops_Particle_Test_Image_Compare python ${Blender_BINARY_DIR}/tests/render/run.py --blender-bin ${Blender_BINARY_DIR}/bin/blender --image ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/cube_hair.blend --image ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/cube_hair_group.blend --image ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/cube_hair_object.blend) +ADD_TEST(Ops_Particle_Test_Image_Compare python ${Blender_BINARY_DIR}/tests/render/run.py --blender-bin ${Blender_BINARY_DIR}/bin/blender --image ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/cube_hair.blend ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/cube_hair_group.blend ${Blender_BINARY_DIR}/tests/pyunit/ops/physics/cube_hair_object.blend) SET_TESTS_PROPERTIES(Ops_Particle_Test_Image_Compare PROPERTIES PASS_REGULAR_EXPRESSION "All tests passed" Modified: branches/soc-2010-leifandersen/tests/render/run.py =================================================================== --- branches/soc-2010-leifandersen/tests/render/run.py 2010-07-14 16:38:09 UTC (rev 30329) +++ branches/soc-2010-leifandersen/tests/render/run.py 2010-07-14 16:41:44 UTC (rev 30330) @@ -12,27 +12,9 @@ from optparse import OptionParser BLENDER_BIN = 'blender' -RUN_ANIMATIONS = False -RUN_IMAGES = True -RUN_ANIMATIONS = False -VERBOSE = False -SAVEOUT = sys.stdout -BLEND_FILE_FOLDER = os.path.join(sys.path[0]) -ANIM_BLEND_FILE_FOLDER = os.path.join(sys.path[0], 'anim') -GOOD_FOLDER = os.path.join(sys.path[0], 'render') -ANIM_GOOD_FOLDER = os.path.join(sys.path[0], 'anim') -OUTPUT_FOLDER = os.path.join(sys.path[0], 'output') -ANIM_OUTPUT_FOLDER = os.path.join(sys.path[0], 'output') -HTML_OUTPUT = sys.path[0] GOOD_BLENDER_BIN = 'blender' -BUILDING_TESTS = False -HASHCODE_TEST = False -HASHCODE_FILE = os.path.join(sys.path[0], 'hashcodes.txt') -GET_HASHCODES = False -OPTIONAL_CASES = [] +VERBOSE = False -HELP = '''Help to come''' - class ImageTestCase: '''A Render Test Case. Steps must be run in order: 1. Constructer @@ -86,8 +68,9 @@ try: self.good_image = Image.open(good_path) except IOError: - self.mode = 'Fail' + self.passed = False self.good_image = None + self.messaged = 'Failed to find good image' def generate_hash(self, image): hash = 0 @@ -119,7 +102,6 @@ self.test_image = Image.open(self.test_path) self.test_hash = self.generate_hash(self.test_image) except IOError: - self.ID = 'Fail' self.test_image = None self.passed = False self.pixel_range = 0 @@ -150,13 +132,6 @@ else: self.passed = False return self.passed - elif self.good_hash != None and self.test_hash != None: - self.diff_hash = abs(self.good_hash - self.test_hash) - if self.diff_hash < 1000: - self.passed = True - else: - self.passed = False - return self.passed def hash_test(self): if self.test_image == None: @@ -457,11 +432,11 @@ file.close() return cases -def console_output(cases): +def console_output(cases, building_tests, get_hashcodes): '''Displays the final output to the console. The output that will be shown if the -v flag isn't used''' failed = [] print '' - if BUILDING_TESTS: + if building_tests: print "Tests built successfully" return @@ -469,7 +444,7 @@ if test_case.passed == False: failed.append(test_case) - if GET_HASHCODES: + if get_hashcodes: for case in cases: print case.ID + ':', case.name, case.test_hash @@ -480,6 +455,8 @@ else: print "All tests passed" if len(failed) == len(cases): + print '' + print "It is possible that the tests have not been built, if so" print "Please build tests by running: python run.py --build-tests" print "Or python --build-tests --with-animations to also build animation tests" print 'Check index.html for more information' @@ -616,19 +593,30 @@ file.write('</div>\n</body>\n</html>') file.close() -if __name__ == "__main__": +def main(): + global BLENDER_BIN, VERBOSE + BLEND_FILE_FOLDER = os.path.join(sys.path[0]) + ANIM_BLEND_FILE_FOLDER = os.path.join(sys.path[0], 'anim') + GOOD_FOLDER = os.path.join(sys.path[0], 'render') + ANIM_GOOD_FOLDER = os.path.join(sys.path[0], 'anim') + OUTPUT_FOLDER = os.path.join(sys.path[0], 'output') + ANIM_OUTPUT_FOLDER = os.path.join(sys.path[0], 'output') + HTML_OUTPUT = sys.path[0] + HASHCODE_FILE = os.path.join(sys.path[0], 'hashcodes.txt') + # Case list, can contain both image cases, and animation cases cases = [] + optional_cases = [] # Parse the arguements parser = OptionParser() - parser.add_option('--build-tests', action='store_true', dest='build_tests', default=False, + parser.add_option('--build-tests', action='store_true', dest='building_tests', default=False, help="Render the images for the tests") parser.add_option('--blender-bin', type='string', dest='blender_bin', default='blender', help="Location of the blender binary if not in your path.") - parser.add_option('-i', '--image', type='string', dest='image', default = '', + parser.add_option('-i', '--image', action='store_true', dest='image', default=True, help="Run an image test outside of the current folder") - parser.add_option('-a', '--animation', type='string', dest='animation', default = '', + parser.add_option('-a', '--animation', action='store_false', dest='image', default=True, help="Run an animation test outside of the current folder") parser.add_option('--with-animations', action='store_true', dest='run_animations', default=False, help="Run the animation tests as well as the image ones.") @@ -639,35 +627,43 @@ BLENDER_BIN = options.blender_bin VERBOSE = options.verbose - RUN_ANIMATIONS = options.run_animations - + if options.building_tests: + BLENDER_BIN = GOOD_BLENDER_BIN + OUTPUT_FOLDER = GOOD_FOLDER + GOOD_FOLDER = '' + ANIM_OUTPUT_FOLDER = ANIM_GOOD_FOLDER + ANIM_GOOD_FOLDER = '' + for arg in args: - (argv_directory, argv_file) = os.path.split(arg) - case = ImageTestCase() - OPTIONAL_CASES.append((case, arg, os.path.join(argv_directory, 'render', string.replace(argv_file, '.blend', '.png')), os.path.join(argv_directory, 'output', string.replace(argv_file, '.blend', '')))) - + (directory, file) = os.path.split(arg) + if options.image: + case = ImageTestCase() + optional_cases.append((case, arg, os.path.join(directory, 'render', string.replace(file, '.blend', '_0001.png')), os.path.join(directory, 'output', string.replace(file, '.blend', '')))) + else: + case = AnimationTestCase() + optional_cases.append((case, arg, os.path.join(directory, string.replace(file, '.blend', '')), os.path.join(directory, 'output', string.replace(file, '.blend', '')))) + # Get cases, unless told not to. if len(args) == 0: - cases += get_image_cases(BLEND_FILE_FOLDER, GOOD_FOLDER, OUTPUT_FOLDER) - if RUN_ANIMATIONS: - cases += get_animation_cases(ANIM_BLEND_FILE_FOLDER, ANIM_GOOD_FOLDER, ANIM_OUTPUT_FOLDER) - - if HASHCODE_TEST == True and len(OPTIONAL_CASES) == 0: - cases += get_hash_cases(BLEND_FILE_FOLDER, HASHCODE_FILE, OUTPUT_FOLDER) - if RUN_IMAGES_AND_ANIMATIONS: - cases+=get_hash_cases(ANIM_BLEND_FILE_FOLDER, HASHCODE_FILE, ANIM_OUTPUT_FOLDER) - - if len(OPTIONAL_CASES) > 0: - if BUILDING_TESTS == False: - if HASHCODE_TEST == True: - for case in OPTIONAL_CASES: + if False: + cases += get_hash_cases(BLEND_FILE_FOLDER, HASHCODE_FILE, OUTPUT_FOLDER) + if options.run_animations: + cases+=get_hash_cases(ANIM_BLEND_FILE_FOLDER, HASHCODE_FILE, ANIM_OUTPUT_FOLDER) + else: + cases += get_image_cases(BLEND_FILE_FOLDER, GOOD_FOLDER, OUTPUT_FOLDER) + if options.run_animations: + cases += get_animation_cases(ANIM_BLEND_FILE_FOLDER, ANIM_GOOD_FOLDER, ANIM_OUTPUT_FOLDER) + else: + if options.building_tests == False: + if False: + for case in optional_cases: case[0].setup_hash(case[1], HASHCODE_FILE, case[3]) else: - for case in OPTIONAL_CASES: + for case in optional_cases: case[0].setup_image(case[1], case[2], case[3]) cases.append(case[0]) else: - for case in OPTIONAL_CASES: + for case in optional_cases: case[0].setup_image(case[1], '', case[2]) cases.append(case[0]) @@ -677,18 +673,21 @@ for test_case in cases: print test_case.name + '...', test_case.render_test() - if RUN_IMAGES or RUN_IMAGES_AND_ANIMATIONS: + if not False: test_case.image_test() test_case.save_diff(os.path.join(HTML_OUTPUT, 'output', string.replace(test_case.name, '.blend', '_diff.png'))) - if HASHCODE_TEST or GET_HASHCODES: + if False: test_case.hash_test() - if test_case.passed or BUILDING_TESTS: + if test_case.passed or options.building_tests: print 'OK' else: print 'FAILED' # Output Result - if not BUILDING_TESTS: + if not options.building_tests: print 'Generating Output' generate_output(cases, os.path.join(HTML_OUTPUT, 'index.html')) - console_output(cases) \ No newline at end of file @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs