Skip to content

Commit

Permalink
Add a spec build test (#2248)
Browse files Browse the repository at this point in the history
* Don't use CURDIR to find spec files

... or rather have it default to CURDIR but be overridable.

* Add a spec build test

This change adds a test spec filled mostly with Lorem Ipsum that can be
built in various versions and extensions.  The build results are checked
against expectations to ensure the spec output is as expected.

This is primarily a test of the asciidoc extensions that have been
implemented in this repository whose functionality is not automatically
tested.
  • Loading branch information
ShabbyX authored Oct 13, 2023
1 parent 69ae59d commit a0797ed
Show file tree
Hide file tree
Showing 27 changed files with 15,249 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ xml/.cache

# Node.js dependency packages
node_modules

# Build test temp output
/build_tests/gen*
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Vulkan-Docs
Source: https://github.com/KhronosGroup/Vulkan-Docs

Files: images/*.svg config/chunkindex/custom.patch config/CI/contractions* config/CI/writing config/CI/txt-files-allowed config/*/docinfo-header.html
Files: images/*.svg config/chunkindex/custom.patch config/CI/contractions* config/CI/writing config/CI/txt-files-allowed config/*/docinfo-header.html build_tests/expectations/* build_tests/images/*.svg
Copyright: 2015-2023 The Khronos Group Inc.
License: CC-BY-4.0

Expand Down
77 changes: 42 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ MKDIR = mkdir -p
CP = cp
ECHO = echo

# Where the repo root is
ROOTDIR = $(CURDIR)
# Where the spec files are
SPECDIR = $(CURDIR)

# Path to scripts used in generation
SCRIPTS = $(CURDIR)/scripts
SCRIPTS = $(ROOTDIR)/scripts
# Path to configs and asciidoc extensions used in generation
CONFIGS = $(ROOTDIR)/config

# Target directories for output files
# HTMLDIR - 'html' target
Expand Down Expand Up @@ -184,10 +191,10 @@ ATTRIBOPTS = -a revnumber="$(SPECREVISION)" $(BASEOPTS) \
-a apititle="$(APITITLE)" \
-a stem=latexmath \
-a imageopts="$(IMAGEOPTS)" \
-a config=$(CURDIR)/config \
-a appendices=$(CURDIR)/appendices \
-a proposals=$(CURDIR)/proposals \
-a chapters=$(CURDIR)/chapters \
-a config=$(ROOTDIR)/config \
-a appendices=$(SPECDIR)/appendices \
-a proposals=$(SPECDIR)/proposals \
-a chapters=$(SPECDIR)/chapters \
-a images=$(IMAGEPATH) \
-a generated=$(GENERATED) \
-a refprefix \
Expand All @@ -197,17 +204,17 @@ ADOCMISCOPTS = --failure-level ERROR
# Look in $(GENERATED) for explicitly required non-extension Ruby, such
# as apimap.rb
ADOCEXTS = -I$(GENERATED) \
-r $(CURDIR)/config/spec-macros.rb \
-r $(CURDIR)/config/open_listing_block.rb \
-r $(CURDIR)/config/ifdef-mismatch.rb
-r $(CONFIGS)/spec-macros.rb \
-r $(CONFIGS)/open_listing_block.rb \
-r $(CONFIGS)/ifdef-mismatch.rb
ADOCOPTS = -d book $(ADOCMISCOPTS) $(ATTRIBOPTS) $(NOTEOPTS) $(VERBOSE) $(ADOCEXTS)

# HTML target-specific Asciidoctor extensions and options
ADOCHTMLEXTS = -r $(CURDIR)/config/katex_replace.rb \
-r $(CURDIR)/config/loadable_html.rb \
-r $(CURDIR)/config/vuid-expander.rb \
-r $(CURDIR)/config/rouge-extend-css.rb \
-r $(CURDIR)/config/genanchorlinks.rb
ADOCHTMLEXTS = -r $(CONFIGS)/katex_replace.rb \
-r $(CONFIGS)/loadable_html.rb \
-r $(CONFIGS)/vuid-expander.rb \
-r $(CONFIGS)/rouge-extend-css.rb \
-r $(CONFIGS)/genanchorlinks.rb

# ADOCHTMLOPTS relies on the relative runtime path from the output HTML
# file to the katex scripts being set with KATEXDIR. This is overridden
Expand All @@ -218,25 +225,25 @@ ADOCHTMLEXTS = -r $(CURDIR)/config/katex_replace.rb \
# that is coded into CSS, and set separately for each HTML target.
# ADOCHTMLOPTS also relies on the absolute build-time path to the
# 'stylesdir' containing our custom CSS.
KATEXSRCDIR = $(CURDIR)/katex
KATEXSRCDIR = $(ROOTDIR)/katex
KATEXINSTDIR = $(OUTDIR)/katex
ADOCHTMLOPTS = $(ADOCHTMLEXTS) -a katexpath=$(KATEXDIR) \
-a stylesheet=khronos.css \
-a stylesdir=$(CURDIR)/config \
-a stylesdir=$(ROOTDIR)/config \
-a sectanchors

# PDF target-specific Asciidoctor extensions and options
ADOCPDFEXTS = -r asciidoctor-pdf \
-r asciidoctor-mathematical \
-r $(CURDIR)/config/asciidoctor-mathematical-ext.rb \
-r $(CURDIR)/config/vuid-expander.rb
-r $(CONFIGS)/asciidoctor-mathematical-ext.rb \
-r $(CONFIGS)/vuid-expander.rb
ADOCPDFOPTS = $(ADOCPDFEXTS) -a mathematical-format=svg \
-a imagesoutdir=$(PDFMATHDIR) \
-a pdf-fontsdir=config/fonts,GEM_FONTS_DIR \
-a pdf-stylesdir=config/themes -a pdf-style=pdf
-a pdf-fontsdir=$(CONFIGS)/fonts,GEM_FONTS_DIR \
-a pdf-stylesdir=$(CONFIGS)/themes -a pdf-style=pdf

# Valid usage-specific Asciidoctor extensions and options
ADOCVUEXTS = -r $(CURDIR)/config/vu-to-json.rb -r $(CURDIR)/config/quiet-include-failure.rb
ADOCVUEXTS = -r $(CONFIGS)/vu-to-json.rb -r $(CONFIGS)/quiet-include-failure.rb
# {vuprefix} precedes some anchors which are otherwise encountered twice
# by the validusage extractor.
# {attribute-missing} overrides the global setting, since the extractor
Expand All @@ -246,13 +253,13 @@ ADOCVUOPTS = $(ADOCVUEXTS) -a vuprefix=vu- -a attribute-missing=skip
.PHONY: directories

# Images used by the spec. These are included in generated HTML now.
IMAGEPATH = $(CURDIR)/images
IMAGEPATH = $(SPECDIR)/images
SVGFILES = $(wildcard $(IMAGEPATH)/*.svg)

# Top-level spec source file
SPECSRC = vkspec.adoc
SPECSRC = $(SPECDIR)/vkspec.adoc
# Static files making up sections of the API spec.
SPECFILES = $(wildcard chapters/[A-Za-z]*.adoc chapters/*/[A-Za-z]*.adoc appendices/[A-Za-z]*.adoc)
SPECFILES = $(wildcard $(SPECDIR)/chapters/[A-Za-z]*.adoc $(SPECDIR)/chapters/*/[A-Za-z]*.adoc $(SPECDIR)/appendices/[A-Za-z]*.adoc)
# Shorthand for where different types generated files go.
# All can be relocated by overriding GENERATED in the make invocation.
GENERATED = $(CURDIR)/gen
Expand All @@ -265,7 +272,7 @@ INTERFACEPATH = $(GENERATED)/interfaces
SPIRVCAPPATH = $(GENERATED)/spirvcap
FORMATSPATH = $(GENERATED)/formats
SYNCPATH = $(GENERATED)/sync
PROPOSALPATH = $(CURDIR)/proposals
PROPOSALPATH = $(SPECDIR)/proposals
# timeMarker is a proxy target created when many generated files are
# made at once
APIDEPEND = $(APIPATH)/timeMarker
Expand Down Expand Up @@ -298,8 +305,8 @@ $(KATEXINSTDIR): $(KATEXSRCDIR)
# There is some complexity to try and avoid short virtual targets like 'html'
# causing specs to *always* be regenerated.

CHUNKER = $(CURDIR)/scripts/asciidoctor-chunker/asciidoctor-chunker.js
CHUNKINDEX = $(CURDIR)/config/chunkindex
CHUNKER = $(SCRIPTS)/asciidoctor-chunker/asciidoctor-chunker.js
CHUNKINDEX = $(CONFIGS)/chunkindex
# Only the $(CHUNKER) step is required unless the search index is to be
# generated and incorporated into the chunked spec.
#
Expand Down Expand Up @@ -339,7 +346,7 @@ $(HTMLDIR)/diff.html: KATEXDIR = ../katex
$(HTMLDIR)/diff.html: $(SPECSRC) $(COMMONDOCS) $(KATEXINSTDIR)
$(QUIET)$(ASCIIDOC) -b html5 $(ADOCOPTS) $(ADOCHTMLOPTS) \
-a diff_extensions="$(DIFFEXTENSIONS)" \
-r $(CURDIR)/config/extension-highlighter.rb --trace \
-r $(CONFIGS)/extension-highlighter.rb --trace \
-o $@ $(SPECSRC)
$(QUIET)$(TRANSLATEMATH) $@

Expand All @@ -366,7 +373,7 @@ $(VUDIR)/validusage.json: $(SPECSRC) $(COMMONDOCS)
# Vulkan Documentation and Extensions, a.k.a. "Style Guide" documentation

STYLESRC = styleguide.adoc
STYLEFILES = $(wildcard style/[A-Za-z]*.adoc)
STYLEFILES = $(wildcard $(SPECDIR)/style/[A-Za-z]*.adoc)

styleguide: $(OUTDIR)/styleguide.html

Expand Down Expand Up @@ -414,7 +421,7 @@ reflow:
# 'ci-allchecks' targets or individually.

# Look for disallowed contractions
CHECK_CONTRACTIONS = git grep -i -F -f config/CI/contractions | egrep -v -E -f config/CI/contractions-allowed
CHECK_CONTRACTIONS = git grep -i -F -f $(ROOTDIR)/config/CI/contractions | egrep -v -E -f $(ROOTDIR)/config/CI/contractions-allowed
check-contractions:
if test `$(CHECK_CONTRACTIONS) | wc -l` != 0 ; then \
echo "Contractions found that are not allowed:" ; \
Expand All @@ -423,7 +430,7 @@ check-contractions:
fi

# Look for typos and suggest fixes
CODESPELL = codespell --config config/CI/codespellrc -S '*.js' -S './antora*/*' -S 'ERRS*,*.pdf'
CODESPELL = codespell --config $(ROOTDIR)/config/CI/codespellrc -S '*.js' -S './antora*/*' -S 'ERRS*,*.pdf'
check-spelling:
if ! $(CODESPELL) > /dev/null ; then \
echo "Found probable misspellings. Corrections can be added to config/CI/codespell-allowed:" ; \
Expand All @@ -434,7 +441,7 @@ check-spelling:
# Look for old or unpreferred language in specification language.
# This mostly helps when we make global changes that also need to be
# made in outstanding extension branches for new text.
CHECK_WRITING = git grep -E -f config/CI/writing registry.adoc vkspec.adoc chapters appendices
CHECK_WRITING = git grep -E -f $(ROOTDIR)/config/CI/writing $(SPECDIR)/registry.adoc $(SPECDIR)/vkspec.adoc $(SPECDIR)/chapters $(SPECDIR)/appendices
check-writing:
if test `$(CHECK_WRITING) | wc -l` != 0 ; then \
echo "Found old style writing. Please refer to the style guide or similar language in current main branch for fixes:" ; \
Expand All @@ -443,7 +450,7 @@ check-writing:
fi

# Look for bullet list items not preceded by exactly two spaces, per styleguide
CHECK_BULLETS = git grep -E '^( | +)[-*]+ ' chapters appendices style [a-z]*.adoc
CHECK_BULLETS = git grep -E '^( | +)[-*]+ ' $(SPECDIR)/chapters $(SPECDIR)/appendices $(SPECDIR)/style $(SPECDIR)/[a-z]*.adoc
check-bullets:
if test `$(CHECK_BULLETS) | wc -l` != 0 ; then \
echo "Bullet list item found not preceded by exactly two spaces:" ; \
Expand Down Expand Up @@ -482,7 +489,7 @@ check-undefined:
$(SCRIPTS)/ci/check_undefined

# Look for '.txt' files, which should almost all be .adoc now
CHECK_TXTFILES = find . -name '*.txt' | egrep -v -E -f config/CI/txt-files-allowed
CHECK_TXTFILES = find . -name '*.txt' | egrep -v -E -f $(ROOTDIR)/config/CI/txt-files-allowed
check-txtfiles:
if test `$(CHECK_TXTFILES) | wc -l` != 0 ; then \
echo "*.txt files found that are not allowed (use .adoc):" ; \
Expand Down Expand Up @@ -553,7 +560,7 @@ refpages: $(REFPATH)/apispec.adoc
$(REFPATH)/apispec.adoc: $(SPECFILES) $(GENREF) $(SCRIPTS)/reflib.py $(PYAPIMAP)
$(QUIET)$(MKDIR) $(REFPATH)
$(PYTHON) $(GENREF) -genpath $(GENERATED) -basedir $(REFPATH) \
-log $(LOGFILE) -extpath $(CURDIR)/appendices \
-log $(LOGFILE) -extpath $(SPECDIR)/appendices \
$(EXTOPTIONS) $(SPECFILES)

# These targets are HTML5 refpages
Expand Down Expand Up @@ -655,7 +662,7 @@ manaliases: $(PYAPIMAP)
# $(GENVKEXTRA) are extra options that can be passed to genvk.py, e.g.
# '-diag diag'

REGISTRY = xml
REGISTRY = $(ROOTDIR)/xml
VKXML = $(REGISTRY)/vk.xml
GENVK = $(SCRIPTS)/genvk.py
GENVKOPTS = $(VERSIONOPTIONS) $(EXTOPTIONS) $(GENVKEXTRA) -registry $(VKXML)
Expand Down
49 changes: 49 additions & 0 deletions build_tests/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2023 The Khronos Group Inc.
// SPDX-License-Identifier: CC-BY-4.0

= Spec Build Tests

This directory contains test source and expectation files for the `testBuild`
script. The test specification files are:

* `testspec.adoc`
* `chapters/*.adoc`
* `chapters/commonvalidity/*.adoc`
* `appendices/*.adoc`
* `images/*.svg`

The expectation files are:

* `expectations/*.html`
* `expectations/validusage.json`

The `testBuild` script builds the test specficiation (`testspec.adoc`) in an
array of configurations, such as Core (latest), Core 1.0, with all extensions,
with a specific extension etc. Additionally, it extracts the VUs into
validusage.json.

Each build by `testBuild` is done in a separate directory under `gen-<build>`.
In all cases except `gen-validusage`, the output is
`gen-<build>/out/html/vkspec.html`. In the case of `gen-validusage`, the output
is `gen-validusage/out/validition/validusage.json`.

The primary reason for these tests is ensuring correctness of asciidoc
extensions implemented in this repository. The `testBuild` script first builds
all configurations, then verifies the results against the expectations.

If a build itself regresses (and fails), the script will stop so the issue can
be addressed after looking at the logs of the failing build. If the builds
succeed but the output does not match the expectations, the diff is output for
investigation.

In some cases, the diff is small enough to be verified. Otherwise, each output
in `gen-<build>/` needs to be manually reviewed to ensure the results are still
correct; for example because the html is styled differently and the differences
are as expected.

If the mismatch between the output and expectations is expected, and the output
is verified to be correct, update the expectations with:

----
$ ./update-expectations
----
54 changes: 54 additions & 0 deletions build_tests/appendices/test.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2021-2023 The Khronos Group, Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

include::{generated}/meta/{refprefix}VK_EXT_host_image_copy.adoc[]

=== Other Extension Metadata

*Last Modified Date*::
2186-02-28
*Contributors*::
- Zabhash Ifessouy, Elgoog
- Htiaf Dnartske, Aroballoc
- Sreip Lleinad, AIDIVN

=== Description

Sed risus pretium quam vulputate dignissim suspendisse in est ante. Mauris
commodo quis imperdiet massa tincidunt nunc pulvinar. Odio morbi quis commodo
odio aenean sed. Quam adipiscing vitae proin sagittis nisl rhoncus. Vel
facilisis volutpat est velit egestas dui. Consequat id porta nibh venenatis
cras sed felis. Ac tortor dignissim convallis aenean et tortor. Amet porttitor
eget dolor morbi non arcu. Consequat interdum varius sit amet. Tempus egestas
sed sed risus pretium quam. Gravida in fermentum et sollicitudin ac orci
phasellus egestas. Nulla facilisi etiam dignissim diam quis enim lobortis
scelerisque fermentum. Tempus quam pellentesque nec nam aliquam. A pellentesque
sit amet porttitor eget. Viverra justo nec ultrices dui sapien eget mi. Nullam
vehicula ipsum a arcu. Amet volutpat consequat mauris nunc congue nisi.
Tincidunt arcu non sodales neque.

include::{generated}/interfaces/VK_EXT_host_image_copy.adoc[]

=== Issues

1) Natoque penatibus et magnis dis parturient montes nascetur.

*RESOLVED*: Iaculis eu non diam phasellus vestibulum. Consequat nisl vel
pretium lectus quam. Euismod in pellentesque massa placerat duis ultricies
lacus sed turpis. Ullamcorper eget nulla facilisi etiam dignissim diam quis
enim. Id velit ut tortor pretium viverra suspendisse potenti.

2) Faucibus in ornare quam viverra orci sagittis eu volutpat?

*RESOLVED*: Eu facilisis sed odio morbi quis commodo. Pharetra magna ac
placerat vestibulum lectus mauris. Ac felis donec et odio pellentesque diam
volutpat commodo sed.

=== Version History

* Revision 0, 2173-05-30 (Htiaf Dnartske)
** Malesuada pellentesque elit eget gravida cum sociis natoque

* Revision 1, 2185-12-01 (Zabhash Ifessouy)
** Id leo in vitae turpis massa sed elementum
28 changes: 28 additions & 0 deletions build_tests/chapters/commonvalidity/dolor.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2020-2023 The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

// Common Valid Usage
// Common to VkBufferImageCopy*, VkMemoryToImageCopy* and VkImageToMemoryCopy*
// structs
// This relies on additional attributes {bufferrowlength} and
// {bufferimageheight} set by the command which includes this file, specifying
// the type of the non-image target of the copy (which is either buffer* or
// memory*).

* [[VUID-{refpage}-{bufferrowlength}-99101]]
pname:{bufferrowlength} must: be `0`, or greater than or equal to the
pname:width member of pname:imageExtent
* [[VUID-{refpage}-{bufferimageheight}-99102]]
pname:{bufferimageheight} must: be `0`, or greater than or equal to the
pname:height member of pname:imageExtent
* [[VUID-{refpage}-aspectMask-99103]]
The pname:aspectMask member of pname:imageSubresource must: only have a
single bit set
* [[VUID-{refpage}-imageExtent-96659]]
pname:imageExtent.width must: not be 0
* [[VUID-{refpage}-imageExtent-96660]]
pname:imageExtent.height must: not be 0
* [[VUID-{refpage}-imageExtent-96661]]
pname:imageExtent.depth must: not be 0
// Common Valid Usage
Loading

0 comments on commit a0797ed

Please sign in to comment.