1. Daniel Ampuero
  2. Judge Tools

Overview

HTTPS SSH

Judge tools for automatic test case generation

Autor:"Daniel Ampuero" <danielmaxx@gmail.com>
Versión:1.0 13/07/2012

Installation

In order to install this Python package, you must perform the following comands:

$ sudo python3 setup.py install

This packages requires Python 3.

What is this about?

This is a Python package that deals with the problem of test case generation for a programming constest. Given a configuration file, this package does:

  • Generates inputs
  • Validates those inputs
  • Generates an output from a supposed valid solution
  • Runs alternatives solutions to validate the output of the supposed valid solution

For doing this, you must write a configuration file. An example is given below:

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import judge_tools.test_driver as jtest

languages = {
  "C":  jtest.Language(
    name = "C",
    extension = "c",
    source_name = "{directory}-{solution}.{extension}",
    executable_name = "{directory}-{solution}.exe",
    compile_script = [["gcc", "-O2", "-o", "{executable}", "{source}"]],
    execute_script = [["./{executable}"]]),

  "C++":  jtest.Language(
    name = "C++",
    extension = "cpp",
    source_name = "{directory}-{solution}.{extension}",
    executable_name = "{directory}-{solution}.exe",
    compile_script = [["g++", "-O2", "-o", "{executable}", "{source}"]],
    execute_script = [["./{executable}"]]),

  "Java":  jtest.Language(
    name = "Java",
    extension = "java",
    source_name = "{directory}-{solution}.{extension}",
    executable_name = "Main.class",
    compile_script = [["javac", "-g:none", "{source}"]],
    execute_script = [["java", "-server", "-Xss8m", "-Xmx512m", "Main", "{input}", "{output}"]]),

  "python2":  jtest.Language(
    name = "python2",
    extension = "py2",
    source_name = "{directory}-{solution}.{extension}",
    execute_script = [["python2",  "{source}"]]),

  "python3":  jtest.Language(
    name = "python3",
    extension = "py3",
    source_name = "{directory}-{solution}.{extension}",
    execute_script = [["python3",  "{source}"]]),
}

#Any source must be placed on a directory called problems/<problem-name>
problems = {
  "<problem-name>": jtest.Problem(
    name = "<problem-name>",
    directory = "<problem-directory>",
    generator = [["./generator-<problem-name>.py", "{problem}.in"]], #{problem} will be replaced with <problem-name>
    validator = [["./validator-<problem-name>.py", "{problem}.in"]],
    valid_solution = jtest.Solution(
      name = "<problem-name>-<author-name>",
      language = languages["C++"],
      redirect_stdin = True,
      redirect_stdout = True),
    test_solutions = (jtest.Solution(
        name = "<problem-name>-<author-name>",
        language = languages["Java"],
        redirect_stdin = True,
        redirect_stdout = True),
    )),
}
jtest.test_problems(problems)