Files
OpenXR-Docs/specification/scripts/test_check_spec_links_api_specific.py
Ryan Pavlik 4405f1dbff Change log for OpenXR 0.90.1 provisional spec update (8-May-2019)
No API changes, and only minimal consistency changes to the spec/registry.
Mostly an update for tooling, layers, loader, and sample code.
Header version has been bumped to 43, but no symbols that should have actually been in use have changed.

The OpenXR-Docs repo now contains the scripts and sources needed to build
the specification output files.

### Internal Issues

- General, Build, Other
  - Unify (for the most part) the OpenXR and Vulkan generator scripts. (internal MR 1166)
  - Avoid dllexport for all apps compiled with `openxr_platform_defines.h` (internal MR 1187)
- API Registry and Headers
  - Remove impossible and undocumented error codes. (internal MR 1185 and 1189)
  - Mark layers in `XrFrameEndInfo` as optional. (internal MR 1151, internal issue 899)
  - Remove unused windows types from `openxr_platform.h` (internal MR 1197)
  - Make `openxr_platform.h` include `openxr.h` on which it depends. (internal MR 1140, internal issue 918)
  - Remove unused, undocumented defines. (internal MR 1238, internal issue 1012)
2019-05-09 10:20:24 -05:00

93 lines
3.2 KiB
Python

#!/usr/bin/python3
#
# Copyright (c) 2018-2019 Collabora, Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author(s): Ryan Pavlik <ryan.pavlik@collabora.com>
#
# Purpose: This file contains tests for check_spec_links.py
# that depend on the API being used.
import pytest
from check_spec_links import MessageId, makeMacroChecker
from test_check_spec_links import CheckerWrapper, allMessages, msgReplacement
@pytest.fixture
def ckr(capsys):
"""Fixture - add an arg named ckr to your test function to automatically get one passed to you."""
return CheckerWrapper(capsys)
def test_openxr_refpage_mismatch(ckr):
"""Test the REFPAGE_MISMATCH message."""
ckr.enabled([MessageId.REFPAGE_MISMATCH])
# Should not error: The include is for FlagBits inside of refpage for Flags
# which is special-cased to not error.
assert(not ckr.check(
"""[open,refpage='MyFlags']
--
include::../../generated/api/enums/MyFlagBits.txt[]""").messages)
assert(not ckr.check(
"""[open,refpage='MyFlags']
--
include::../../generated/validity/enums/MyFlagBits.txt[]""").messages)
def test_openxr_refpage_missing(ckr):
"""OpenXR-specific tests of the REFPAGE_MISSING message."""
ckr.enabled([MessageId.REFPAGE_MISSING])
# Should not error: all flags includes are stuck in the Appendix for now.
assert(not ckr.check(
"include::../../generated/api/flags/XrEndFrameDescriptionFlags.txt[]").messages)
def test_openxr_refpage_block(ckr):
"""OpenXR-specific tests of the REFPAGE_BLOCK message."""
ckr.enabled([MessageId.REFPAGE_BLOCK])
# Should have 1 error: line before '--' isn't tag
assert(ckr.check(
"""--
bla
--""").numDiagnostics() == 1)
# Should have 3 errors:
# - line before '--' isn't tag (refpage gets opened anyway),
# - tag is inside refpage (which auto-closes the previous refpage block, then re-opens a refpage)
# - line after tag isn't '--'
result = ckr.check(
"""--
[open,]
bla
--""")
assert(result.numDiagnostics() == 3)
# Internally, it's as if the following were the spec source, after putting in the "fake" lines
# (each of the added lines comes from one message):
#
# [open,]
# --
# --
# [open,]
# --
# bla
# --
assert(len([x for x in allMessages(result)
if "but did not find, a line containing only -- following a reference page tag" in x]) == 1)
assert(len([x for x in allMessages(result)
if "containing only -- outside of a reference page block" in x]) == 1)
assert(len([x for x in allMessages(result)
if "we are already in a refpage block" in x]) == 1)