Skip to content

Commit

Permalink
test: Fix tests to adapt bib.ietf.org (#852)
Browse files Browse the repository at this point in the history
* Update draft-template.xml to v3.
* Add new v2 draft-template-old.xml to old-drafttest.
* Add old-drafttest to default tests.
* Use draft-template for cachetest
* Disable rfc6787.xml test
* Update reference URLs
* Update Makefile to use datatracker
* Update xml2rfc-doc location
  • Loading branch information
kesara authored Aug 9, 2022
1 parent 20b54d1 commit 41b177a
Show file tree
Hide file tree
Showing 66 changed files with 28,233 additions and 17,054 deletions.
27 changes: 13 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ generator_regex = name="generator"
libversion_regex = \(pyflakes\|PyYAML\|requests\|setuptools\|six\|Weasyprint\) [0-9]\+\(\.[0-9]\+\)*

rfcxml= \
rfc6787.xml \
rfc7911.xml \
# rfc6787.xml \
# rfc7754.edited.xml \
rfcxmlfiles = $(addprefix tests/input/, $(rfcxml))
Expand Down Expand Up @@ -59,7 +59,7 @@ pyfiles = $(wildcard xml2rfc/*.py) $(wildcard xml2rfc/writers/*.py)
tests: minify tests-no-network cachetest

# Tests that can run without network access
tests-no-network: test flaketest drafttest rfctest utf8test v3featuretest elementstest indextest sourcecodetest notoctest bomtest wiptest mantest
tests-no-network: test flaketest drafttest old-drafttest rfctest utf8test v3featuretest elementstest indextest sourcecodetest notoctest bomtest wiptest mantest

# Clear the cache
.PHONY: clear-cache
Expand Down Expand Up @@ -100,9 +100,7 @@ CHECKOUTPUT= \
%.rng: %.rnc
trang $< $@

%.tests: %.txt.test %.raw.txt.test %.nroff.test %.html.test %.exp.xml.test %.nroff.txt %.v2v3.xml.test %.v3add-xinclude.xml.test %.text.test %.pages.text.test %.v3.html.test %.prepped.xml.test %.plain.text
@echo " Diffing .nroff.txt against regular .txt"
@doc=$(basename $@); diff -u -I '$(datetime_regex)' -I '$(version_regex)' -I '$(libversion_regex)' -I '$(date_regex)' $$doc.nroff.txt $$doc.txt || { echo 'Diff failed for $$doc.nroff.txt output'; exit 1; }
%.tests: %.txt.test %.html.test %.exp.xml.test %.v2v3.xml.test %.v3add-xinclude.xml.test %.text.test %.pages.text.test %.v3.html.test %.prepped.xml.test %.plain.text
@echo " Checking v3 validity"
@doc=$(basename $@); printf ' '; xmllint --noout --relaxng xml2rfc/data/v3.rng $$doc.prepped.xml
@echo " Diffing .plain.text against regular .text"
Expand All @@ -116,7 +114,7 @@ tests/out/%.canonical.html: tests/input/%.canonical.xml install

tests/out/%.txt tests/out/%.raw.txt tests/out/%.nroff tests/out/%.html tests/out/%.txt : tests/input/%.xml install
@echo -e "\n Processing $<"
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --base tests/out/ --raw --legacy --text --nroff --html --strict $<"
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --base tests/out/ --text --html --strict $<"

tests/out/%.v2v3.xml: tests/input/%.xml install
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --v2v3 --strict --legacy-date-format $< --out $@"
Expand Down Expand Up @@ -160,16 +158,16 @@ tests/out/%.v3.html: tests/input/%.xml install
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --html --v3 --external-css --external-js --strict --legacy-date-format --rfc-reference-base-url https://rfc-editor.org/rfc --id-reference-base-url https://datatracker.ietf.org/doc/html/ --no-inline-version $< --out $@"

tests/out/%.pdf: tests/input/%.xml install
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --pdf --v3 --legacy-date-format --rfc-reference-base-url https://rfc-editor.org/rfc --id-reference-base-url https://tools.ietf.org/html/ $< --out $@"
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --pdf --v3 --legacy-date-format --rfc-reference-base-url https://rfc-editor.org/rfc --id-reference-base-url https://datatracker.ietf.org/doc/html/ $< --out $@"

tests/out/%.plain.xml: tests/out/%.prepped.xml install
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --unprep --v3 --legacy-date-format --rfc-reference-base-url https://rfc-editor.org/rfc --id-reference-base-url https://tools.ietf.org/html/ $< --out $@"
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --unprep --v3 --legacy-date-format --rfc-reference-base-url https://rfc-editor.org/rfc --id-reference-base-url https://datatracker.ietf.org/doc/html/ $< --out $@"

tests/out/%.plain.text: tests/out/%.plain.xml install
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --text --v3 --strict --no-pagination --legacy-date-format $< --out $@ --silence='The document date'"

tests/out/%.exp.xml: tests/input/%.xml install
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --out $@ --exp --legacy $<"
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --out $@ --exp $<"

%.prepped.xml: %.v2v3.xml
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --out $@ --prep $<"
Expand All @@ -193,9 +191,10 @@ tests/out/%.exp.xml: tests/input/%.xml install
# ----------------------------------------------------------------------

old-drafttest: cleantmp install
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --base tmp/ --raw --legacy --text --nroff --html --exp --v2v3 tests/input/draft-template.xml"
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --out tmp/draft-template.prepped.xml --prep tmp/draft-template.v2v3.xml "
doc=draft-template ; postnrofffix="sed 1,2d" ; type=ascii; $(CHECKOUTPUT)
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --base tmp/ --raw --legacy --text --nroff --html --exp --v2v3 tests/input/draft-template-old.xml"
@PS4=" " /bin/bash -cx "cp tests/input/ietf.svg tmp/"
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --out tmp/draft-template-old.prepped.xml --prep tmp/draft-template-old.v2v3.xml "
doc=draft-template-old ; postnrofffix="sed 1,2d" ; type=ascii; $(CHECKOUTPUT)

miektest: cleantmp install
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache \"$${IETF_TEST_CACHE_PATH}\" --no-network --base tmp/ --raw --legacy --text --nroff --html --exp --v2v3 tests/input/draft-miek-test.xml"
Expand All @@ -206,9 +205,9 @@ cachetest: cleantmp install
@echo -e "\n Clearing cache ..."
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache .cache --clear-cache"
@echo " Filling cache ..."
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache .cache tests/input/rfc6787.xml --base tmp/ --raw --legacy"
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache .cache tests/input/draft-template.xml --base tmp/"
@echo " Running without accessing network ..."
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache .cache tests/input/rfc6787.xml --no-network --base tmp/ --raw --legacy"
@PS4=" " /bin/bash -cx "xml2rfc --skip-config --allow-local-file-access --cache .cache tests/input/draft-template.xml --no-network --base tmp/"


rfctest: cleantmp env/bin/python install $(rfctests) tests/out/rfc9001.canonical.html.test
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ The initial build may take time because it downloads all required fonts as well.
[RFC7991]: https://www.rfc-editor.org/info/rfc7991
[bis draft for 7991]: https://datatracker.ietf.org/doc/draft-iab-rfc7991bis/
[v3.rng]: xml2rfc/data/v3.rng
[documentation xml2rfc produces]: https://xml2rfc.tools.ietf.org/xml2rfc-doc.html
[documentation xml2rfc produces]: https://ietf-tools.github.io/xml2rfc/
[preptool]: https://www.rfc-editor.org/info/rfc7998
[WeasyPrint]: https://weasyprint.org/
[WeasyPrint Docs]: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html
18 changes: 9 additions & 9 deletions tests/input/draft-flanagan-nonascii-05.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY ANSI.X3-4.1986 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml2/reference.ANSI.X3-4.1986.xml">
<!ENTITY RFC5137 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5137.xml">
<!ENTITY STD64 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3550.xml">
<!ENTITY RFC4475 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4475.xml">
<!ENTITY RFC6949 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6949.xml">
<!ENTITY RFC7322 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7322.xml">
<!ENTITY RFC7564 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7564.xml">
<!ENTITY RFC7613 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7613.xml">
<!ENTITY I-D.hoffman-xml2rfc SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.hoffman-xml2rfc.xml">
<!ENTITY ANSI.X3-4.1986 SYSTEM "http://bib.ietf.org/public/rfc/bibxml2/reference.ANSI.X3-4.1986.xml">
<!ENTITY RFC5137 SYSTEM "http://bib.ietf.org/public/rfc/bibxml/reference.RFC.5137.xml">
<!ENTITY STD64 SYSTEM "http://bib.ietf.org/public/rfc/bibxml/reference.RFC.3550.xml">
<!ENTITY RFC4475 SYSTEM "http://bib.ietf.org/public/rfc/bibxml/reference.RFC.4475.xml">
<!ENTITY RFC6949 SYSTEM "http://bib.ietf.org/public/rfc/bibxml/reference.RFC.6949.xml">
<!ENTITY RFC7322 SYSTEM "http://bib.ietf.org/public/rfc/bibxml/reference.RFC.7322.xml">
<!ENTITY RFC7564 SYSTEM "http://bib.ietf.org/public/rfc/bibxml/reference.RFC.7564.xml">
<!ENTITY RFC7613 SYSTEM "http://bib.ietf.org/public/rfc/bibxml/reference.RFC.7613.xml">
<!ENTITY I-D.hoffman-xml2rfc SYSTEM "http://bib.ietf.org/public/rfc/bibxml3/reference.I-D.hoffman-xml2rfc.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes"?>
Expand Down
Loading

0 comments on commit 41b177a

Please sign in to comment.