2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-01 03:12:29 +00:00

Add --test-json-schema command-line option

This commit is contained in:
Jay Berkenbilt 2022-05-06 17:29:22 -04:00
parent 7604ac5cb2
commit b361c5ce19
11 changed files with 41 additions and 7 deletions

View File

@ -633,6 +633,7 @@ class QPDFJob
int json_version;
std::set<std::string> json_keys;
std::set<std::string> json_objects;
bool test_json_schema;
bool check;
bool optimize_images;
bool externalize_inline_images;

View File

@ -43,6 +43,7 @@ QPDF_DLL Config* staticAesIv();
QPDF_DLL Config* staticId();
QPDF_DLL Config* suppressPasswordRecovery();
QPDF_DLL Config* suppressRecovery();
QPDF_DLL Config* testJsonSchema();
QPDF_DLL Config* verbose();
QPDF_DLL Config* warningExit0();
QPDF_DLL Config* withImages();

View File

@ -3,15 +3,15 @@ generate_auto_job 0514289f2deb3bf7c1a6e85ef7d99ad120321ef5a6fe49d76c5274c6a658d3
include/qpdf/auto_job_c_att.hh 4c2b171ea00531db54720bf49a43f8b34481586ae7fb6cbf225099ee42bc5bb4
include/qpdf/auto_job_c_copy_att.hh 50609012bff14fd82f0649185940d617d05d530cdc522185c7f3920a561ccb42
include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a349e0cd4ae17ddd5
include/qpdf/auto_job_c_main.hh 4ba9bcb8be945f6a3ffa0df3becdb8488b6eaf45dd914d8b714d948e17b5ad5d
include/qpdf/auto_job_c_main.hh 940aa6f1ead18ed08ba33f11254e9f042348262c85b91de742f0427094412a80
include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c18911614fe8e568ec
include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1
job.yml c2937bb06818fc3bffe54c6c069a4a06db7f3c841958c2da1b2f4a33978fd24a
job.yml 3c130913b3546f272c06b334ece9aa70450449539db10e39673b5ee79d863f48
libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df
libqpdf/qpdf/auto_job_help.hh a7d7edc3b270f2488778426646bb68dcad036727db4be87d1da9993e2a007634
libqpdf/qpdf/auto_job_init.hh 6bd71c2ae4ba80e81fe5ae5517ba72abf53a3146f66864f99eeebc7d224998a5
libqpdf/qpdf/auto_job_help.hh a3d1a326a3f8ff61a7d451176acde3bb6c8ad66c1ea7a0b8c5d789917ad3a9ee
libqpdf/qpdf/auto_job_init.hh c8477a597f037d7de5fd131b008a75f1fe435bba248261abe422e8bfb24c8755
libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297
libqpdf/qpdf/auto_job_json_init.hh 06d51f11c117011256e175386eee9946441f3c22b49dd91fc591bbc1fa3bbeec
libqpdf/qpdf/auto_job_schema.hh 43273b9edfc48b1f4cccbff1d2b31916a9057c474ef97d2936b2f1f14170885b
libqpdf/qpdf/auto_job_json_init.hh e7047a7c83737adfaae49abc295a579bb9b9e0a4644e911d1656a604cb202208
libqpdf/qpdf/auto_job_schema.hh cbbcae166cfecbdbdeb40c5a30870e03604a019a8b4f7a217d554a82431d2e5f
manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580
manual/cli.rst 70258db13d89b0476248e9703bf5f50ffe28fce2a179dfeca241582dd28b455c
manual/cli.rst 8a5a12351df6a42f91d6d271b2d065a843d8daa5125d8723d474e4180d7abbf1

View File

@ -127,6 +127,7 @@ options:
- static-id
- suppress-password-recovery
- suppress-recovery
- test-json-schema
- underlay
- verbose
- warning-exit-0
@ -352,6 +353,7 @@ json:
keep-files-open-threshold:
no-warn:
verbose:
test-json-schema:
ignore-xref-streams:
password-is-hex-key:
password-mode:

View File

@ -400,6 +400,7 @@ QPDFJob::Members::Members() :
flatten_rotation(false),
list_attachments(false),
json_version(0),
test_json_schema(false),
check(false),
optimize_images(false),
externalize_inline_images(false),

View File

@ -260,6 +260,13 @@ QPDFJob::Config::jsonObject(std::string const& parameter)
return this;
}
QPDFJob::Config*
QPDFJob::Config::testJsonSchema()
{
o.m->test_json_schema = true;
return this;
}
QPDFJob::Config*
QPDFJob::Config::keepFilesOpen(std::string const& parameter)
{

View File

@ -835,6 +835,12 @@ Write the first pass of linearization to the named file. The
resulting file is not a valid PDF file. This option is useful only
for debugging qpdf.
)");
ap.addOptionHelp("--test-json-schema", "testing", "test generated json against schema", R"(This is used by qpdf's test suite to check consistency between
the output of qpdf --json and the output of qpdf --json-help.
)");
}
static void add_help_8(QPDFArgParser& ap)
{
}
static void add_help(QPDFArgParser& ap)
{
@ -845,6 +851,7 @@ static void add_help(QPDFArgParser& ap)
add_help_5(ap);
add_help_6(ap);
add_help_7(ap);
add_help_8(ap);
ap.addHelpFooter("For detailed help, visit the qpdf manual: https://qpdf.readthedocs.io\n");
}

View File

@ -77,6 +77,7 @@ this->ap.addBare("static-aes-iv", [this](){c_main->staticAesIv();});
this->ap.addBare("static-id", [this](){c_main->staticId();});
this->ap.addBare("suppress-password-recovery", [this](){c_main->suppressPasswordRecovery();});
this->ap.addBare("suppress-recovery", [this](){c_main->suppressRecovery();});
this->ap.addBare("test-json-schema", [this](){c_main->testJsonSchema();});
this->ap.addBare("underlay", b(&ArgParser::argUnderlay));
this->ap.addBare("verbose", [this](){c_main->verbose();});
this->ap.addBare("warning-exit-0", [this](){c_main->warningExit0();});

View File

@ -267,6 +267,9 @@ popHandler(); // key: noWarn
pushKey("verbose");
addBare([this]() { c_main->verbose(); });
popHandler(); // key: verbose
pushKey("testJsonSchema");
addBare([this]() { c_main->testJsonSchema(); });
popHandler(); // key: testJsonSchema
pushKey("ignoreXrefStreams");
addBare([this]() { c_main->ignoreXrefStreams(); });
popHandler(); // key: ignoreXrefStreams

View File

@ -89,6 +89,7 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({
"keepFilesOpenThreshold": "set threshold for keepFilesOpen",
"noWarn": "suppress printing of warning messages",
"verbose": "print additional information",
"testJsonSchema": "test generated json against schema",
"ignoreXrefStreams": "use xref tables rather than streams",
"passwordIsHexKey": "provide hex-encoded encryption key",
"passwordMode": "tweak how qpdf encodes passwords",

View File

@ -3327,6 +3327,16 @@ Related Options
inspection of the file before values calculated in pass 1 are
inserted into the file for pass 2.
.. qpdf:option:: --test-json-schema
.. help: test generated json against schema
This is used by qpdf's test suite to check consistency between
the output of qpdf --json and the output of qpdf --json-help.
This is used by qpdf's test suite to check consistency between the
output of ``qpdf --json`` and the output of ``qpdf --json-help``.
.. _unicode-passwords:
Unicode Passwords