Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Updates for new docrepo #139

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file gives (suggestions for) the links from the landing page in
# the format <anchor text>;<doc type>;<file name>.
# sumission.py will fill in the keys html-doc and pdf-doc, and you
# should have a very good reason to change that. You can add additional
# entries, for instance for schema files and the like.
# <doc type> at this point can be document and schema.
# For now, no values may include semicolons; if you think you have to
# include curly braces, escape them from python str.format.
html;document;{html-doc}
pdf;document;{pdf-doc}
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,22 @@ generate:
bib-suggestions: $(DOCNAME).pdf
$(PYTHON) ivoatex/suggest-bibupgrade.py $(DOCNAME).aux

MANIFEST.in: ivoatex/MANIFEST.in
if [ ! -f MANIFEST.in ]; then cp $^ $@; fi

MANIFEST: MANIFEST.in Makefile
sed -e "s/{html-doc}/$(versionedName).html/;\
s/{pdf-doc}/$(versionedName).pdf/;\
s/^#.*/# Do not edit this file. Edit MANIFEST.in instead./" $< > $@

package: $(DOCNAME).tex $(DOCNAME).html $(DOCNAME).pdf \
$(GENERATED_PNGS) $(FIGURES) $(AUX_FILES)
$(GENERATED_PNGS) $(FIGURES) $(AUX_FILES) MANIFEST
rm -rf -- $(versionedName)
mkdir $(versionedName)
cp $(DOCNAME).tex $(versionedName)/$(versionedName).tex
cp $(DOCNAME).html $(versionedName)/$(versionedName).html
cp $(DOCNAME).pdf $(versionedName)/$(versionedName).pdf
cp MANIFEST $(versionedName)/MANIFEST

ifneq ($(strip $(FIGURES)),)
cp $(FIGURES) $(versionedName)
Expand All @@ -220,6 +229,9 @@ endif
upload: package
$(PYTHON) ivoatex/submission.py $(versionedName).zip

fakeupload: package
$(PYTHON) ivoatex/submission.py --dry-run $(versionedName).zip


# Build TtH from source. See http://hutchinson.belmont.ma.us/tth/.
# TtH source seems to be highly portable, so compilation should be easy
Expand Down
69 changes: 63 additions & 6 deletions regressiontest/run-regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _assert_has(assertion, found_str, where):
assert False, f"Cannot understand assertion: {assertion}"


def execute(cmd, check_output=None, input=None):
def execute(cmd, check_output=None, input=None, expected_status=0):
"""execute a subprocess.Popen-compatible command cmd under supervision.

Specifically, we run with shell=True so the ivoatexDoc recipes work as
Expand All @@ -67,9 +67,10 @@ def execute(cmd, check_output=None, input=None):
check_stdout is not met. For now, that is: neither stdout nor stderr
contains a string.
"""
output = subprocess.check_output(cmd, shell=True, input=input,
stderr=subprocess.STDOUT)
output = output.decode("utf-8")
proc = subprocess.run(cmd, shell=True, input=input,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
assert proc.returncode == expected_status
output = proc.stdout.decode("utf-8")
if check_output is not None:
with open("last-output.txt", "w", encoding="utf-8") as f:
f.write(output)
Expand Down Expand Up @@ -307,7 +308,7 @@ def test_auxiliaryurl_and_test():
(r"\section{Normative Nonsense}", "\\section{Normative Nonsense}\n"
"See (\\auxiliaryurl{our-instance.xml}) for details.")])
edit_file("Makefile", [
('AUX_FILES =', 'AUX_FILES = our-schema.xml')])
('AUX_FILES =', 'AUX_FILES = our-instance.xml')])
with open("our-instance.xml", "w") as f:
f.write(
"""<ri:Resource xmlns:ri="http://www.ivoa.net/xml/RegistryInterface/v1.0" xmlns:vg="http://www.ivoa.net/xml/VORegistry/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" created="2014-09-24T08:36:00Z" status="active" updated="2020-09-17T10:19:29Z" xsi:type="vg:Authority">
Expand Down Expand Up @@ -471,6 +472,58 @@ def test_REC_material():
"has been endorsed by the IVOA Executive Committee")


def test_submission():
execute("make fakeupload")
assert_in_file("submission-payload.txt",
"group_name Standards and Processes\n",
"title Regression test\n")

# submission.py at this point parses its metadata out of the
# built html in the repo, *not* the one in the zip. If this
# changes, we have to change these tests, too
os.unlink("submission-payload.txt")
edit_file("Regress.html", [
('<dd xmlns="" id="ivoagroup" class="WG">Standards and Processes</dd>',
'<dd xmlns="" id="ivoagroup" class="WG">Break and Crash</dd>'),])

execute(
"python ivoatex/submission.py --dry-run NOTE-Regress-1.0-20230201.zip",
expected_status=1,
check_output="Break and Crash is it an IVOA WG/IG name we recognise.")
os.unlink("Regress.html")


def test_manifest():
execute("cp ivoatex/MANIFEST.in MANIFEST.in")
with open("MANIFEST.in", "a+") as f:
f.write("\nsample;document;my_sample.dat\n")
execute("make fakeupload", expected_status=2,
check_output="MANIFEST: Missing file in line 12: my_sample.dat")

with open("my_sample.dat", "w") as f:
f.write("abc")
edit_file("Makefile", [("AUX_FILES =", "AUX_FILES = my_sample.dat ")])
edit_file("MANIFEST.in", [("sample;document;", "sample;dcuoment;")])
execute("make fakeupload", expected_status=2,
check_output="MANIFEST: Bad doctype dcuoment in line:12")

edit_file("MANIFEST.in", [("sample;dcuoment;", "sample;document;")])
execute("make fakeupload")

# the first line of submission-payload is the name of the upload
# file
with open("submission-payload.txt") as f:
zip_name = next(f).strip()
base_name = zip_name[:-4]

assert_in_file("MANIFEST",
f"html;document;{base_name}.html",
f"pdf;document;{base_name}.pdf",
"sample;document;my_sample.dat")

execute(f"unzip -l {zip_name}", check_output="/MANIFEST")


def run_tests(repo_url, branch_name):
os.environ["DOCNAME"] = "Regress"
execute("mkdir $DOCNAME")
Expand Down Expand Up @@ -518,7 +571,11 @@ def run_tests(repo_url, branch_name):

test_all_bibliography()

test_REC_material()
test_REC_material()

test_submission()

test_manifest()
# run_shell()


Expand Down
Loading