Skip to content

Commit

Permalink
testing: minimal Bats cli testing setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarnett committed Aug 27, 2024
1 parent 533eb49 commit 2bd8b5b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ universal = true

[tool.ruff]
line-length = 80
extend-exclude = ["tests/cli/"]

[tool.ruff.lint]
# Enable Errors, Warnings, Flakes
Expand Down
14 changes: 14 additions & 0 deletions tests/cli/test.bats
Original file line number Diff line number Diff line change
@@ -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 'usage.*required'
}

@test "prints correct help" {
run gcalcli -h
assert_output --regexp 'positional arguments:.*list.*search.*edit.*options:'
}
11 changes: 9 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2bd8b5b

Please sign in to comment.