def compare_testbeds_by_entities(db1_fname, db1_testbed, db2_fname, db2_testbed): db1 = dbm.db_load(db1_fname, default_testbed=db1_testbed) db2 = dbm.db_load(db2_fname, default_testbed=db2_testbed) ents1, unknown = db1.entities() ents2, unknown = db2.entities() common_entities = ents1 & ents2 only_in_1 = ents1 - common_entities only_in_2 = ents2 - common_entities f1 = db1.get_propdict f2 = db2.get_propdict equals = set([entity for entity in common_entities if f1(entity) == f2(entity)]) differents = common_entities - equals return common_entities, only_in_1, only_in_2, equals, differents
def compare_testbeds_by_entities(db1_fname, db1_testbed, db2_fname, db2_testbed): db1 = dbm.db_load(db1_fname, default_testbed=db1_testbed) db2 = dbm.db_load(db2_fname, default_testbed=db2_testbed) ents1, unknown = db1.entities() ents2, unknown = db2.entities() common_entities = ents1 & ents2 only_in_1 = ents1 - common_entities only_in_2 = ents2 - common_entities f1 = db1.get_propdict f2 = db2.get_propdict equals = set( [entity for entity in common_entities if f1(entity) == f2(entity)]) differents = common_entities - equals return common_entities, only_in_1, only_in_2, equals, differents
def new(db_fname, testbed, stats_fname, candidates, limit, samples_dir): db = dbm.db_load(db_fname, default_testbed=testbed) # test stats_fname writable with open(stats_fname, 'wb') as f: f.write("hello") res = hl.measure_repeteability(db, candidates, limit, samples_dir) #overal_md5, elapsed, rounds, stats_by_script_name, stats_by_snapshot_name = res session = db_fname, testbed, samples_dir, res with open(stats_fname, 'wb') as f: pickle.dump(session, f)
def new(db_fname, testbed, stats_fname, candidates, limit, samples_dir): db = dbm.db_load(db_fname, default_testbed=testbed) # test stats_fname writable with open(stats_fname, 'wb') as f: f.write("hello".encode('utf-8')) res = hl.measure_repeteability(db, candidates, limit, samples_dir) #overal_md5, elapsed, rounds, stats_by_script_name, stats_by_snapshot_name = res session = db_fname, testbed, samples_dir, res with open(stats_fname, 'wb') as f: pickle.dump(session, f, 2)
def report(stats_fname, rpt_function): (db_fname, testbed, samples_dir, overal_md5, elapsed, rounds, stats_by_script_name, stats_by_snapshot_name) = load_stats(stats_fname) db = dbm.db_load(db_fname, default_testbed=testbed) res_expand = expand_stats(db, rounds, stats_by_script_name, stats_by_snapshot_name) text = rpt_function(elapsed, rounds, res_expand, verbose=False) return text
def report(stats_fname, rpt_function): (db_fname, testbed, samples_dir, overal_md5, elapsed, rounds, stats_by_script_name, stats_by_snapshot_name ) = load_stats(stats_fname) db = dbm.db_load(db_fname, default_testbed=testbed) res_expand = expand_stats(db, rounds, stats_by_script_name, stats_by_snapshot_name) text = rpt_function(elapsed, rounds, res_expand, verbose=False) return text
def report(stats_fname, rpt_function): # load with open(stats_fname, 'rb') as f: session = pickle.load(f) db_fname, testbed, samples_dir, res = session _, elapsed, rounds, stats_by_script_name, stats_by_snapshot_name = res db = dbm.db_load(db_fname, default_testbed=testbed) res_expand = expand_stats(db, rounds, stats_by_script_name, stats_by_snapshot_name) text = rpt_compact(elapsed, rounds, res_expand, verbose=False) return text
def new_db(filename_persist=None): """Instantiates and saves a new db :Parameters: `filename_persist` : str filename used to persist the new db, defaults to None if filename_persist is None, the new db is not stored to disk If file exists a ValueError is raised. The new db is an instance of remembercases.TestbedEntityPropDB. The stored db is retrieved to ensure it can be read. """ if filename_persist and os.path.exists(filename_persist): msg = "initial_recon refuses to overwrite an existing file: %s" msg = msg % filename_persist raise ValueError(msg) db = dbm.TestbedEntityPropDB() if filename_persist: dbm.db_save(db, filename_persist) new = dbm.db_load(filename_persist) return db
## test/test_waves_vertical.py ## """ #debug text = """ test/test_sprite.py test/test_base.py test/test_subscene_events.py """ # sanity checks diagnostic = '' if not os.path.exists(snapshots_reference_dir): diagnostic = "Snapshots references dir not found:%s" % snapshots_reference_dir db = dbm.db_load(filename_persist, default_testbed=testbed) candidates = doers.scripts_names_from_text(text, end_mark=':') knowns, unknowns = db.entities(fn_allow=None, candidates=candidates) if unknowns: msg = '\n'.join(unknowns) diagnostic = "Unknown scripts:\n" + msg if diagnostic: sys.stderr.write(diagnostic) sys.exit(1) # payload equals, unequals, untested = hl.snapshots_compare(db, fn_snapshots_dist, threshold, candidates, tries, snapshots_reference_dir, samples_dir)
text = """ test/test_action_non_interval.py test/test_animation.py test/test_rect.py test/test_scrolling_manager_without_tiles.py test/test_scrolling_manager_without_tiles_autoscale.py test/test_tiles_autotest.py test/test_tmx_autotest.py """ # sanity checks diagnostic = '' if not os.path.exists(snapshots_reference_dir): diagnostic = "Snapshots references dir not found:%s"%snapshots_reference_dir db = dbm.db_load(filename_persist, default_testbed=testbed) ##knowns, unknowns = db.entities(fn_allow=hl.fn_allow_testrun_pass, candidates=None) candidates = doers.scripts_names_from_text(text, end_mark=':') knowns, unknowns = db.entities(fn_allow=None, candidates=candidates) if unknowns: msg = '\n'.join(unknowns) diagnostic = "Unknown scripts:\n" + msg if diagnostic: sys.stderr.write(diagnostic) sys.exit(1) # payload equals, unequals, untested = hl.snapshots_compare(db, fn_snapshots_dist, threshold, knowns, tries,
def ensure_db(db_path): if os.path.isfile(db_path): db = dbm.db_load(db_path) else: db = new_db(db_path) return db