Exemplo n.º 1
0
def update_testrun__bad(db, filename_persist, testrun_props_by_candidate, snapshots_dir, snapshots_reference_dir=None):
    """
    snapshots_reference_dir : dir to move snapshots; if None no move
    """

    if snapshots_reference_dir:
        if not os.path.isdir(snapshots_dir):
            raise ValueError("snapshot dir not found or not a dir:%s" % snapshots_dir)
        if not os.path.exists(snapshots_reference_dir):
            os.makedirs(snapshots_reference_dir)

    checked_in, ignored, unknown = _update_testrun(db, testrun_props_by_candidate, snapshots_dir)

    move_failed = set()
    if snapshots_reference_dir:
        # move snapshots to reference dir
        for script in checked_in:
            snapshots = db.get_prop_value(script, "expected_snapshots")
            moved, cant_move = doers.move_files(snapshots, snapshots_dir, snapshots_reference_dir)
            if cant_move:
                move_failed.add(script)

    # update history
    text_1 = doers.pprint_to_string(checked_in)
    text_2 = doers.pprint_to_string(move_failed)
    text_3 = doers.pprint_to_string(unknown)
    text_history = "\n".join(["checked_in:", text_1, "move_failed:", text_2, "unknown:", text_3])
    db.history_add("update_testrun__bad", text_history)

    if filename_persist:
        dbm.db_save(db, filename_persist)

    return checked_in, unknown, move_failed
Exemplo n.º 2
0
def update_testrun__pass(db,
                         filename_persist,
                         candidates,
                         snapshots_dir,
                         snapshots_reference_dir=None):
    """
    snapshots_reference_dir : dir to move snapshots; if None no move
    """

    if snapshots_reference_dir:
        if not os.path.isdir(snapshots_dir):
            raise ValueError("snapshot dir not found or not a dir:%s" %
                             snapshots_dir)
        if not os.path.exists(snapshots_reference_dir):
            os.makedirs(snapshots_reference_dir)

    pass_dict = {
        'testrun_success': 'pass',
        'testrun_diagnostic': '',
    }

    testrun_props_by_candidate = dict([(k, pass_dict) for k in candidates])
    checked_in, ignored, unknown = _update_testrun(db,
                                                   testrun_props_by_candidate,
                                                   snapshots_dir)

    move_failed = set()
    if snapshots_reference_dir:
        # move snapshots to reference dir
        for script in checked_in:
            snapshots = db.get_prop_value(script, 'expected_snapshots')
            moved, cant_move = doers.move_files(snapshots, snapshots_dir,
                                                snapshots_reference_dir)
            if cant_move:
                db.del_groupdict(script, 'testrun')
                move_failed.add(script)

    checked_in -= move_failed

    # update history
    text_1 = doers.pprint_to_string(checked_in)
    text_2 = doers.pprint_to_string(move_failed)
    text_3 = doers.pprint_to_string(unknown)
    text_history = '\n'.join(
        ["checked_in:", text_1, "move_failed:", text_2, "unknown:", text_3])
    db.history_add("update_testrun__pass", text_history)

    if filename_persist:
        dbm.db_save(db, filename_persist)

    return checked_in, unknown, move_failed
Exemplo n.º 3
0
def rpt_all_props(db, candidates, testbed=None):
    scripts, unknowns = db.entities(candidates=candidates)
    text_parts = []
    separator = '-' * 78
    for name in scripts:
        text_parts.append(name)
        text = doers.pprint_to_string(db.get_propdict(name, testbed=testbed))
        text_parts.append(text)
        text_parts.append(separator)
    if unknowns:
        text_parts.append('unknown entities')
        text_parts.append(doers.pprint_to_string(unknowns))
    text = '\n'.join(text_parts)
    return text
Exemplo n.º 4
0
def rpt_all_props(db, candidates, testbed=None):
    scripts, unknowns = db.entities(candidates=candidates)
    text_parts = []
    separator = '-' * 78
    for name in scripts:
        text_parts.append(name)
        text = doers.pprint_to_string(db.get_propdict(name, testbed=testbed))
        text_parts.append(text)
        text_parts.append(separator)
    if unknowns:
        text_parts.append('unknown entities')
        text_parts.append(doers.pprint_to_string(unknowns))
    text = '\n'.join(text_parts)
    return text
Exemplo n.º 5
0
def update_testrun__pass(db, filename_persist, candidates,
                         snapshots_dir, snapshots_reference_dir=None):
    """
    snapshots_reference_dir : dir to move snapshots; if None no move
    """
    
    if snapshots_reference_dir:
        if not os.path.isdir(snapshots_dir):
            raise ValueError("snapshot dir not found or not a dir:%s"%snapshots_dir)
        if not os.path.exists(snapshots_reference_dir):
            os.makedirs(snapshots_reference_dir)

    pass_dict = {
        'testrun_success': 'pass',
        'testrun_diagnostic': '',
        }

    testrun_props_by_candidate = dict([(k, pass_dict) for k in candidates])
    checked_in, ignored, unknown = _update_testrun(db, testrun_props_by_candidate,
                                                   snapshots_dir)

    move_failed = set()
    if snapshots_reference_dir:
        # move snapshots to reference dir 
        for script in checked_in:
            snapshots = db.get_prop_value(script, 'expected_snapshots')
            moved, cant_move = doers.move_files(snapshots, snapshots_dir,
                                                snapshots_reference_dir)
            if cant_move:
                db.del_groupdict(script, 'testrun')
                move_failed.add(script)

    checked_in -= move_failed

    # update history
    text_1 = doers.pprint_to_string(checked_in)
    text_2 = doers.pprint_to_string(move_failed)
    text_3 = doers.pprint_to_string(unknown)
    text_history = '\n'.join(["checked_in:", text_1,
                              "move_failed:", text_2,
                              "unknown:", text_3
                              ])
    db.history_add("update_testrun__pass", text_history)

    if filename_persist:
        dbm.db_save(db, filename_persist)
    
    return checked_in, unknown, move_failed
Exemplo n.º 6
0
def update_testrun__bad(db,
                        filename_persist,
                        testrun_props_by_candidate,
                        snapshots_dir,
                        snapshots_reference_dir=None):
    """
    snapshots_reference_dir : dir to move snapshots; if None no move
    """
    if snapshots_reference_dir:
        if not os.path.isdir(snapshots_dir):
            fmt = "snapshot dir not found or not a dir:%s"
            raise ValueError(fmt % snapshots_dir)
        if not os.path.exists(snapshots_reference_dir):
            os.makedirs(snapshots_reference_dir)

    checked_in, ignored, unknown = _update_testrun(db,
                                                   testrun_props_by_candidate,
                                                   snapshots_dir)

    move_failed = set()
    if snapshots_reference_dir:
        # move snapshots to reference dir
        for script in checked_in:
            snapshots = db.get_prop_value(script, 'expected_snapshots')
            moved, cant_move = doers.move_files(snapshots, snapshots_dir,
                                                snapshots_reference_dir)
            if cant_move:
                move_failed.add(script)

    # update history
    text_1 = doers.pprint_to_string(checked_in)
    text_2 = doers.pprint_to_string(move_failed)
    text_3 = doers.pprint_to_string(unknown)
    text_history = '\n'.join(
        ["checked_in:", text_1, "move_failed:", text_2, "unknown:", text_3])
    db.history_add("update_testrun__bad", text_history)

    if filename_persist:
        dbm.db_save(db, filename_persist)

    return checked_in, unknown, move_failed
Exemplo n.º 7
0
def new_testbed(db, testbed, basepath):
    """Creates, initializes (and set as db's default_tesbed) a testbed

    :Parameters:
        `db` : remembercases.TestbedEntityPropDB
            The db where the testbed will be added.
        `testbed` : str
            name for the new testbed; if duplicates an existing name an
            dbm.ErrorDuplicatedTestbed will be raised and the db will not
            be modified.            
        `basepath` : str
            directory name that will be the testbed's basepath

    After the testbed is created, it is set as the db's default_testbed.
    
    The testbed is initialized by adding some group of props, and their
    props are added to the testbed.

    An entry "new_testbed" with details about the operation is added to the
    db history.

    The testbed basepath will be used to calculate the canonical name for
    entities in the testbed that are files.
    The canonical name is the the relative path from basepath, with '/'
    path separators irrespective to the os.sep
    No check is performed over the basepath parameter.
    
    """
    db.add_testbed(testbed, basepath)
    db.set_default_testbed(testbed)

    default_groups = {
        "scan" : [
            # script can't be loaded
            'IOerror',
            
            # hints behavior, based on script's text
            'timedependent',
            'interactive',
            'uses_random',
            'has_testinfo', # string 'testinfo' present, maybe theres a real testinfo

            # secondary behavior hints, combination of above
            'static',

            # testinfo
            'testinfo',
            'expected_snapshots',
            'testinfo_diagnostic',
            'md5_at_testinfo',
            ],
        
        "snapshots_capture": [
            'snapshots_success',
            'snapshots_diagnostic',
            'missing_snapshots',
            ],
        
        "testrun": [
            'testrun_success', # 'pass', 'fail', 'error'
            'testrun_diagnostic',
            'testrun_md5'
            ]
        }
    
    for groupname in default_groups:
        db.add_group(groupname, default_groups[groupname], addprops=True)

    # add to history
    text_history = ("testbed: %s\nbasepath: %s\n\n"%(testbed, basepath) +
                    "\nAdded prop groups:\n" + doers.pprint_to_string(default_groups))
    db.history_add("new_testbed", text_history)
Exemplo n.º 8
0
def new_testbed(db, testbed, basepath):
    """Creates, initializes (and set as db's default_tesbed) a testbed

    :Parameters:
        `db` : remembercases.TestbedEntityPropDB
            The db where the testbed will be added.
        `testbed` : str
            name for the new testbed; if duplicates an existing name an
            dbm.ErrorDuplicatedTestbed will be raised and the db will not
            be modified.            
        `basepath` : str
            directory name that will be the testbed's basepath

    After the testbed is created, it is set as the db's default_testbed.
    
    The testbed is initialized by adding some group of props, and their
    props are added to the testbed.

    An entry "new_testbed" with details about the operation is added to the
    db history.

    The testbed basepath will be used to calculate the canonical name for
    entities in the testbed that are files.
    The canonical name is the the relative path from basepath, with '/'
    path separators irrespective to the os.sep
    No check is performed over the basepath parameter.
    
    """
    db.add_testbed(testbed, basepath)
    db.set_default_testbed(testbed)

    default_groups = {
        "scan": [
            # script can't be loaded
            'IOerror',

            # hints behavior, based on script's text
            'timedependent',
            'interactive',
            'uses_random',
            'has_testinfo',  # string 'testinfo' present, maybe theres a real testinfo

            # secondary behavior hints, combination of above
            'static',

            # testinfo
            'testinfo',
            'expected_snapshots',
            'testinfo_diagnostic',
            'md5_at_testinfo',
        ],
        "snapshots_capture": [
            'snapshots_success',
            'snapshots_diagnostic',
            'missing_snapshots',
        ],
        "testrun": [
            'testrun_success',  # 'pass', 'fail', 'error'
            'testrun_diagnostic',
            'testrun_md5'
        ]
    }

    for groupname in default_groups:
        db.add_group(groupname, default_groups[groupname], addprops=True)

    # add to history
    text_history = ("testbed: %s\nbasepath: %s\n\n" % (testbed, basepath) +
                    "\nAdded prop groups:\n" +
                    doers.pprint_to_string(default_groups))
    db.history_add("new_testbed", text_history)