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 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.º 4
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