Package: bapctools
BAPCtoolsBAPCtools is a tool for creating and developing problems following the
CLICS (DOMjudge/Kattis) problem format specifiedhere.The aim of this tool is to run all necessary compilation, validation, and
testing commands while working on an ICPC-style problem.
Ideally one should never have to manually run any compilation or testing command themselves.I'm interested to know who's using this, so feel free to inform me (e.g. via an issue) if so ;)
The current state is relatively stable, but things do change from time to
time since I'm not aware of usage outside of BAPC yet.InstallationYou can install thebapctools-git AUR
package, mirroredhere, or use theDocker
image.Otherwise, clone this repository and install the required dependencies manually.
(If you know how to make a Debian package, feel free to help out.)Python 3 (>= 3.6).Theyaml libraryviapip install pyyamlor thepython[3]-yamlArch Linux package.Thecolorama libraryviapip install coloramaor thepython[3]-coloramaArch Linux package.Theargcompletelibrary for command line argument completion. Install viapython[3]-argcomplete.Note that actually usingargcompleteis optional, but recommended.
Detailed instructions arehere.TL;DR: Puteval "$(register-python-argcomplete[3] tools.py)"in your.bashrcor.zshrc.Optional dependencies, required for some subcommands:Theruamel.yaml libraryviapip install ruamel.yamlor thepython[3]-ruamel-yamlArch Linux package.This is only needed for commands that updategenerators.yaml.Thelatexmkandpdflatexcommands, provided bytexlive-binon Arch Linux and
potentially some specific LaTeX packages (like tikz) provided bytexlive-extra.
These are only needed for buildingpdffiles, not forrunandvalidateand such.After cloning the repository, symlinkbin/tools.pyto somewhere in your$PATH. E.g., if~/bin/is in your$PATH, you can do:% ln -s ~/git/BAPCtools/bin/tools.py ~/bin/btWindowsFor Windows, you'll need the following in yourpath:Pythonfor Python 3g++to compile C++javacandjavato compile and runjava.Resource limits (memory limit/hard cpu time limit) are also not supported.BAPCtools makes use of symlinks for building programs. By default users are not allowed to create symlinks on Windows.
This can be fixed by enabling Developer Mode on Windows (Only works for Windows 10, version 1703 or newer).(TODO: Copy instead of symlink files when symlinking is not allowed.)DockerA docker image containing this git repo and dependencies, together with commonly
used languages, is provided atragnargrootkoerkamp/bacptools.
This version may be somewhat outdated. Ping me if you'd like it to be updated.This image can be used for e.g.:running CI on your repo. Also seebt gitlabciwhich generates a.gitlab-ci.yamlfile. Make sure to clear the entrypoint, e.g.entrypoint: [""].runningbton your local problems. Use this command to mount your local
directory into the docker image and run a command on it:docker run -v $PWD:/data --rm -it ragnargrootkoerkamp/bapctools <bt subcommands>UsageBAPCtools can be run either from a problem directory or a contest directory. This
is automatically detected by searching for theproblem.yamlfile.The most common commands and options to use on an existing repository are:bt run [-v] [submissions [submissions ...]] [testcases [testcases ...]]bt test <submission> [--interactive | --samples | [testcases [testcases ...]]]bt generate [-v] [--jobs JOBS]bt validate [-v] [--remove | --move-to DIR] [testcases [testcases ...]]bt pdf [-v]The list of all available commands and options is atdoc/commands.md#synopsis,
and more information regarding the implementation is atdoc/implementation_notes.md.Runbt run [-v] [submissions [submissions ...]] [testcases [testcases ...]]Without arguments, theruncommand runs all submissions against all testcases.
Specify one or more submissions and one or more testcases to only run the given submissions against the given testcases.Before running the given submissions, this command first makes sure that all generated testcases are up to date (in casegenerators/generators.yamlwas found).By default,bt runonly prints one summary line per submission, and one additional line for each testcase with an unexpected result. Use-vto print one line per testcase instead.Testbt test <submission> [--samples | [testcases [testcases ...]]]Use thetestcommand to run a single submission on some testcases. The submissionstdoutandstderrare printed to the terminal instead of verified as an answer file.
Use--samplesto run on the samples, or pass a list of testcases or directories containing testcases. Use--interactive/-ito run in interactive mode, where console input is forwarded to the submission.
This rebuilds and reruns the program until eithercontrol-Corcontrol-Dis pressed. It's also possible to supply the test case on the command line directly using e.g.< /path/to/file.inor<<< "10 20".Generatebt generate [-v] [--jobs JOBS]Use thegeneratecommand to generate the testcases specified ingenerators/generators.yaml. Seedoc/generators.mdfor the specification ofgenerators.yamland seedoc/commands.md#generatefor the full list of arguents.
Use-j 0to disable running multiple jobs in parallel (the default is4).Validatebt validate [-v] [--remove | --move-to DIR] [testcases [testcases ...]]Validate all the.inand.ansfor all (given) testcases. It runs all validators frominput_validatorsandoutput_validators.Validators can be one ofa single-file program.a multi-file program with all files in a common directory.a .ctd CheckTestData file (this needs thechecktestdataexecutable in your$PATH).a .viva file.You can use--removeto delete all failing testcases or--move <dir>to move
them to a separate directory.Pdfbt pdf [-v]Use this command to compile theproblem.pdffrom theproblem_statement/problem.en.texLaTeX statement.problem.pdfis written to the problem directory itself.This can also be used to create the contest pdf by running it from the contest directory.Contributing / Style guideThe python code in the repository is formatted usingblack.
To enable the pre-commit hook, installpre-commitwithpipor your package manager (Arch:python-pre-commit) and runpre-commit installfrom the repository root. All python code will now automatically be formatted
on each commit.Imports are usually ordered with system libraries first, followed by a
newline, followed by local includes. Both groups are sorted alphabetically,
andimportcomes beforefrom ... import.