diff --git a/cmscontrib/loaders/polygon.py b/cmscontrib/loaders/polygon.py
index 29030fc994..99f08f6a99 100644
--- a/cmscontrib/loaders/polygon.py
+++ b/cmscontrib/loaders/polygon.py
@@ -32,6 +32,7 @@
from cms import config
from cms.db import Contest, User, Task, Statement, Dataset, Manager, Testcase
+from cms.grading.languagemanager import HEADER_EXTS, LANGUAGES
from cmscommon.crypto import build_password
from cmscontrib import touch
from .base_loader import ContestLoader, TaskLoader, UserLoader, LANGUAGE_MAP
@@ -44,6 +45,69 @@ def make_timedelta(t):
return timedelta(seconds=t)
+def _format_test_path(pattern, test_number):
+ """Format a Polygon test path pattern for a one-based test number."""
+ try:
+ return pattern % test_number
+ except (TypeError, ValueError) as error:
+ raise ValueError(
+ "Invalid Polygon test path pattern %r: %s" % (pattern, error)
+ ) from error
+
+
+def _package_path(package_dir, relative_path):
+ """Resolve a path taken from a Polygon package.
+
+ Paths in problem.xml are relative to the package directory. Refuse
+ absolute paths and ".." components that would read files outside it.
+
+ """
+ package_dir = os.path.realpath(package_dir)
+ path = os.path.realpath(os.path.join(package_dir, relative_path))
+ if os.path.commonpath([package_dir, path]) != package_dir:
+ raise ValueError(
+ "Path %r points outside the Polygon package" % relative_path)
+ return path
+
+
+def _is_header(filename):
+ """Return whether filename is a header for some CMS language."""
+ return any(filename.endswith(extension) for extension in HEADER_EXTS)
+
+
+def _languages_for_source(filename):
+ """Return the CMS languages that compile sources named like filename."""
+ extension = os.path.splitext(filename)[1]
+ return [language for language in LANGUAGES
+ if extension in language.source_extensions]
+
+
+def _solution_compile_resources(root):
+ """Return the paths of resources Polygon compiles with solutions.
+
+ Polygon exports graders, and the headers they need, as resources with
+ the "compile" stage and the "solution" asset, for example:
+
+
+
+
+
+
+ Other resources, such as testlib.h or olymp.sty, have no such marks.
+
+ """
+ paths = []
+ for resource in root.iterfind("files/resources/file"):
+ stages = {stage.get("name", "").lower()
+ for stage in resource.iterfind("stages/stage")}
+ assets = {asset.get("name", "").lower()
+ for asset in resource.iterfind("assets/asset")}
+ if "compile" in stages and "solution" in assets \
+ and resource.get("path"):
+ paths.append(resource.get("path"))
+ return paths
+
+
class PolygonTaskLoader(TaskLoader):
"""Load a task stored using the Codeforces Polygon format.
@@ -60,7 +124,18 @@ class PolygonTaskLoader(TaskLoader):
Loaders assumes that checker is check.cpp and written with usage of
testlib.h. It provides customized version of testlib.h which allows
using Polygon checkers with CMS. Checkers will be compiled during
- importing the contest.
+ importing the contest. A checker that calls quitp() must report a
+ fraction of the test's score in [0, 1].
+
+ Graders are taken from the resources that problem.xml marks as
+ compiled with solutions. Each grader becomes the CMS manager
+ grader. (for example grader.cpp or grader.py), headers
+ marked the same way are imported under their own names, and the task
+ only allows the languages that have a grader. As usual in CMS, a
+ Python grader is the entry point and must import the contestant's
+ module, which is named after the task.
+
+ Interactive problems are not supported.
"""
@@ -80,14 +155,120 @@ def task_has_changed(self):
"""
return True
+ def _has_interactor(self, root):
+ """Return whether the package contains a Polygon interactor."""
+ if root.find("assets/interactor") is not None:
+ return True
+ return any(os.path.exists(path) for path in (
+ os.path.join(self.path, "files", "interactor.cpp"),
+ os.path.join(self.path, "interactor.cpp"),
+ ))
+
+ def _find_checker(self, root):
+ """Return the path of the checker source, or None if there is none.
+
+ Prefer the source declared in problem.xml, then files/check.cpp,
+ then check.cpp in the package root.
+
+ """
+ source = root.find("assets/checker/source")
+ if source is not None and source.get("path"):
+ path = _package_path(self.path, source.get("path"))
+ if os.path.isfile(path):
+ return path
+ for path in (os.path.join(self.path, "files", "check.cpp"),
+ os.path.join(self.path, "check.cpp")):
+ if os.path.isfile(path):
+ return path
+ return None
+
+ def _find_grader_files(self, root):
+ """Find the graders and headers compiled with solutions.
+
+ return: a dict mapping each CMS manager filename to its source path.
+
+ raise ValueError: if a declared file is missing, has no matching
+ CMS language, or two files map to the same manager.
+
+ """
+ declared = _solution_compile_resources(root)
+ if declared:
+ sources = [_package_path(self.path, path) for path in declared]
+ else:
+ # Hand-made packages may lack the resource metadata. Accept
+ # grader. and the headers next to it, looking in
+ # files/ first like the checker lookup does.
+ sources = []
+ extensions = sorted({language.source_extension
+ for language in LANGUAGES})
+ for directory in (os.path.join(self.path, "files"), self.path):
+ graders = [os.path.join(directory, "grader" + extension)
+ for extension in extensions]
+ graders = [path for path in graders if os.path.isfile(path)]
+ if not graders:
+ continue
+ headers = [os.path.join(directory, filename)
+ for filename in sorted(os.listdir(directory))
+ if _is_header(filename)
+ and filename != "testlib.h"]
+ sources = graders + [path for path in headers
+ if os.path.isfile(path)]
+ break
+
+ files = {}
+ for source in sources:
+ if not os.path.isfile(source):
+ raise ValueError("Grader resource %s is missing" % source)
+ filename = os.path.basename(source)
+ if _is_header(filename):
+ manager_name = filename
+ else:
+ languages = _languages_for_source(filename)
+ if not languages:
+ raise ValueError(
+ "No CMS language compiles the grader %s" % source)
+ manager_name = "grader" + languages[0].source_extension
+ if manager_name in files and files[manager_name] != source:
+ raise ValueError(
+ "Both %s and %s would be imported as manager %s" %
+ (files[manager_name], source, manager_name))
+ files[manager_name] = source
+ return files
+
+ def _compile_checker(self, checker_src, name):
+ """Compile a testlib checker with the patched testlib.h.
+
+ return: the digest of the checker binary, or None on failure.
+
+ """
+ with tempfile.TemporaryDirectory() as tempdir:
+ # We need to override the testlib.h from the polygon
+ # package with our patched version. Since the package
+ # includes a testlib.h too, the easiest way to achieve this
+ # is to copy the checker source to a temporary directory.
+ testlib_res = importlib.resources.files(
+ "cmscontrib.loaders").joinpath("polygon/testlib.h")
+ with testlib_res.open('rb') as src, \
+ open(os.path.join(tempdir, "testlib.h"), "wb") as dst:
+ shutil.copyfileobj(src, dst)
+ new_checker_src = os.path.join(tempdir, "check.cpp")
+ output_path = os.path.join(tempdir, "check")
+ shutil.copyfile(checker_src, new_checker_src)
+ code = subprocess.call(["g++", "-x", "c++", "-O2",
+ "-static", "-DCMS", "-o",
+ output_path, new_checker_src])
+ if code != 0:
+ return None
+ return self.file_cacher.put_file_from_path(
+ output_path, "Manager for task %s" % name)
+
def get_task(self, get_statement=True):
"""See docstring in class Loader.
"""
logger.info("Checking dos2unix presence")
- i = os.system('dos2unix -V 2>/dev/null')
- self.dos2unix_found = (i == 0)
+ self.dos2unix_found = shutil.which("dos2unix") is not None
if not self.dos2unix_found:
logger.error("dos2unix not found - tests will not be converted!")
@@ -106,6 +287,16 @@ def get_task(self, get_statement=True):
tree = ET.parse(os.path.join(self.path, "problem.xml"))
root = tree.getroot()
+ # A Polygon interactor speaks the Polygon file/stdio protocol. CMS
+ # interactive controllers use a different START_SOLUTION protocol and
+ # cannot run this binary as a normal batch checker or manager.
+ if self._has_interactor(root):
+ logger.critical(
+ "Polygon interactors are not supported by the Polygon loader "
+ "(task %s). Convert the interactor to a CMS controller.", name
+ )
+ return None
+
args["name"] = name
args["title"] = str(root.find('names').find("name").attrib['value'])
@@ -144,6 +335,29 @@ def get_task(self, get_statement=True):
# args['token_gen_interval'] = make_timedelta(1800)
# args['token_gen_max'] = 2
+ # Graders and headers do not depend on the testset, so find and
+ # store them once. A grader only exists for some languages (usually
+ # C++), so the task allows just those; cms_conf.py can override it.
+ try:
+ grader_files = self._find_grader_files(root)
+ checker_src = self._find_checker(root)
+ except ValueError as error:
+ logger.critical("Task %s: %s", name, error)
+ return None
+ grader_managers = {}
+ for filename, source in grader_files.items():
+ logger.info("Importing %s as manager %s", source, filename)
+ grader_managers[filename] = self.file_cacher.put_file_from_path(
+ source, "Manager %s for task %s" % (filename, name))
+ grader_languages = [
+ language.name for language in LANGUAGES
+ if "grader%s" % language.source_extension in grader_managers]
+ compilation_param = "grader" if grader_languages else "alone"
+ if grader_languages:
+ logger.info("Task %s uses graders, allowing only: %s",
+ name, ", ".join(grader_languages))
+ args["allowed_languages"] = grader_languages
+
task_cms_conf_path = os.path.join(self.path, 'files', 'cms_conf.py')
task_cms_conf = None
if os.path.exists(task_cms_conf_path):
@@ -157,6 +371,16 @@ def get_task(self, get_statement=True):
task = Task(**args)
+ checker_digest = None
+ if checker_src is not None:
+ logger.info("Checker found, compiling %s", checker_src)
+ checker_digest = self._compile_checker(checker_src, name)
+ if checker_digest is None:
+ logger.critical("Could not compile checker")
+ return None
+ else:
+ logger.info("Checker not found, using diff")
+
judging = root.find('judging')
testset = None
for testset in judging:
@@ -177,48 +401,47 @@ def get_task(self, get_statement=True):
infile_param = judging.attrib['input-file']
outfile_param = judging.attrib['output-file']
- # Checker can be in any of these two locations.
- checker_src = os.path.join(self.path, "files", "check.cpp")
- if not os.path.exists(checker_src):
- checker_src = os.path.join(self.path, "check.cpp")
-
- if os.path.exists(checker_src):
- logger.info("Checker found, compiling")
- with tempfile.TemporaryDirectory() as tempdir:
- # We need to override the testlib.h from the polygon
- # package with our patched version. Since the package
- # includes a testlib.h too, the easiest way to achieve this
- # is to copy the checker source to a temporary directory.
- testlib_res = importlib.resources.files("cmscontrib.loaders").joinpath("polygon/testlib.h")
- with testlib_res.open('rb') as src, open(tempdir + "/testlib.h", "wb") as dst:
- shutil.copyfileobj(src, dst)
- new_checker_src = tempdir + '/check.cpp'
- output_path = tempdir + '/check'
- shutil.copyfile(checker_src, new_checker_src)
- code = subprocess.call(["g++", "-x", "c++", "-O2",
- "-static", "-DCMS", "-o",
- output_path, new_checker_src])
- if code != 0:
- logger.critical("Could not compile checker")
- return None
- digest = self.file_cacher.put_file_from_path(
- output_path,
- "Manager for task %s" % name)
- args["managers"]["checker"] = Manager("checker", digest)
+ for filename, digest in grader_managers.items():
+ args["managers"][filename] = Manager(filename, digest)
+ if checker_digest is not None:
+ args["managers"]["checker"] = Manager("checker",
+ checker_digest)
evaluation_param = "comparator"
else:
- logger.info("Checker not found, using diff")
evaluation_param = "diff"
args["task_type"] = "Batch"
- args["task_type_parameters"] = \
- ["alone", [infile_param, outfile_param], evaluation_param]
+ args["task_type_parameters"] = [
+ compilation_param,
+ [infile_param, outfile_param],
+ evaluation_param,
+ ]
args["score_type"] = "Sum"
total_value = 100.0
input_value = 0.0
- testcases = int(testset.find('test-count').text)
+ test_count = testset.findtext('test-count')
+ if test_count is None:
+ logger.critical(
+ "Testset %s for task %s has no test-count.",
+ testset_name, name)
+ return None
+ try:
+ testcases = int(test_count)
+ except ValueError:
+ logger.critical(
+ "Testset %s for task %s has an invalid test-count %r.",
+ testset_name, name, test_count)
+ return None
+
+ input_pattern = testset.findtext('input-path-pattern')
+ answer_pattern = testset.findtext('answer-path-pattern')
+ if input_pattern is None or answer_pattern is None:
+ logger.critical(
+ "Testset %s for task %s has no input/answer path pattern.",
+ testset_name, name)
+ return None
n_input = testcases
if n_input != 0:
@@ -228,13 +451,23 @@ def get_task(self, get_statement=True):
args["testcases"] = {}
for i in range(testcases):
- infile = os.path.join(self.path, testset_name,
- "%02d" % (i + 1))
- outfile = os.path.join(self.path, testset_name,
- "%02d.a" % (i + 1))
+ try:
+ infile = _package_path(
+ self.path, _format_test_path(input_pattern, i + 1))
+ outfile = _package_path(
+ self.path, _format_test_path(answer_pattern, i + 1))
+ except ValueError as error:
+ logger.critical("%s", error)
+ return None
+ missing = [path for path in (infile, outfile)
+ if not os.path.isfile(path)]
+ if missing:
+ logger.critical(
+ "Testset %s for task %s references missing file(s): %s",
+ testset_name, name, ", ".join(missing))
+ return None
if self.dos2unix_found:
- os.system('dos2unix -q %s' % (infile, ))
- os.system('dos2unix -q %s' % (outfile, ))
+ subprocess.call(["dos2unix", "-q", infile, outfile])
input_digest = self.file_cacher.put_file_from_path(
infile,
"Input %d for task %s" % (i, name))
diff --git a/cmscontrib/loaders/polygon/testlib-cms.patch b/cmscontrib/loaders/polygon/testlib-cms.patch
index cd61fdd8cd..9a713eb4e9 100644
--- a/cmscontrib/loaders/polygon/testlib-cms.patch
+++ b/cmscontrib/loaders/polygon/testlib-cms.patch
@@ -1,29 +1,24 @@
---- testlib.h.orig 2018-12-03 23:31:33.532335025 +0200
-+++ testlib.h 2018-12-04 19:00:42.933212959 +0200
-@@ -41,6 +41,22 @@
- *
- */
+--- testlib.h.orig
++++ testlib.h
+@@ -28,6 +28,17 @@
+ #define VERSION "0.9.51"
-+/*
-+ * Artem Iglikov
-+ * Alexander Kernozhitsky
-+ * Andrey Vihrov
-+ *
+ /*
+ * Modifications for Contest Management System (CMS) support:
+ * - Write checker outcome to stdout and message to stderr
+ * - Use special localizable message strings by default
-+ * - Adjust checker exit code
-+ * - Adjust checker argument order (except in help and comments)
-+ * - Add the "CMS" conditional macro for CMS checker format
-+ * - Add the "CMS_VERBOSE_FEEDBACK" conditional macro to enable
-+ * testlib-style messages
-+ * - Interactors are not supported
++ * - Adjust checker exit code and argument order
++ * - Add the CMS conditional macro for checker format
++ * - Add CMS_VERBOSE_FEEDBACK to opt into testlib-style messages
++ * - Reject quitp() points outside [0, 1], since CMS reads a fraction
++ * - Interactors remain unsupported by this checker adapter
+ */
+
- /* NOTE: This file contains testlib library for C++.
++/*
+ * Mike Mirzayanov
*
- * Check, using testlib running format:
-@@ -2468,6 +2484,57 @@
+ * This material is provided "as is", with absolutely no warranty expressed
+@@ -3117,6 +3128,65 @@ NORETURN void InStream::quit(TResult res
int pctype = result - _partially;
bool isPartial = false;
@@ -40,7 +35,7 @@
+# ifndef CMS_VERBOSE_FEEDBACK
+# define CMS_MSG(code, text) "translate:" code "\n"
+# else
-+# define CMS_MSG(code, text) text " %s\n", msg
++# define CMS_MSG(code, text) text " %s\n", message.c_str()
+# endif
+
+ if (result == _ok) {
@@ -56,53 +51,65 @@
+ std::fprintf(stdout, "0.0\n");
+ std::fprintf(stderr, CMS_MSG(CMS_WRONG, "Wrong Output Format"));
+ } else if (result == _points) {
-+ std::string stringPoints(removeDoubleTrailingZeroes(
-+ format("%.10f", __testlib_points)));
++ if (!(__testlib_points >= 0.0 && __testlib_points <= 1.0)) {
++ std::fprintf(stderr,
++ "FAIL quitp() points must be in [0, 1] for CMS, got %f\n",
++ __testlib_points);
++ halt(1);
++ }
++ char pointsBuffer[64];
++ std::snprintf(pointsBuffer, sizeof(pointsBuffer), "%.10f",
++ __testlib_points);
++ std::string stringPoints(removeDoubleTrailingZeroes(pointsBuffer));
+ std::fprintf(stdout, "%s\n", stringPoints.c_str());
+ std::fprintf(stderr, CMS_MSG(CMS_PARTIAL, "Partial Score"));
+ } else if (result == _unexpected_eof) {
+ std::fprintf(stdout, "0.0\n");
+ std::fprintf(stderr, CMS_MSG(CMS_WRONG, "Unexpected EOF"));
+ } else if (result >= _partially) {
-+ double score = (double)pctype / 200.0;
++ double score = (double) pctype / 200.0;
+ std::fprintf(stdout, "%.3f\n", score);
+ std::fprintf(stderr, CMS_MSG(CMS_PARTIAL, "Partial Score"));
+ } else if (result == _fail) {
-+ std::fprintf(stderr, "FAIL %s\n", msg);
++ std::fprintf(stderr, "FAIL %s\n", message.c_str());
+ halt(1);
+ } else {
-+ std::fprintf(stderr, "FAIL unknown result %d\n", (int)result);
++ std::fprintf(stderr, "FAIL unknown result %d\n", (int) result);
+ halt(1);
+ }
+
+ halt(0);
+#endif
+
- switch (result)
- {
- case _ok:
-@@ -3922,6 +3989,10 @@
+ switch (result) {
+ case _ok:
+ errorName = "ok ";
+@@ -4683,6 +4753,12 @@ void setAppesModeEncoding(std::string va
+ }
- void registerInteraction(int argc, char* argv[])
- {
+ void registerInteraction(int argc, char *argv[]) {
+#ifdef CMS
-+ quit(_fail, "Interactors are not supported");
++ TestlibFinalizeGuard::registered = true;
++ std::fprintf(stderr, "FAIL Interactors are not supported\n");
++ halt(1);
+#endif
+
__testlib_ensuresPreconditions();
+ __testlib_set_testset_and_group(argc, argv);
+ TestlibFinalizeGuard::registered = true;
+@@ -4915,9 +4991,14 @@ void registerTestlibCmd(int argc, char *
+ #endif
- testlibMode = _interactor;
-@@ -4081,8 +4152,13 @@
- }
-
- inf.init(argv[1], _input);
+ inf.init(args[1], _input);
+#ifdef CMS
-+ ouf.init(argv[3], _output);
-+ ans.init(argv[2], _answer);
++ ouf.init(args[3], _output);
++ ans.init(args[2], _answer);
+#else
- ouf.init(argv[2], _output);
- ans.init(argv[3], _answer);
+ ouf.init(args[2], _output);
+- ouf.skipBom();
+ ans.init(args[3], _answer);
+#endif
++ ouf.skipBom();
}
- void registerTestlib(int argc, ...)
+ void registerTestlib(int argc, ...) {
diff --git a/cmscontrib/loaders/polygon/testlib.h b/cmscontrib/loaders/polygon/testlib.h
index 612a439a9d..30e20c1dd7 100644
--- a/cmscontrib/loaders/polygon/testlib.h
+++ b/cmscontrib/loaders/polygon/testlib.h
@@ -1,16 +1,16 @@
-/*
- * It is strictly recommended to include "testlib.h" before any other include
+/*
+ * It is strictly recommended to include "testlib.h" before any other include
* in your code. In this case testlib overrides compiler specific "random()".
*
- * If you can't compile your code and compiler outputs something about
- * ambiguous call of "random_shuffle", "rand" or "srand" it means that
+ * If you can't compile your code and compiler outputs something about
+ * ambiguous call of "random_shuffle", "rand" or "srand" it means that
* you shouldn't use them. Use "shuffle", and "rnd.next()" instead of them
- * because these calls produce stable result for any C++ compiler. Read
+ * because these calls produce stable result for any C++ compiler. Read
* sample generator sources for clarification.
*
* Please read the documentation for class "random_t" and use "rnd" instance in
- * generators. Probably, these sample calls will be usefull for you:
- * rnd.next(); rnd.next(100); rnd.next(1, 2);
+ * generators. Probably, these sample calls will be useful for you:
+ * rnd.next(); rnd.next(100); rnd.next(1, 2);
* rnd.next(3.14); rnd.next("[a-z]{1,100}").
*
* Also read about wnext() to generate off-center random distribution.
@@ -22,18 +22,29 @@
#define _TESTLIB_H_
/*
- * Copyright (c) 2005-2018
+ * Copyright (c) 2005-2026
*/
-#define VERSION "0.9.21"
+#define VERSION "0.9.51"
+
+/*
+ * Modifications for Contest Management System (CMS) support:
+ * - Write checker outcome to stdout and message to stderr
+ * - Use special localizable message strings by default
+ * - Adjust checker exit code and argument order
+ * - Add the CMS conditional macro for checker format
+ * - Add CMS_VERBOSE_FEEDBACK to opt into testlib-style messages
+ * - Reject quitp() points outside [0, 1], since CMS reads a fraction
+ * - Interactors remain unsupported by this checker adapter
+ */
-/*
+/*
* Mike Mirzayanov
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
- * Permission to use or copy this software for any purpose is hereby granted
+ * Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
@@ -41,118 +52,127 @@
*
*/
-/*
- * Artem Iglikov
- * Alexander Kernozhitsky
- * Andrey Vihrov
- *
- * Modifications for Contest Management System (CMS) support:
- * - Write checker outcome to stdout and message to stderr
- * - Use special localizable message strings by default
- * - Adjust checker exit code
- * - Adjust checker argument order (except in help and comments)
- * - Add the "CMS" conditional macro for CMS checker format
- * - Add the "CMS_VERBOSE_FEEDBACK" conditional macro to enable
- * testlib-style messages
- * - Interactors are not supported
- *
- * Backports:
- * - 1bcfacc3a97667b38a3aef9d95b97edc6a9db688 (MikeMirzayanov/testlib#79)
- */
-
/* NOTE: This file contains testlib library for C++.
*
* Check, using testlib running format:
* check.exe [ [-appes]],
* If result file is specified it will contain results.
*
- * Validator, using testlib running format:
+ * Validator, using testlib running format:
* validator.exe < input.txt,
* It will return non-zero exit code and writes message to standard output.
*
- * Generator, using testlib running format:
+ * Generator, using testlib running format:
* gen.exe [parameter-1] [parameter-2] [... paramerter-n]
* You can write generated test(s) into standard output or into the file(s).
*
- * Interactor, using testlib running format:
+ * Interactor, using testlib running format:
* interactor.exe [ [ [-appes]]],
* Reads test from inf (mapped to args[1]), writes result to tout (mapped to argv[2],
* can be judged by checker later), reads program output from ouf (mapped to stdin),
* writes output to program via stdout (use cout, printf, etc).
*/
-const char* latestFeatures[] = {
- "Fixed issue #79: fixed missed guard against repeated header include",
- "Fixed stringstream repeated usage issue",
- "Fixed compilation in g++ (for std=c++03)",
- "Batch of println functions (support collections, iterator ranges)",
- "Introduced rnd.perm(size, first = 0) to generate a `first`-indexed permutation",
- "Allow any whitespace in readInts-like functions for non-validators",
- "Ignore 4+ command line arguments ifdef EJUDGE",
- "Speed up of vtos",
- "Show line number in validators in case of incorrect format",
- "Truncate huge checker/validator/interactor message",
- "Fixed issue with readTokenTo of very long tokens, now aborts with _pe/_fail depending of a stream type",
- "Introduced InStream::ensure/ensuref checking a condition, returns wa/fail depending of a stream type",
- "Fixed compilation in VS 2015+",
- "Introduced space-separated read functions: readWords/readTokens, multilines read functions: readStrings/readLines",
- "Introduced space-separated read functions: readInts/readIntegers/readLongs/readUnsignedLongs/readDoubles/readReals/readStrictDoubles/readStrictReals",
- "Introduced split/tokenize functions to separate string by given char",
- "Introduced InStream::readUnsignedLong and InStream::readLong with unsigned long long paramerters",
- "Supported --testOverviewLogFileName for validator: bounds hits + features",
- "Fixed UB (sequence points) in random_t",
- "POINTS_EXIT_CODE returned back to 7 (instead of 0)",
- "Removed disable buffers for interactive problems, because it works unexpectedly in wine",
- "InStream over string: constructor of InStream from base InStream to inherit policies and std::string",
- "Added expectedButFound quit function, examples: expectedButFound(_wa, 10, 20), expectedButFound(_fail, ja, pa, \"[n=%d,m=%d]\", n, m)",
- "Fixed incorrect interval parsing in patterns",
- "Use registerGen(argc, argv, 1) to develop new generator, use registerGen(argc, argv, 0) to compile old generators (originally created for testlib under 0.8.7)",
- "Introduced disableFinalizeGuard() to switch off finalization checkings",
- "Use join() functions to format a range of items as a single string (separated by spaces or other separators)",
- "Use -DENABLE_UNEXPECTED_EOF to enable special exit code (by default, 8) in case of unexpected eof. It is good idea to use it in interactors",
- "Use -DUSE_RND_AS_BEFORE_087 to compile in compatibility mode with random behavior of versions before 0.8.7",
- "Fixed bug with nan in stringToDouble",
- "Fixed issue around overloads for size_t on x64",
- "Added attribute 'points' to the XML output in case of result=_points",
- "Exit codes can be customized via macros, e.g. -DPE_EXIT_CODE=14",
- "Introduced InStream function readWordTo/readTokenTo/readStringTo/readLineTo for faster reading",
- "Introduced global functions: format(), englishEnding(), upperCase(), lowerCase(), compress()",
- "Manual buffer in InStreams, some IO speed improvements",
- "Introduced quitif(bool, const char* pattern, ...) which delegates to quitf() in case of first argument is true",
- "Introduced guard against missed quitf() in checker or readEof() in validators",
- "Supported readStrictReal/readStrictDouble - to use in validators to check strictly float numbers",
- "Supported registerInteraction(argc, argv)",
- "Print checker message to the stderr instead of stdout",
- "Supported TResult _points to output calculated score, use quitp(...) functions",
- "Fixed to be compilable on Mac",
- "PC_BASE_EXIT_CODE=50 in case of defined TESTSYS",
- "Fixed issues 19-21, added __attribute__ format printf",
- "Some bug fixes",
- "ouf.readInt(1, 100) and similar calls return WA",
- "Modified random_t to avoid integer overflow",
- "Truncated checker output [patch by Stepan Gatilov]",
- "Renamed class random -> class random_t",
- "Supported name parameter for read-and-validation methods, like readInt(1, 2, \"n\")",
- "Fixed bug in readDouble()",
- "Improved ensuref(), fixed nextLine to work in case of EOF, added startTest()",
- "Supported \"partially correct\", example: quitf(_pc(13), \"result=%d\", result)",
- "Added shuffle(begin, end), use it instead of random_shuffle(begin, end)",
- "Added readLine(const string& ptrn), fixed the logic of readLine() in the validation mode",
- "Package extended with samples of generators and validators",
- "Written the documentation for classes and public methods in testlib.h",
- "Implemented random routine to support generators, use registerGen() to switch it on",
- "Implemented strict mode to validate tests, use registerValidation() to switch it on",
- "Now ncmp.cpp and wcmp.cpp are return WA if answer is suffix or prefix of the output",
- "Added InStream::readLong() and removed InStream::readLongint()",
- "Now no footer added to each report by default (use directive FOOTER to switch on)",
- "Now every checker has a name, use setName(const char* format, ...) to set it",
- "Now it is compatible with TTS (by Kittens Computing)",
- "Added \'ensure(condition, message = \"\")\' feature, it works like assert()",
- "Fixed compatibility with MS C++ 7.1",
- "Added footer with exit code information",
- "Added compatibility with EJUDGE (compile with EJUDGE directive)",
- "Added compatibility with Contester (compile with CONTESTER directive)"
- };
+const char *latestFeatures[] = {
+ "InStream::unreadChar(char) puts back bytes 0x80..0xFF as data (0xFF no longer becomes EOF); EOF cannot be put back through it",
+ "No shadowing warnings from testlib.h: g++ -Wshadow, clang++ -Wshadow-all, MSVC C4456-C4459",
+ "readLine()/readString(): a CR right before EOF no longer appends a 0xFF byte to the line",
+ "Byte 0xFF in input is data, not EOF: EOFC is -1 now, readers return bytes as unsigned char",
+ "testlib format()/println() work with using namespace std; call std::format/std::println explicitly for standard formatting",
+ "Remove incorrect const attributes",
+ "Added ConstantBoundsLog, VariablesLog to validator testOverviewLogFile",
+ "Use setAppesModeEncoding to change xml encoding from windows-1251 to other",
+ "rnd.any/wany use distance/advance instead of -/+: now they support sets/multisets",
+ "Use syntax `int t = inf.readInt(1, 3, \"~t\");` to skip the lower bound check. Tildes can be used on either side or both: ~t, t~, ~t~",
+ "Supported EJUDGE support in registerTestlibCmd",
+ "Supported '--testMarkupFileName fn' and '--testCase tc/--testCaseFileName fn' for validators",
+ "Added opt defaults via opt(key/index, default_val); check unused opts when using has_opt or default opt (turn off this check with suppressEnsureNoUnusedOpt()).",
+ "For checker added --group and --testset command line params (like for validator), use checker.group() or checker.testset() to get values",
+ "Added quitpi(points_info, message) function to return with _points exit code 7 and given points_info",
+ "rnd.partition(size, sum[, min_part=1]) returns random (unsorted) partition which is a representation of the given `sum` as a sum of `size` positive integers (or >=min_part if specified)",
+ "rnd.distinct(size, n) and rnd.distinct(size, from, to)",
+ "opt(\"some_missing_key\") returns false now",
+ "has_opt(key)",
+ "Abort validator on validator.testset()/validator.group() if registered without using command line",
+ "Print integer range violations in a human readable way like `violates the range [1, 10^9]`",
+ "Opts supported: use them like n = opt(\"n\"), in a command line you can use an exponential notation",
+ "Reformatted",
+ "Use setTestCase(i) or unsetTestCase() to support test cases (you can use it in any type of program: generator, interactor, validator or checker)",
+ "Fixed issue #87: readStrictDouble accepts \"-0.00\"",
+ "Fixed issue #83: added InStream::quitif(condition, ...)",
+ "Fixed issue #79: fixed missed guard against repeated header include",
+ "Fixed issue #80: fixed UB in case of huge quitf message",
+ "Fixed issue #84: added readXs(size, indexBase = 1)",
+ "Fixed stringstream repeated usage issue",
+ "Fixed compilation in g++ (for std=c++03)",
+ "Batch of println functions (support collections, iterator ranges)",
+ "Introduced rnd.perm(size, first = 0) to generate a `first`-indexed permutation",
+ "Allow any whitespace in readInts-like functions for non-validators",
+ "Ignore 4+ command line arguments ifdef EJUDGE",
+ "Speed up of vtos",
+ "Show line number in validators in case of incorrect format",
+ "Truncate huge checker/validator/interactor message",
+ "Fixed issue with readTokenTo of very long tokens, now aborts with _pe/_fail depending of a stream type",
+ "Introduced InStream::ensure/ensuref checking a condition, returns wa/fail depending of a stream type",
+ "Fixed compilation in VS 2015+",
+ "Introduced space-separated read functions: readWords/readTokens, multilines read functions: readStrings/readLines",
+ "Introduced space-separated read functions: readInts/readIntegers/readLongs/readUnsignedLongs/readDoubles/readReals/readStrictDoubles/readStrictReals",
+ "Introduced split/tokenize functions to separate string by given char",
+ "Introduced InStream::readUnsignedLong and InStream::readLong with unsigned long long parameters",
+ "Supported --testOverviewLogFileName for validator: bounds hits + features",
+ "Fixed UB (sequence points) in random_t",
+ "POINTS_EXIT_CODE returned back to 7 (instead of 0)",
+ "Removed disable buffers for interactive problems, because it works unexpectedly in wine",
+ "InStream over string: constructor of InStream from base InStream to inherit policies and std::string",
+ "Added expectedButFound quit function, examples: expectedButFound(_wa, 10, 20), expectedButFound(_fail, ja, pa, \"[n=%d,m=%d]\", n, m)",
+ "Fixed incorrect interval parsing in patterns",
+ "Use registerGen(argc, argv, 1) to develop new generator, use registerGen(argc, argv, 0) to compile old generators (originally created for testlib under 0.8.7)",
+ "Introduced disableFinalizeGuard() to switch off finalization checkings",
+ "Use join() functions to format a range of items as a single string (separated by spaces or other separators)",
+ "Use -DENABLE_UNEXPECTED_EOF to enable special exit code (by default, 8) in case of unexpected eof. It is good idea to use it in interactors",
+ "Use -DUSE_RND_AS_BEFORE_087 to compile in compatibility mode with random behavior of versions before 0.8.7",
+ "Fixed bug with nan in stringToDouble",
+ "Fixed issue around overloads for size_t on x64",
+ "Added attribute 'points' to the XML output in case of result=_points",
+ "Exit codes can be customized via macros, e.g. -DPE_EXIT_CODE=14",
+ "Introduced InStream function readWordTo/readTokenTo/readStringTo/readLineTo for faster reading",
+ "Introduced global functions: format(), englishEnding(), upperCase(), lowerCase(), compress()",
+ "Manual buffer in InStreams, some IO speed improvements",
+ "Introduced quitif(bool, const char* pattern, ...) which delegates to quitf() in case of first argument is true",
+ "Introduced guard against missed quitf() in checker or readEof() in validators",
+ "Supported readStrictReal/readStrictDouble - to use in validators to check strictly float numbers",
+ "Supported registerInteraction(argc, argv)",
+ "Print checker message to the stderr instead of stdout",
+ "Supported TResult _points to output calculated score, use quitp(...) functions",
+ "Fixed to be compilable on Mac",
+ "PC_BASE_EXIT_CODE=50 in case of defined TESTSYS",
+ "Fixed issues 19-21, added __attribute__ format printf",
+ "Some bug fixes",
+ "ouf.readInt(1, 100) and similar calls return WA",
+ "Modified random_t to avoid integer overflow",
+ "Truncated checker output [patch by Stepan Gatilov]",
+ "Renamed class random -> class random_t",
+ "Supported name parameter for read-and-validation methods, like readInt(1, 2, \"n\")",
+ "Fixed bug in readDouble()",
+ "Improved ensuref(), fixed nextLine to work in case of EOF, added startTest()",
+ "Supported \"partially correct\", example: quitf(_pc(13), \"result=%d\", result)",
+ "Added shuffle(begin, end), use it instead of random_shuffle(begin, end)",
+ "Added readLine(const string& ptrn), fixed the logic of readLine() in the validation mode",
+ "Package extended with samples of generators and validators",
+ "Written the documentation for classes and public methods in testlib.h",
+ "Implemented random routine to support generators, use registerGen() to switch it on",
+ "Implemented strict mode to validate tests, use registerValidation() to switch it on",
+ "Now ncmp.cpp and wcmp.cpp are return WA if answer is suffix or prefix of the output",
+ "Added InStream::readLong() and removed InStream::readLongint()",
+ "Now no footer added to each report by default (use directive FOOTER to switch on)",
+ "Now every checker has a name, use setName(const char* format, ...) to set it",
+ "Now it is compatible with TTS (by Kittens Computing)",
+ "Added \'ensure(condition, message = \"\")\' feature, it works like assert()",
+ "Fixed compatibility with MS C++ 7.1",
+ "Added footer with exit code information",
+ "Added compatibility with EJUDGE (compile with EJUDGE directive)",
+ "Added compatibility with Contester (compile with CONTESTER directive)"
+};
#ifdef _MSC_VER
#define _CRT_SECURE_NO_DEPRECATE
@@ -175,6 +195,7 @@ const char* latestFeatures[] = {
#include