Commit b361c5ce19a05ce8da60c767651521a9ce0210e5
1 parent
7604ac5c
Add --test-json-schema command-line option
Showing
11 changed files
with
41 additions
and
7 deletions
include/qpdf/QPDFJob.hh
| @@ -633,6 +633,7 @@ class QPDFJob | @@ -633,6 +633,7 @@ class QPDFJob | ||
| 633 | int json_version; | 633 | int json_version; |
| 634 | std::set<std::string> json_keys; | 634 | std::set<std::string> json_keys; |
| 635 | std::set<std::string> json_objects; | 635 | std::set<std::string> json_objects; |
| 636 | + bool test_json_schema; | ||
| 636 | bool check; | 637 | bool check; |
| 637 | bool optimize_images; | 638 | bool optimize_images; |
| 638 | bool externalize_inline_images; | 639 | bool externalize_inline_images; |
include/qpdf/auto_job_c_main.hh
| @@ -43,6 +43,7 @@ QPDF_DLL Config* staticAesIv(); | @@ -43,6 +43,7 @@ QPDF_DLL Config* staticAesIv(); | ||
| 43 | QPDF_DLL Config* staticId(); | 43 | QPDF_DLL Config* staticId(); |
| 44 | QPDF_DLL Config* suppressPasswordRecovery(); | 44 | QPDF_DLL Config* suppressPasswordRecovery(); |
| 45 | QPDF_DLL Config* suppressRecovery(); | 45 | QPDF_DLL Config* suppressRecovery(); |
| 46 | +QPDF_DLL Config* testJsonSchema(); | ||
| 46 | QPDF_DLL Config* verbose(); | 47 | QPDF_DLL Config* verbose(); |
| 47 | QPDF_DLL Config* warningExit0(); | 48 | QPDF_DLL Config* warningExit0(); |
| 48 | QPDF_DLL Config* withImages(); | 49 | QPDF_DLL Config* withImages(); |
job.sums
| @@ -3,15 +3,15 @@ generate_auto_job 0514289f2deb3bf7c1a6e85ef7d99ad120321ef5a6fe49d76c5274c6a658d3 | @@ -3,15 +3,15 @@ generate_auto_job 0514289f2deb3bf7c1a6e85ef7d99ad120321ef5a6fe49d76c5274c6a658d3 | ||
| 3 | include/qpdf/auto_job_c_att.hh 4c2b171ea00531db54720bf49a43f8b34481586ae7fb6cbf225099ee42bc5bb4 | 3 | include/qpdf/auto_job_c_att.hh 4c2b171ea00531db54720bf49a43f8b34481586ae7fb6cbf225099ee42bc5bb4 |
| 4 | include/qpdf/auto_job_c_copy_att.hh 50609012bff14fd82f0649185940d617d05d530cdc522185c7f3920a561ccb42 | 4 | include/qpdf/auto_job_c_copy_att.hh 50609012bff14fd82f0649185940d617d05d530cdc522185c7f3920a561ccb42 |
| 5 | include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a349e0cd4ae17ddd5 | 5 | include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a349e0cd4ae17ddd5 |
| 6 | -include/qpdf/auto_job_c_main.hh 4ba9bcb8be945f6a3ffa0df3becdb8488b6eaf45dd914d8b714d948e17b5ad5d | 6 | +include/qpdf/auto_job_c_main.hh 940aa6f1ead18ed08ba33f11254e9f042348262c85b91de742f0427094412a80 |
| 7 | include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c18911614fe8e568ec | 7 | include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c18911614fe8e568ec |
| 8 | include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1 | 8 | include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1 |
| 9 | -job.yml c2937bb06818fc3bffe54c6c069a4a06db7f3c841958c2da1b2f4a33978fd24a | 9 | +job.yml 3c130913b3546f272c06b334ece9aa70450449539db10e39673b5ee79d863f48 |
| 10 | libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df | 10 | libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df |
| 11 | -libqpdf/qpdf/auto_job_help.hh a7d7edc3b270f2488778426646bb68dcad036727db4be87d1da9993e2a007634 | ||
| 12 | -libqpdf/qpdf/auto_job_init.hh 6bd71c2ae4ba80e81fe5ae5517ba72abf53a3146f66864f99eeebc7d224998a5 | 11 | +libqpdf/qpdf/auto_job_help.hh a3d1a326a3f8ff61a7d451176acde3bb6c8ad66c1ea7a0b8c5d789917ad3a9ee |
| 12 | +libqpdf/qpdf/auto_job_init.hh c8477a597f037d7de5fd131b008a75f1fe435bba248261abe422e8bfb24c8755 | ||
| 13 | libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297 | 13 | libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297 |
| 14 | -libqpdf/qpdf/auto_job_json_init.hh 06d51f11c117011256e175386eee9946441f3c22b49dd91fc591bbc1fa3bbeec | ||
| 15 | -libqpdf/qpdf/auto_job_schema.hh 43273b9edfc48b1f4cccbff1d2b31916a9057c474ef97d2936b2f1f14170885b | 14 | +libqpdf/qpdf/auto_job_json_init.hh e7047a7c83737adfaae49abc295a579bb9b9e0a4644e911d1656a604cb202208 |
| 15 | +libqpdf/qpdf/auto_job_schema.hh cbbcae166cfecbdbdeb40c5a30870e03604a019a8b4f7a217d554a82431d2e5f | ||
| 16 | manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580 | 16 | manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580 |
| 17 | -manual/cli.rst 70258db13d89b0476248e9703bf5f50ffe28fce2a179dfeca241582dd28b455c | 17 | +manual/cli.rst 8a5a12351df6a42f91d6d271b2d065a843d8daa5125d8723d474e4180d7abbf1 |
job.yml
| @@ -127,6 +127,7 @@ options: | @@ -127,6 +127,7 @@ options: | ||
| 127 | - static-id | 127 | - static-id |
| 128 | - suppress-password-recovery | 128 | - suppress-password-recovery |
| 129 | - suppress-recovery | 129 | - suppress-recovery |
| 130 | + - test-json-schema | ||
| 130 | - underlay | 131 | - underlay |
| 131 | - verbose | 132 | - verbose |
| 132 | - warning-exit-0 | 133 | - warning-exit-0 |
| @@ -352,6 +353,7 @@ json: | @@ -352,6 +353,7 @@ json: | ||
| 352 | keep-files-open-threshold: | 353 | keep-files-open-threshold: |
| 353 | no-warn: | 354 | no-warn: |
| 354 | verbose: | 355 | verbose: |
| 356 | + test-json-schema: | ||
| 355 | ignore-xref-streams: | 357 | ignore-xref-streams: |
| 356 | password-is-hex-key: | 358 | password-is-hex-key: |
| 357 | password-mode: | 359 | password-mode: |
libqpdf/QPDFJob.cc
| @@ -400,6 +400,7 @@ QPDFJob::Members::Members() : | @@ -400,6 +400,7 @@ QPDFJob::Members::Members() : | ||
| 400 | flatten_rotation(false), | 400 | flatten_rotation(false), |
| 401 | list_attachments(false), | 401 | list_attachments(false), |
| 402 | json_version(0), | 402 | json_version(0), |
| 403 | + test_json_schema(false), | ||
| 403 | check(false), | 404 | check(false), |
| 404 | optimize_images(false), | 405 | optimize_images(false), |
| 405 | externalize_inline_images(false), | 406 | externalize_inline_images(false), |
libqpdf/QPDFJob_config.cc
| @@ -261,6 +261,13 @@ QPDFJob::Config::jsonObject(std::string const& parameter) | @@ -261,6 +261,13 @@ QPDFJob::Config::jsonObject(std::string const& parameter) | ||
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | QPDFJob::Config* | 263 | QPDFJob::Config* |
| 264 | +QPDFJob::Config::testJsonSchema() | ||
| 265 | +{ | ||
| 266 | + o.m->test_json_schema = true; | ||
| 267 | + return this; | ||
| 268 | +} | ||
| 269 | + | ||
| 270 | +QPDFJob::Config* | ||
| 264 | QPDFJob::Config::keepFilesOpen(std::string const& parameter) | 271 | QPDFJob::Config::keepFilesOpen(std::string const& parameter) |
| 265 | { | 272 | { |
| 266 | o.m->keep_files_open_set = true; | 273 | o.m->keep_files_open_set = true; |
libqpdf/qpdf/auto_job_help.hh
| @@ -835,6 +835,12 @@ Write the first pass of linearization to the named file. The | @@ -835,6 +835,12 @@ Write the first pass of linearization to the named file. The | ||
| 835 | resulting file is not a valid PDF file. This option is useful only | 835 | resulting file is not a valid PDF file. This option is useful only |
| 836 | for debugging qpdf. | 836 | for debugging qpdf. |
| 837 | )"); | 837 | )"); |
| 838 | +ap.addOptionHelp("--test-json-schema", "testing", "test generated json against schema", R"(This is used by qpdf's test suite to check consistency between | ||
| 839 | +the output of qpdf --json and the output of qpdf --json-help. | ||
| 840 | +)"); | ||
| 841 | +} | ||
| 842 | +static void add_help_8(QPDFArgParser& ap) | ||
| 843 | +{ | ||
| 838 | } | 844 | } |
| 839 | static void add_help(QPDFArgParser& ap) | 845 | static void add_help(QPDFArgParser& ap) |
| 840 | { | 846 | { |
| @@ -845,6 +851,7 @@ static void add_help(QPDFArgParser& ap) | @@ -845,6 +851,7 @@ static void add_help(QPDFArgParser& ap) | ||
| 845 | add_help_5(ap); | 851 | add_help_5(ap); |
| 846 | add_help_6(ap); | 852 | add_help_6(ap); |
| 847 | add_help_7(ap); | 853 | add_help_7(ap); |
| 854 | + add_help_8(ap); | ||
| 848 | ap.addHelpFooter("For detailed help, visit the qpdf manual: https://qpdf.readthedocs.io\n"); | 855 | ap.addHelpFooter("For detailed help, visit the qpdf manual: https://qpdf.readthedocs.io\n"); |
| 849 | } | 856 | } |
| 850 | 857 |
libqpdf/qpdf/auto_job_init.hh
| @@ -77,6 +77,7 @@ this->ap.addBare("static-aes-iv", [this](){c_main->staticAesIv();}); | @@ -77,6 +77,7 @@ this->ap.addBare("static-aes-iv", [this](){c_main->staticAesIv();}); | ||
| 77 | this->ap.addBare("static-id", [this](){c_main->staticId();}); | 77 | this->ap.addBare("static-id", [this](){c_main->staticId();}); |
| 78 | this->ap.addBare("suppress-password-recovery", [this](){c_main->suppressPasswordRecovery();}); | 78 | this->ap.addBare("suppress-password-recovery", [this](){c_main->suppressPasswordRecovery();}); |
| 79 | this->ap.addBare("suppress-recovery", [this](){c_main->suppressRecovery();}); | 79 | this->ap.addBare("suppress-recovery", [this](){c_main->suppressRecovery();}); |
| 80 | +this->ap.addBare("test-json-schema", [this](){c_main->testJsonSchema();}); | ||
| 80 | this->ap.addBare("underlay", b(&ArgParser::argUnderlay)); | 81 | this->ap.addBare("underlay", b(&ArgParser::argUnderlay)); |
| 81 | this->ap.addBare("verbose", [this](){c_main->verbose();}); | 82 | this->ap.addBare("verbose", [this](){c_main->verbose();}); |
| 82 | this->ap.addBare("warning-exit-0", [this](){c_main->warningExit0();}); | 83 | this->ap.addBare("warning-exit-0", [this](){c_main->warningExit0();}); |
libqpdf/qpdf/auto_job_json_init.hh
| @@ -267,6 +267,9 @@ popHandler(); // key: noWarn | @@ -267,6 +267,9 @@ popHandler(); // key: noWarn | ||
| 267 | pushKey("verbose"); | 267 | pushKey("verbose"); |
| 268 | addBare([this]() { c_main->verbose(); }); | 268 | addBare([this]() { c_main->verbose(); }); |
| 269 | popHandler(); // key: verbose | 269 | popHandler(); // key: verbose |
| 270 | +pushKey("testJsonSchema"); | ||
| 271 | +addBare([this]() { c_main->testJsonSchema(); }); | ||
| 272 | +popHandler(); // key: testJsonSchema | ||
| 270 | pushKey("ignoreXrefStreams"); | 273 | pushKey("ignoreXrefStreams"); |
| 271 | addBare([this]() { c_main->ignoreXrefStreams(); }); | 274 | addBare([this]() { c_main->ignoreXrefStreams(); }); |
| 272 | popHandler(); // key: ignoreXrefStreams | 275 | popHandler(); // key: ignoreXrefStreams |
libqpdf/qpdf/auto_job_schema.hh
| @@ -89,6 +89,7 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ | @@ -89,6 +89,7 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ | ||
| 89 | "keepFilesOpenThreshold": "set threshold for keepFilesOpen", | 89 | "keepFilesOpenThreshold": "set threshold for keepFilesOpen", |
| 90 | "noWarn": "suppress printing of warning messages", | 90 | "noWarn": "suppress printing of warning messages", |
| 91 | "verbose": "print additional information", | 91 | "verbose": "print additional information", |
| 92 | + "testJsonSchema": "test generated json against schema", | ||
| 92 | "ignoreXrefStreams": "use xref tables rather than streams", | 93 | "ignoreXrefStreams": "use xref tables rather than streams", |
| 93 | "passwordIsHexKey": "provide hex-encoded encryption key", | 94 | "passwordIsHexKey": "provide hex-encoded encryption key", |
| 94 | "passwordMode": "tweak how qpdf encodes passwords", | 95 | "passwordMode": "tweak how qpdf encodes passwords", |
manual/cli.rst
| @@ -3327,6 +3327,16 @@ Related Options | @@ -3327,6 +3327,16 @@ Related Options | ||
| 3327 | inspection of the file before values calculated in pass 1 are | 3327 | inspection of the file before values calculated in pass 1 are |
| 3328 | inserted into the file for pass 2. | 3328 | inserted into the file for pass 2. |
| 3329 | 3329 | ||
| 3330 | +.. qpdf:option:: --test-json-schema | ||
| 3331 | + | ||
| 3332 | + .. help: test generated json against schema | ||
| 3333 | + | ||
| 3334 | + This is used by qpdf's test suite to check consistency between | ||
| 3335 | + the output of qpdf --json and the output of qpdf --json-help. | ||
| 3336 | + | ||
| 3337 | + This is used by qpdf's test suite to check consistency between the | ||
| 3338 | + output of ``qpdf --json`` and the output of ``qpdf --json-help``. | ||
| 3339 | + | ||
| 3330 | .. _unicode-passwords: | 3340 | .. _unicode-passwords: |
| 3331 | 3341 | ||
| 3332 | Unicode Passwords | 3342 | Unicode Passwords |