Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ on:
jobs:
build:
runs-on: ubuntu-latest
name: "Python ${{ matrix.python-version }}, Postgres=${{ matrix.with-postgres }}"

strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
with-postgres: [true, false]
fail-fast: false

steps:
Expand All @@ -25,6 +27,11 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Install PostgreSQL
if: ${{ matrix.with-postgres }}
uses: tj-actions/install-postgresql@v3
with:
postgresql-version: 17
- name: Tox flake8
run: tox -e flake8
- name: Tox docs
Expand Down
8 changes: 1 addition & 7 deletions docs/developer_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ Optional Tests
Some tests require additional tools to be installed and are not enabled by
default. You can enable them by passing additional flags to ``lit``:

``-Dpostgres=1``
Enable postgres database support testing. This requires at least
postgres version 9.2 and the ``initdb`` and ``postgres`` binaries in your path.
Note that you do not need to setup an actual server, the tests will create
temporary instances on demand.

``-Dmysql=1``
Enable mysql database support testing. This requires MySQL-python to be
installed and expects the ``mysqld`` and ``mysqladmin`` binaries in your path.
Expand All @@ -74,7 +68,7 @@ default. You can enable them by passing additional flags to ``lit``:

Example::

lit -sv -Dpostgres=1 -Dmysql=1 -Dtidylib=1 ./tests
lit -sv -Dmysql=1 -Dtidylib=1 ./tests

Publishing a new version of LNT
-------------------------------
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ dev = [
"filecheck",
"Flake8-pyproject",
"flake8",
"gunicorn>=19.9.0",
"lit",
"psycopg2>=2.9.0",
"tox",
"twine",
]
Expand Down Expand Up @@ -120,7 +122,7 @@ allowlist_externals = ["rm", "lit"]
deps = [".[dev]"]
commands = [
["rm", "-rf", "test_run_tmp"],
["lit", "-sv", "tests"],
["lit", "-sv", "--show-unsupported", "tests"],
]

[tool.tox.env.flake8]
Expand Down
9 changes: 5 additions & 4 deletions tests/SharedInputs/postgres_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
# Setup minimalistic postgres instance in specified directory, start a server,
# run the given command and shutdown the server. Use
# `postgresql://pgtest@localhost:9100` to connect to the server.
Expand All @@ -10,7 +10,7 @@
set -u
TEST_DIR=$1
shift
DB_DIR="$(mktemp -d -t lnt)"
DB_DIR="$(mktemp -d -t lnt.XXXXX)"
if [ -d "${TEST_DIR}" ]; then
echo 1>&2 "${TEST_DIR} already exists"
exit 1
Expand All @@ -19,15 +19,17 @@ fi
mkdir -p "${TEST_DIR}"
ln -s ${TEST_DIR}/db_root ${DB_DIR}

INITDB_FLAGS=""
INITDB_FLAGS+=" --pgdata=${DB_DIR}/db"
INITDB_FLAGS+=" --xlogdir=${DB_DIR}/db"
INITDB_FLAGS+=" --waldir=${DB_DIR}/db"
INITDB_FLAGS+=" --nosync"
INITDB_FLAGS+=" --no-locale"
INITDB_FLAGS+=" --auth=trust"
INITDB_FLAGS+=" --username=pgtest"
echo "$ initdb $INITDB_FLAGS >& ${DB_DIR}/initdb_log.txt"
initdb ${INITDB_FLAGS} >& ${DB_DIR}/initdb_log.txt

POSTGRES_FLAGS=""
POSTGRES_FLAGS+=" -p 9100"
POSTGRES_FLAGS+=" -D ${DB_DIR}/db"
POSTGRES_FLAGS+=" -k ${DB_DIR}/db"
Expand All @@ -49,4 +51,3 @@ kill -15 ${PG_PID}
wait ${PG_PID}
[ ${RC} -ne 0 ] && (rm -rf ${DB_DIR})
exit ${RC}

10 changes: 6 additions & 4 deletions tests/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os
import platform
import glob
import shutil

import lit.formats
import lit.util
Expand Down Expand Up @@ -46,9 +46,11 @@ config.substitutions.append(('%{test_exec_root}', config.test_exec_root))
if lit_config.params.get('long', None):
config.available_features.add('long')

# Enable postgres testing. This requires postgres binaries in PATH.
# (You do not need to start a server, the tests will create ad-hoc instances).
if lit_config.params.get('postgres', None):
# Enable postgres database support testing if the postgres binary can be found.
# Note that you do not need to setup an actual server, the tests will create
# temporary instances on demand.
postgres = shutil.which('postgres')
if postgres is not None:
config.available_features.add('postgres')

# Enable MySQL testing. This requires mysqld and mysqladmin binaries in PATH.
Expand Down
2 changes: 1 addition & 1 deletion tests/lnttool/PostgresDB.shtest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: postgres
# RUN: rm -rf "%t.install"
# RUN: %{shared_inputs}/postgres_wrapper.sh "%t.install" /bin/sh %s "%t.install" postgresql://pgtest@localhost:9100 "%{shared_inputs}"
# RUN: %{shared_inputs}/postgres_wrapper.sh "%t.install" bash %s "%t.install" postgresql://pgtest@localhost:9100 "%{shared_inputs}"
set -eux

TESTDIR="$1"
Expand Down
Loading