예제 #1
0
def check_assignment(assignment: Assignment,
                     baseline: Assignment) -> Tuple[int, List[str]]:
    def check(a: Assignment):
        return list(map(execute_with_output, a.create_checks()))

    def change_result_to_mandatory(r: CheckResult):
        return CheckResult(r.result, r.msg, r.output, r.warning,
                           r.should_succeed, r.command, True)

    if assignment != baseline:
        baseline_results = list(
            map(change_result_to_mandatory, check(baseline)))
    else:
        baseline_results = []

    set_assignment_name(assignment.category)

    print_message('executing test \'{}\''.format(assignment.name))

    results = baseline_results + check(assignment)

    set_assignment_name('')

    (grade_value, reasons) = grade(results)

    for reason in reasons:
        print_warning(reason)

    print_grade(grade_value)
예제 #2
0
파일: cli.py 프로젝트: AriezLabs/SE19
def check_assignment(assignment, base_test):
    if assignment[3] != base_test:
        base_test(mandatory=True)

    set_assignment_name(assignment[2])

    print_message('executing test \'{}\''.format(assignment[0]))

    assignment[3]()

    set_assignment_name('')

    grade()
예제 #3
0
def do_bulk_grading(assignment: Optional[Assignment], base_test: Assignment):
    if not os.path.exists(bulk_grade_directory):
        os.mkdir(bulk_grade_directory)

    working_directory = os.getcwd()

    os.chdir(bulk_grade_directory)

    with open(file_with_commit_links, 'rt') as file:
        for line in file.readlines():
            info = parse_commit_url(line)

            if info is None:
                print_message(line + '" is not a valid github commit link')
                continue

            repo_id = '{}/{}'.format(info['user'], info['repo'])

            print_message(repo_id + ': ', end='', loud=True)

            clone_dir = os.path.join(bulk_grade_directory, repo_id)

            if not os.path.exists(clone_dir):
                status = run([
                    'git', 'clone', '-q', '[email protected]:{}'.format(repo_id),
                    repo_id
                ],
                             stdout=DEVNULL,
                             stderr=DEVNULL).returncode

                if status != 0:
                    print_message('error while cloning ' + repo_id, loud=True)
                    continue

            os.chdir(clone_dir)

            # remove all changes in local repository
            run(['git', 'reset', '--hard', '-q'],
                stdout=DEVNULL,
                stderr=DEVNULL)

            # fetch updates from github repository
            run(['git', 'fetch', '-q'], stdout=DEVNULL, stderr=DEVNULL)

            # change the local repository state using the commit ID
            status = run(['git', 'checkout', '-q', info['commit']],
                         stdout=DEVNULL,
                         stderr=DEVNULL).returncode

            if status == 0:
                if assignment is None:
                    print_message('updated', loud=True)
                else:
                    print_message('')
                    check_assignment(assignment, base_test)
                    print_message('', loud=True)
            else:
                print_message('commit hash "{}" is not valid'.format(
                    info['commit']))

            os.chdir(bulk_grade_directory)

    os.chdir(working_directory)

    if bulk_grade_directory is DEFAULT_BULK_GRADE_DIRECTORY:
        os.system('rm -rf {}'.format(bulk_grade_directory))
예제 #4
0
파일: cli.py 프로젝트: AriezLabs/SE19
def do_bulk_grading(assignment, base_test):
    if not os.path.exists(bulk_grade_directory):
        os.mkdir(bulk_grade_directory)

    working_directory = os.getcwd()

    os.chdir(bulk_grade_directory)

    with open(file_with_commit_links, 'rt') as file:
        for line in file.readlines():
            info = parse_commit_url(line)

            if info is None:
                print_message(line + '" is not a valid github commit link')
                continue

            repo_id = '{}/{}'.format(info['user'], info['repo'])

            print_message(repo_id + ': ', end='', loud=True)

            clone_dir = os.path.join(bulk_grade_directory, repo_id)

            if not os.path.exists(clone_dir):
                status = os.system(
                    'git clone -q [email protected]:{} {} >/dev/null 2>&1'.format(
                        repo_id, repo_id))

                if status != 0:
                    print_message('error when cloning ' + repo_id, loud=True)
                    continue

            os.chdir(clone_dir)

            # remove all changes in local repository
            os.system('git reset --hard -q >/dev/null 2>&1')

            # fetch updates from github repository
            os.system('git fetch -q >/dev/null 2>&1')

            # change the local repository state using the commit ID
            status = os.system('git checkout -q {} >/dev/null 2>&1'.format(
                info['commit']))

            if status == 0:
                if assignment is None:
                    print_message('updated', loud=True)
                else:
                    print_message('')
                    check_assignment(assignment, base_test)
                    print_message('', loud=True)
            else:
                print_message('commit hash "{}" is not valid'.format(
                    info['commit']))

            os.chdir(bulk_grade_directory)

    os.chdir(working_directory)

    if bulk_grade_directory is DEFAULT_BULK_GRADE_DIRECTORY:
        os.system('rm -rf {}'.format(bulk_grade_directory))