From eb791ea29cb334d547aa2bdf38571dfb71b70452 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Tue, 7 Jan 2025 16:22:33 -0600 Subject: [PATCH] Add some basic smoke tests --- .github/workflows/ci.yaml | 18 ++++++++++++++++++ .gitignore | 1 + setup.cfg | 7 +++++++ setup.py | 8 +++++++- test/__init__.py | 6 ++++++ test/conftest.py | 11 +++++++++++ test/roots/test-cmake-extension/conf.py | 11 +++++++++++ test/roots/test-sh-lexer-extension/conf.py | 11 +++++++++++ test/test_cmake_extension.py | 6 ++++++ test/test_sh_lexer_extension.py | 6 ++++++ test/test_theme_path.py | 6 ++++++ 11 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 setup.cfg create mode 100644 test/__init__.py create mode 100644 test/conftest.py create mode 100644 test/roots/test-cmake-extension/conf.py create mode 100644 test/roots/test-sh-lexer-extension/conf.py create mode 100644 test/test_cmake_extension.py create mode 100644 test/test_sh_lexer_extension.py create mode 100644 test/test_theme_path.py diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..78a17bd --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,18 @@ +--- +name: Run tests + +on: # yamllint disable-line rule:truthy + push: + branches: ['master'] + pull_request: + +jobs: + pytest: + uses: ros-infrastructure/ci/.github/workflows/pytest.yaml@main + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + yamllint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: yamllint -f github . diff --git a/.gitignore b/.gitignore index eaea68a..d290c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +/.coverage MANIFEST dist diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..4d61cf3 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,7 @@ +[tool:pytest] +junit_suite_name = catkin-sphinx +markers = + sphinx + +[coverage:run] +source = catkin_sphinx diff --git a/setup.py b/setup.py index 3d66990..be80cd5 100755 --- a/setup.py +++ b/setup.py @@ -33,5 +33,11 @@ description="Sphinx extension for Catkin projects", long_description="Sphinx extension for Catkin projects that provides a " "custom ROS theme and a Sphinx domain for cmake.", - license="BSD" + license="BSD", + extras_require={ + 'test': [ + 'pytest', + 'sphinx', + ], + }, ) diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..3cc1493 --- /dev/null +++ b/test/__init__.py @@ -0,0 +1,6 @@ +import os +import sys + +sys.path.insert(0, os.path.join( + os.path.dirname(os.path.dirname(os.path.realpath(__file__))), + 'src')) diff --git a/test/conftest.py b/test/conftest.py new file mode 100644 index 0000000..6529dee --- /dev/null +++ b/test/conftest.py @@ -0,0 +1,11 @@ +import pytest +from sphinx.testing.path import path + +pytest_plugins = ( + 'sphinx.testing.fixtures', +) + + +@pytest.fixture(scope='session') +def rootdir(): + return path(__file__).parent.abspath() / 'roots' diff --git a/test/roots/test-cmake-extension/conf.py b/test/roots/test-cmake-extension/conf.py new file mode 100644 index 0000000..2b1d929 --- /dev/null +++ b/test/roots/test-cmake-extension/conf.py @@ -0,0 +1,11 @@ +from pathlib import Path +import sys + +import catkin_sphinx + + +project = 'test_cmake_extension' + +sys.path.append(str(Path(catkin_sphinx.__file__).parent.resolve())) + +extensions = ['cmake'] diff --git a/test/roots/test-sh-lexer-extension/conf.py b/test/roots/test-sh-lexer-extension/conf.py new file mode 100644 index 0000000..0257a76 --- /dev/null +++ b/test/roots/test-sh-lexer-extension/conf.py @@ -0,0 +1,11 @@ +from pathlib import Path +import sys + +import catkin_sphinx + + +project = 'test_sh_lexer' + +sys.path.append(str(Path(catkin_sphinx.__file__).parent.resolve())) + +extensions = ['ShLexer'] diff --git a/test/test_cmake_extension.py b/test/test_cmake_extension.py new file mode 100644 index 0000000..8b8a526 --- /dev/null +++ b/test/test_cmake_extension.py @@ -0,0 +1,6 @@ +import pytest + + +@pytest.mark.sphinx(testroot='cmake-extension') +def test_cmake_extension_setup(app): + pass diff --git a/test/test_sh_lexer_extension.py b/test/test_sh_lexer_extension.py new file mode 100644 index 0000000..8ef5d51 --- /dev/null +++ b/test/test_sh_lexer_extension.py @@ -0,0 +1,6 @@ +import pytest + + +@pytest.mark.sphinx(testroot='sh-lexer-extension') +def test_sh_lexer_setup(app): + pass diff --git a/test/test_theme_path.py b/test/test_theme_path.py new file mode 100644 index 0000000..f61487f --- /dev/null +++ b/test/test_theme_path.py @@ -0,0 +1,6 @@ +import catkin_sphinx + + +def test_theme_path(): + res = catkin_sphinx.get_theme_path() + assert res