Build tooling work, commits C65d-C75: pdf-lib shim gate, impexp parity, one command-line convention - #213
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Puts a test around the book's pdf-lib shims and the two
impexpeditions, then gives every Node tool in the repository the same command-line behaviour: the same--help, the same refusal of a bad command line, and the same exit codes.fast-dict-onebuf.mjsreplaced six of pdf-lib's eight factories forPDFDict,PDFCatalog,PDFPageTreeandPDFPageLeaf. The other two,PDFPageTree.withContextandPDFPageLeaf.withContextAndParent, still built on aMap, soinsertPage,addPageandPDFDocument.createfailed under the shim. Both are replaced now. Stock and shimmed pdf-lib give the same bytes forcreate,addPage,insertPage,drawTextandsave. The book never adds a page, so it was not affected.check_pdf_shims_equiv(new, intest.bat, the shared CI action and Tools.md) loads, changes and saves one generated document with stock pdf-lib and with the shims, in child processes, and compares the two files object by object with streams inflated. A second pair builds a document withPDFDocument.create. It also lists the 72 members of pdf-lib the shims patch, and fails when a listed member is not patched, a patched one is not listed, an unmarked one never runs, or a marked one runs. Only the twocontextsetters stay marked as unreached. Today it reports the same 25 objects for the loaded document and the same 11 for the created one. It runs in about 0.5 s.computeBufferSizeoverrides infast-sync-load.mjsare deleted. No storage change forced them, the measurements found no reliable gain, andParallelStreamWriteroverrides the method on the book's only path.book/lib/pdf-lib-internals.mjsholds the 33 pdf-lib internals the shims import (44 before the unused ones went), replacing acreateRequireblock repeated in nine shims.book/lib/onebuf-range.mjsholds the range machinery the two onebuf shims had copied.book/lib/shim-targets.mjsgives each shim a load-time check of the members it overwrites (arity and a source fingerprint, 78 targets), so a changed pdf-lib throws naming the shim instead of being patched silently.book.htmlbefore and after the onebuf change give 2,299 pages and 2,466 outline entries each, in the same time within noise. The files differ only in/CreationDateand/ModDate, and in a byte of deflate size in some renders.check_impexp_parity(new) runs both--self-testsuites (19 tests each) and then 21 commands throughimpexp.mjsandimpexp.pyon the repository's fixtures, comparing exit code, output and written files byte for byte. Without Python it reports itself skipped and passes; withCI=trueit fails. About 4 s.test.batis now fifteen steps, and CI runs the gates the wrappers run.--helpand-hby printing usage to stdout and exiting 0, with no side effect. Before,gen_attribute_probestook--helpas its output folder and created--help/Sources,render-bookrejected it, and twelve tools ignored it.check_links's tolerance for stray flags and its unused--threadsare gone. A term that starts with a dash goes after--. Onlytbdocs's--baseurlmay be empty. Two hazards close with it:build_corpus --dest ""removed the current folder, andconvert_em_dash_separators --chekrewrotedocs/.lib/cli.mjsgainschoiceOption,regexOption,urlOption,dateOptionandrefuseTogether, and every number goes throughnumberOption. This closes cases such ascrawl_check --concurrency abcandaddin_test --jobs abc, which looped for ever,addin_test's andrun_case's timeout of 0 or text, which killed every child at once, andtbdocs --url foo, which crashed partway through the build. Conflicting options are refused, for example--showwith--hide, and two ofcheck_examples's modes.build_corpusrefuses a--destthat is or contains the repository root, the current folder or--src.tbdocsandcheck_linksexit 0 clean, 1 when the build or check found a problem of any kind, and 2 on a refused command line or a crash, like every other tool. They gave a bitmask (1, 2, 3 and 4) that nothing read: the wrappers testerrorlevel 1, and CI andcompare_treestest non-zero.tbdocs's stall watchdog and a failed--servestart now exit 2 as well.--jsonnow always means "print to stdout" and--srcalways means a documentation root.check_a11y_fingerprint's--json FILEis--out FILE.census_attributesandbuild_package_apitake--exported <dir>for the package tree.build_corpusandnav_hopstake--repo, since their--srcnamed a repository root that holdsdocs/. The threeperf/rigs follow. The old spellings are refused as unknown options.Exit codes:block, and its Tools.md section (oreval/README.md, or Wisdom.md) ends with the same codes. The convention is 0 clean, 1 a finding, 2 the tool could not do its job, and a tool's own codes above 2. Three codes that meant two things are split:addin_testexits 3 when the registry or a work folder was not put back,wisdomexits 3 when it reaches its request cap, andtbrunexits 4 when the compiler crashed, astbbuilddoes. Several tools that exited 1 when they could not run now exit 2, and a crash exits 2 in every tool;exitOnCrashmoved intolib/cli.mjsfor that.addin_testputs the registry and the add-ins' settings back when it crashes, not only at the end of a normal run. The crash path ends the lanes, waits up to 10 s for them, and runs the same put-back. It exits 2, or 3 if the put-back found a problem. Before, a crash left the user's registry changed.tbdocs's exit code, as the other wrappers do. With its port held, it now exits 2 where it exited 0.eval/README.mdand the WIP notes are updated to match. Tools.md now names--exportedfor the two package tools.builder/PLAN-TOOLING-REVIEW.mdare cut to what later work needs. Their full text stays in history.check_cligrows from 258 to 860 probes: a--helpcase and an empty-folder probe for every tool, an unknown-flag case for all 45 tools, empty-value and bad-value cases, and a probe that each tool's--helpends with exactly one exit-code table. Faults put intolib/cli.mjsfailed 69 of 568 probes (unknown-option refusal) and 88 of 810 (numberOption).test.batalso gained the two new gates named above.