Skip to content

Commit

Permalink
assert log using CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Aug 1, 2023
1 parent 1775801 commit 4225cd4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
python: ['3.8', '3.9', '3.10', '3.11']
fail-fast: false

permissions:
Expand Down Expand Up @@ -40,9 +40,10 @@ jobs:
run: |
cd test
find . -name '*.html' -exec rm {} \;
make html SPHINXOPTS='-W'
make html SPHINXOPTS='-W' | tee log.txt
(cd _build/html && rm genindex.html index.html search.html php-modindex.html)
(cd _build/html && find . -name '*.html' -exec sh -c 'xmllint {} --xpath '"'"'//div[@role="main"]'"'"' | xmllint --format - > ../../{}' \;)
sed -i -r 's~.*/(test/.* \[phpdomain)~\1~;t;d' log.txt
- name: Diff Unit Tests Output
run: |
Expand Down
6 changes: 3 additions & 3 deletions sphinxcontrib/phpdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def log_info(
message: str
):
logger = logging.getLogger(__name__)
logger.info(f"[phpdomain] {message}", location=fromdocnode)
logger.info(f"[phpdomain.info] {message}", location=fromdocnode)

# log messages that should fail CI
def log_warning(
fromdocnode,
message: str
):
logger = logging.getLogger(__name__)
logger.warning(f"[phpdomain] {message}", location=fromdocnode)
logger.warning(f"[phpdomain.warning] {message}", location=fromdocnode)

# log assertions that should fail CI
def log_assert(
Expand All @@ -48,7 +48,7 @@ def log_assert(
if not value:
caller = inspect.getframeinfo(inspect.stack()[1][0])
logger = logging.getLogger(__name__)
logger.warning(f"[phpdomain-assert] line {caller.lineno}", location=fromdocnode)
logger.warning(f"[phpdomain.assert] line {caller.lineno}", location=fromdocnode)

php_sig_re = re.compile(
r'''^ (public\ |protected\ |private\ )? # visibility
Expand Down
27 changes: 27 additions & 0 deletions test/log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
test/method.md:11: [phpdomain.info] Target not found 'Foo\array'
test/ns.md:48: [phpdomain.info] Target not found 'A2::simplify'
test/ns.md:53: [phpdomain.info] Target not found 'Bar2\A::simplify'
test/rst_doc.md:24: [phpdomain.info] Target not found 'array'
test/rst_doc.md:27: [phpdomain.info] Target not found 'boolean'
test/rst_doc.md:40: [phpdomain.info] Target not found 'DateTime\int'
test/rst_doc.md:40: [phpdomain.info] Target not found 'DateTime\int'
test/rst_doc.md:40: [phpdomain.info] Target not found 'DateTime\int'
test/rst_doc.md:48: [phpdomain.info] Target not found 'DateTime\int'
test/rst_doc.md:48: [phpdomain.info] Target not found 'DateTime\int'
test/rst_doc.md:48: [phpdomain.info] Target not found 'DateTime\int'
test/rst_doc.md:104: [phpdomain.info] Target not found 'DateTimeInterface\int'
test/rst_doc.md:104: [phpdomain.info] Target not found 'DateTimeInterface\int'
test/rst_doc.md:104: [phpdomain.info] Target not found 'DateTimeInterface\int'
test/rst_doc.md:112: [phpdomain.info] Target not found 'DateTimeInterface\int'
test/rst_doc.md:112: [phpdomain.info] Target not found 'DateTimeInterface\int'
test/rst_doc.md:112: [phpdomain.info] Target not found 'DateTimeInterface\int'
test/rst_doc.md:221: [phpdomain.info] Target not found 'LibraryName\string'
test/rst_doc.md:221: [phpdomain.info] Target not found 'LibraryName\string'
test/rst_doc.md:497: [phpdomain.info] Target not found 'OtherLibrary\ReturningClass\string'
test/rst_doc.md:502: [phpdomain.info] Target not found 'OtherLibrary\ReturningClass\int|string|OtherLibrary\ReturnedClass|LibraryName\SubPackage\SubpackageInterface|null'
test/rst_doc2.md:11: [phpdomain.info] Target not found 'Imagine\Draw\ImagineImageImageInterface::draw'
test/rst_doc2.md:17: [phpdomain.info] Target not found 'Imagine\Draw\DrawerInterface\ImagineImagePointInterface'
test/rst_doc2.md:17: [phpdomain.info] Target not found 'Imagine\Draw\DrawerInterface\ImagineImageBoxInterface'
test/rst_doc2.md:17: [phpdomain.info] Target not found 'Imagine\Draw\DrawerInterface\integer'
test/rst_doc2.md:17: [phpdomain.info] Target not found 'Imagine\Draw\DrawerInterface\integer'
test/rst_doc2.md:17: [phpdomain.info] Target not found 'Imagine\Draw\DrawerInterface\ImagineImageColor'

0 comments on commit 4225cd4

Please sign in to comment.