. "$BST_LIB" # BST-TIMEOUT: 1200 # THREE python3 starts, and they are the whole cost. # # Everything else reads the filesystem or dpkg with shell # # builtins, or greps one probe transcript. # # # # The three: a bare `import typogrify', a second import # # whose STDERR is the assertion, and the probe -- which # # takes ONE start for 81 measurements, upstream's own 40 # # doctests among them. # # # # The work inside a start is regex substitution over three # # dozen fixtures under 200 characters, plus doctest.testmod # # over filters.py, which measures 0.01s on the x86-64 # # control. Microseconds beside an interpreter start on this # # arm, which is tens of seconds before the first line of the # # program runs. # # # # 1200 is 400s per start, against the ~60s a python3 start # # has measured at here. The start dominates and nothing in # # this file is quadratic in anything. # # # # NOT MEASURED ON TARGET YET: this port's first on-target # # run is the batch verify. The measured elapsed goes in the # # test plan rather than in this comment, which would cost an # # image build to keep the shipped suite byte-identical. # # python3-typogrify 2.0.7 (poky/meta recipes-devtools/python/ # python3-typogrify_2.0.7.bb, `inherit pypi setuptools3', PyPI sdist unmodified, # plus a meta-brintos bbappend that adds one RDEPENDS) on the wasm32-hwjs glibc # image. # # ============================================================================ # WHAT THE PACKAGE DOES. # ============================================================================ # # typogrify applies typographic conventions to HTML. Six filters do the work and # `typogrify()' composes them: # # amp a free-standing `&' becomes & # caps a run of two or more capitals becomes # initial_quotes a block's OPENING quote becomes # smartypants straight quotes and dashes become curly entities # titlecase Title Case, with small words left lowercase # widont the space between a block's last two words becomes   # # The point of each is that it must know when a character is NOT what it looks # like -- an `&' inside a tag attribute is not text, a capital run inside a # ') # == '' # # which is a inserted into JavaScript -- upstream's behaviour, not # this image's, and asserted as such rather than as a fault of the port. The # repair is asserted beside it (`tg-script-ignored', with ignore_tags), so the # pair says which reading is the library's default and which is the caller's. # # `caps' ALONE does skip more CAPS'" \ "$(pv caps_script_skipped)" # A single capital is not a run; two is the minimum. check_eq $P/caps-single-letter-untouched \ "'A single I is not caps'" "$(pv caps_single_letter)" # -------------------------------------------------------- initial_quotes --- check_eq $P/iq-double \ "'\"With primes\"'" "$(pv iq_double)" check_eq $P/iq-single \ "'\\'With single primes\\''" "$(pv iq_single)" check_eq $P/iq-inside-link \ "'\"With primes and a link\"'" \ "$(pv iq_inside_link)" check_eq $P/iq-smartypanted \ "'“With smartypanted quotes”'" \ "$(pv iq_smartypanted)" # Only a BLOCK's opening quote is wrapped, not any quote. check_eq $P/iq-midsentence-untouched \ "'He said \"hello\" to me'" "$(pv iq_midsentence)" # ----------------------------------------------------------- smartypants --- check_eq $P/sp-quotes "'The “Green” man'" "$(pv sp_quotes)" check_eq $P/sp-emdash "'Some text — and more'" "$(pv sp_emdash)" check_eq $P/sp-ellipsis "'Wait… what'" "$(pv sp_ellipsis)" # ---------------------------------------------------------------- widont --- check_eq $P/wd-simple "'A very simple test'" "$(pv wd_simple)" check_eq $P/wd-one-word "'Test'" "$(pv wd_one_word)" check_eq $P/wd-leading-space "' Test'" "$(pv wd_leading_space)" # THE BLOCK CASE: each paragraph gets its own nbsp, not the document's last two. check_eq $P/wd-per-block \ "'

In a couple of paragraphs

paragraph two

'" \ "$(pv wd_two_paragraphs)" check_eq $P/wd-link-in-heading \ "'

In a link inside a heading

'" \ "$(pv wd_link_in_heading)" check_eq $P/wd-link-then-text \ "'

In a link followed by other text

'" \ "$(pv wd_link_then_text)" check_eq $P/wd-empty-html "'

'" "$(pv wd_empty_html)" # A bare div is not one of widont's blocks; a p inside one is. check_eq $P/wd-div-untouched "'
Divs get no love!
'" "$(pv wd_div_ignored)" check_eq $P/wd-pre-untouched "'
Neither do PREs
'" "$(pv wd_pre_ignored)" check_eq $P/wd-div-with-p \ "'

But divs with paragraphs do!

'" "$(pv wd_div_with_p)" check_eq $P/wd-li-single-word "'
  • Test

    • '" "$(pv wd_li)" # ------------------------------------------------------------- titlecase --- # The vendored in-tree typogrify.packages.titlecase, not an external dependency. check_eq $P/tc-simple "'This Is a Title'" "$(pv tc_simple)" check_eq $P/tc-small-words "'A Tale of Two Cities'" "$(pv tc_small_words)" check_eq $P/tc-all-caps-kept "'IBM and the FBI'" "$(pv tc_all_caps_kept)" # ------------------------------------------------- typogrify(), composed --- # Everything at once: initial_quotes, smartypants, amp, caps and widont. check_eq $P/tg-document \ "'

      “Jayhawks” & KU fans act extremely obnoxiously

      '" \ "$(pv tg_document)" #
       and  ARE the default ignore set: the region is byte-identical,
      # and the 

      beside it shows the filters did run. check_eq $P/tg-pre-untouched \ "'

      \"KU\" & stuff

      “KU” & stuff

      '" \ "$(pv tg_pre_untouched)" check_eq $P/tg-code-untouched \ "'\"KU\" & stuff

      “KU” & stuff

      '" \ "$(pv tg_code_untouched)" # See the header, point 2. '" \ "$(pv tg_script_default)" check_eq $P/tg-style-default \ "''" \ "$(pv tg_style_default)" # The repair, beside the default: an explicit ignore_tags does reach them. check_eq $P/tg-script-ignored \ "''" "$(pv tg_script_ignored)" check_eq $P/tg-style-ignored \ "''" "$(pv tg_style_ignored)" # -------------------------------------------------------- process_ignores --- check_eq $P/pi-default \ "[('
      processed
      ', False), ('

      processed

      ', True)]" "$(pv pi_default)" check_eq $P/pi-nested \ "[('processed', False), ('

      processed', True), ('

      processed
      ', False), ('

      ', True)]" \ "$(pv pi_nested)" check_eq $P/pi-explicit-tag \ "[('processed', False), ('

      processed

      processed

      ', False)]" \ "$(pv pi_explicit)" check_eq $P/pi-class-selector \ "[('processed', False), ('processed', True), ('
      processed
      ', False), ('
      ', True)]" \ "$(pv pi_class_selector)" # ----------------------------------- python3-smartypants is the supplier --- check_eq $P/smartypants-file "$SITE/smartypants.py" "$(pv smartypants_file)" check_eq $P/smartypants-version "2.0.0" "$(pv smartypants_version)" check_eq $P/smartypants-agrees "yes" "$(pv smartypants_agrees)" # With the module hidden, the filter raises typogrify's OWN error -- which is # what a Django/Jinja template catches -- rather than a bare ImportError. check_eq $P/smartypants-missing-raises "TypogrifyError" "$(pv smartypants_missing_raises)" check_eq $P/caps-missing-raises "TypogrifyError" "$(pv caps_missing_raises)" # ------------------------------------------------------ template bindings --- check_eq $P/jinja-binding-filters \ "amp,caps,initial_quotes,smartypants,titlecase,typogrify,widont" \ "$(pv jinja_binding_filters)" # The jinja binding registers plain filters; it ships no Extension subclass. check_eq $P/jinja-no-extension "no" "$(pv jinja_has_extension)" # Deliberately unimportable -- see the header and the bbappend. check_eq $P/django-binding-absent "ModuleNotFoundError:django" "$(pv django_binding)" check_eq $P/django-file-present "yes" "$(pv django_file_present)" # --------------------------------------------- upstream's own doctest suite --- # filters.py carries its entire specification as doctests; `_test()' is what # runs them upstream. There is no unittest file in this package. check_eq $P/doctest-attempted "40" "$(pv doctest_attempted)" check_eq $P/doctest-failed "0" "$(pv doctest_failed)" check_eq $P/titlecase-tests-import "imported" "$(pv titlecase_tests_import)" rm -rf "$W"