fukamachi / getac

Quick unit testing tool for competitive programming

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getac

Quick unit testing CLI tool for competitive programming.

Screenshot

Usage

$ getac -h
Usage: getac [options] <file>

OPTIONS:
    -t, --test=<file>
        Specify a file to read test cases. (Default: <file>.txt)
    -f, --filetype=<type>
        File type to test. The default will be detected by the file extension.
    -T, --timeout=<seconds>
        Time limit for each test cases. (Default: 2)
    --disable-colors
        Turn off colors.
    -F, --no-fail-fast
        Don't quit when a failure.
    -V, --version
        Print version.
    -h, --help
        Show help.

# Run with the default Python
$ getac main.py

# Specify test cases
$ getac -t test-cases.in main.py

# Run with PyPy3
$ getac -f pypy3 main.py

Installation

via Homebrew (for macOS/Linux)

Install Homebrew if not already installed.

$ brew tap fukamachi/getac
$ brew install getac

Manually

Install SBCL if not already installed.

$ git clone https://github.com/fukamachi/getac
$ cd getac
$ make
$ sudo make install

Getting started

  1. Write your code in a file (ex. main.py)
a = int(input())
b, c = map(int, input().split())
s = input()
print(a + b + c, s)
  1. Write your test cases in "*.txt" (ex. main.txt)
==== example1 ====
1
2 3
test
--------------
6 test
==== example2 ====
2
3 4
myonmyon
-------
9 myonmyon

See Format of test cases for getting its syntax.

  1. Run getac main.py

Screenshot of successed tests

If some test cases are failed, it shows 'WA' (wrong answer).

Screenshot of failed tests

Format of test cases

Single .txt file

Let's start with this very minimal example which contains a single test case:

Input texts are here...
------------------
Expected result is here...

The input text and its expected results are separated with ---- (more than 4 hyphens).

When you include multiple test cases in the same file, those have to be divided with ==== (more than 4 equal signs).

Input texts are here...
------------------
Expected result is here...
==================
Second test case
------------------
Expected result is here again...

The name of each test cases can be written in the middle of separators, like ==== example1 ====.

Here's the full example:

==== example1 ====
Input texts are here...
------------------
Expected result is here...
==== example2 ====
Second test case
------------------
Expected result is here again...

Separated input/output files

If the single test file couldn't find, getac tries to get from ./test/ and ./tests/ directory, which contains test cases as separated input/output files.

The directory structure is like this:

.
├── main.lisp
└── tests
    ├── sample-1.in
    ├── sample-1.out
    ├── sample-2.in
    └── sample-2.out

Supported languages

  • C
  • C++
  • Clojure
  • Common Lisp
  • Go
  • Haskell
  • Java
  • Node.js
  • Python
  • Ruby
  • Scheme

Author

Copyright

Copyright (c) 2019 Eitaro Fukamachi (e.arrows@gmail.com)

License

See LICENSE.

About

Quick unit testing tool for competitive programming

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Common Lisp 86.6%Language:JavaScript 6.0%Language:Makefile 2.3%Language:Shell 1.0%Language:Java 0.8%Language:C++ 0.7%Language:C 0.6%Language:Haskell 0.5%Language:Clojure 0.4%Language:Go 0.4%Language:Ruby 0.4%Language:Python 0.3%