From e413f633f346ba7d4009d82603190f0f3db125a2 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Mon, 26 Aug 2024 16:09:31 -0600 Subject: [PATCH] testing: minimal Bats cli testing setup --- .github/workflows/tests.yml | 10 +++++----- pyproject.toml | 1 + tests/cli/test.bats | 14 ++++++++++++++ tox.ini | 11 +++++++++-- 4 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 tests/cli/test.bats diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3c775ec..2a579b6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,25 +18,25 @@ jobs: matrix: py: - "3.12" - - "3.11" - - "3.10" - - "3.9" - "3.8" os: - ubuntu-latest - macos-latest - windows-latest + env: + SKIP_ENVS: ${{ (matrix.py != '3.12' || matrix.os == 'windows-latest') && '--skip-env=cli' || '' }} steps: - uses: actions/checkout@v3 with: fetch-depth: 0 + submodules: ${{ matrix.py == '3.12' && matrix.os != 'windows-latest' && 'true' || 'false' }} - name: Setup python for test ${{ matrix.py }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.py }} - - name: Install tox + - name: Install tox-gh run: python -m pip install tox-gh>=1.2 - name: Setup test suite run: tox -vv --notest - name: Run test suite - run: tox --skip-pkg-install + run: tox --skip-pkg-install ${{ env.SKIP_ENVS }} diff --git a/pyproject.toml b/pyproject.toml index 019db93..b8d89f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,6 +58,7 @@ universal = true [tool.ruff] line-length = 80 +extend-exclude = ["tests/cli/"] [tool.ruff.lint] # Enable Errors, Warnings, Flakes diff --git a/tests/cli/test.bats b/tests/cli/test.bats new file mode 100644 index 0000000..e3f3b2b --- /dev/null +++ b/tests/cli/test.bats @@ -0,0 +1,14 @@ +setup() { + load 'test_helper/bats-support/load' + load 'test_helper/bats-assert/load' +} + +@test "can run" { + run gcalcli + assert_output --regexp '.*' +} + +@test "prints correct help" { + run gcalcli -h + assert_output --regexp 'positional arguments:.*list.*search.*edit.*options:' +} diff --git a/tox.ini b/tox.ini index 81ec924..77c913c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] requires = tox>=4 -envlist = lint, type, py3{8,9,10,11,12} +envlist = lint, type, py3{8,9,10,11,12}, cli [testenv] usedevelop=true @@ -31,9 +31,16 @@ deps = commands = mypy {posargs:gcalcli} +[testenv:cli] +description = run functional tests using Bats +allowlist_externals = + ./tests/cli/bats/bin/bats +commands = + ./tests/cli/bats/bin/bats tests/cli/test.bats + [gh] python = - 3.12 = py312, lint, type + 3.12 = py312, lint, type, cli 3.11 = py311 3.10 = py310 3.9 = py39