test/integration/jw-pkg -> test/integration/jw_pkg

The mypy module names of the test tree derive from the full path, anchored
by the top-level test/__init__.py, but a file below a path component that
is not a valid identifier - the dashes in jw-pkg - falls back to the bare
file name, so two same-named test.py drivers collide (the duplicate module
error that drove the runme.py and main.py renames).

Rename the directory a sane Python name - jw_pkg, that's the better fix.
Then name the driver test.py like all the others for consistency.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-10-15 11:08:09 +02:00
commit 61c9479e79
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
19 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,4 @@
TOPDIR = ../../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/dirs.mk

View file

@ -0,0 +1,29 @@
# This file runs commands typically used during initial Makefile caching.
#
# It's especially useful to run them in an explicit test, because they are used
# to fill Makefile variables, and if they fail, they leave an empty variable
# behind instead of failing the build entirely.
export JW_DEFAULT_SHOW_BACKTRACE = true
TOPDIR = ../../../../..
include $(TOPDIR)/make/proj.mk
include $(TOPDIR)/make/test-jw-pkg.mk
all:
test: test.integration.in-tree
test.integration.in-tree:
$(TEST_CMD_LINE) --topdir-format absolute platform info --format "%{gnu-triplet} %{cascade}"
$(TEST_CMD_LINE) --topdir-format absolute platform info --format %{id}-%{codename}
$(TEST_CMD_LINE) --topdir-format absolute projects pkg-requires --no-subpackages --subsections=jw --syntax names-only --delimiter " " "build devel" jw-pkg
$(TEST_CMD_LINE) --topdir-format absolute projects pkg-requires --no-subpackages --subsections=jw --syntax names-only --delimiter " " run jw-pkg
$(TEST_CMD_LINE) --topdir-format absolute projects proj-dir jw-pkg
$(TEST_CMD_LINE) --topdir-format absolute projects pythonpath --delimiter " " jw-pkg
$(TEST_CMD_LINE) --topdir-format relative projects pythonpath --prefix '$$MYPY_CONFIG_FILE_DIR/' jw-pkg
$(TEST_CMD_LINE) --topdir-format unaltered projects create-file --format tmpl --template-name pyproject.toml --search-path $(TOPDIR)/conf/templates --field "mypypath=mypy_path = "$MYPY_CONFIG_FILE_DIR/src/python"" jw-pkg > test-pyproject.toml
$(TEST_CMD_LINE) --topdir-format unaltered projects create-file --format pyright --field base=./conf/project/pyrightconfig-base.json --field include=src/python jw-pkg > test-pyrightconfig.json
clean: test.integration.in-tree.clean
test.integration.in-tree.clean:
rm -f test-*.*

View file

@ -0,0 +1,23 @@
TOPDIR = ../../../../..
OUTPUT = test-out.txt
REFERENCE = test-expected.txt
# Relative topdir keeps the rendered project paths relocatable; dropping the
# log position keeps the error output free of volatile line numbers.
TEST_CMD_ARGS = --topdir-format relative --log-flags prio,stderr
include $(TOPDIR)/make/proj.mk
include $(TOPDIR)/make/test-jw-pkg.mk
all:
$(OUTPUT): Makefile test.sh templates/basic.tmpl templates/list.tmpl
bash ./test.sh $(TEST_CMD_LINE) > $(OUTPUT).tmp 2>&1
diff $(REFERENCE) $(OUTPUT).tmp
mv $(OUTPUT).tmp $(OUTPUT)
test: $(OUTPUT)
clean: test.integration.in-tree.clean
test.integration.in-tree.clean:
rm -f $(OUTPUT) $(OUTPUT).tmp

View file

@ -0,0 +1,2 @@
name={name}
path={path}

View file

@ -0,0 +1 @@
start={items}end

View file

@ -0,0 +1,55 @@
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl --template-name basic.tmpl --search-path templates --field name=foo jw-pkg
name=foo
path={path}
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl --template-name list.tmpl --search-path templates --field items=a --field items=b jw-pkg
start=a,
start=bend
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl --template-name list.tmpl --search-path templates --field items=a --field items=b --field-separator | jw-pkg
start=a|bend
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl --template-name list.tmpl --search-path templates --field items=a --field items=b --field-separator %n jw-pkg
start=a
start=bend
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl --template-name list.tmpl --search-path templates --field items=a --field items=b --quote --field-separator | jw-pkg
start="a"|"b"end
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl --template-name basic.tmpl --search-path templates --field-keys name,path --field name=foo jw-pkg
name=foo
path=
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format pyright --field base=./conf/project/pyrightconfig-base.json --field include=src/python jw-pkg
{
"extends": "./conf/project/pyrightconfig-base.json",
"include": [
"src/python"
],
"exclude": [
"**/__pycache__",
"**/.pytest_cache",
"**/.mypy_cache",
"**/.ruff_cache",
"**/.venv",
"**/build",
"**/dist"
],
"extraPaths": [
"src/python"
],
"typeCheckingMode": "basic",
"pythonPlatform": "Linux"
}
============= Running (expect failure): jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl jw-pkg
<E> Failed: Can't render template without name
============= Exit status: 1
============= Running (expect failure): jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl --template-name nosuch.tmpl --search-path templates jw-pkg
<E> Failed: Failed to find template "nosuch.tmpl"
============= Exit status: 1
============= Running (expect failure): jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl --template-name basic.tmpl --search-path templates --field-keys name --field path=x jw-pkg
<E> Failed: The following keys in --field are not in --field-keys: path
============= Exit status: 1
============= Running (expect failure): jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format pyright --field base=x --field include=y --field-separator | jw-pkg
<E> Failed: Unsupported separator for pyright config: "|"
============= Exit status: 1
============= Running (expect failure): jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format bogus jw-pkg
jw-pkg.py projects create-file: error: argument --format: invalid choice: 'bogus' (choose from 'pyright', 'tmpl')
============= Exit status: 2
============= Running (expect failure): jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr projects create-file --format tmpl --template-name basic.tmpl --search-path templates --field noval jw-pkg
jw-pkg.py projects create-file: error: argument -f/--field: Expected KEY=VALUE
============= Exit status: 2

View file

@ -0,0 +1,108 @@
#!/bin/bash
# shellcheck disable=SC2048,SC2086
# Unquoted $* is intentional — the jw-pkg command line
export LC_ALL="C"
set -euo pipefail
jw_pkg_py="$*"
# Print a header and run a command whose output is part of the expected
# result. Under `set -e` a non-zero exit aborts the test.
run()
{
local log_cmd
# shellcheck disable=SC2001
log_cmd=$(echo "$*" | sed 's|.*python3[0-9.]*\s\+\(\.\.\/\)*scripts/||')
printf '============= Running: %s\n' "$log_cmd"
"$@"
}
# Run a command that must exit non-zero and report the given message. Prints
# the command, the resulting error message, and the observed exit status.
# Fails the test if the command unexpectedly succeeds or the message is
# missing. Only the last output line is shown: for the app-level errors it is
# the error itself, and for argparse rejections it is the error line, which
# keeps the expected file free of the volatile usage text.
expect_fail()
{
local expected out rc log_cmd
expected=$1
shift
# shellcheck disable=SC2001
log_cmd=$(echo "$*" | sed 's|.*python3[0-9.]*\s\+\(\.\.\/\)*scripts/||')
printf '============= Running (expect failure): %s\n' "$log_cmd"
set +e
out=$("$@" 2>&1)
rc=$?
set -e
printf '%s\n' "$(tail -n 1 <<<"$out")"
printf '============= Exit status: %s\n' "$rc"
if [ "$rc" -eq 0 ]; then
echo "ERROR: expected failure, but the command succeeded" >&2
return 1
fi
if ! grep -qF -- "$expected" <<<"$out"; then
echo "ERROR: expected message not found: $expected" >&2
return 1
fi
}
cmd_test()
{
# -- tmpl: substitute a field; a marker without a value stays literal
run $jw_pkg_py projects create-file --format tmpl \
--template-name basic.tmpl --search-path templates \
--field name=foo jw-pkg
# -- tmpl: multi-value field, default separator (comma, newline)
run $jw_pkg_py projects create-file --format tmpl \
--template-name list.tmpl --search-path templates \
--field items=a --field items=b jw-pkg
# -- tmpl: multi-value field, custom separator
run $jw_pkg_py projects create-file --format tmpl \
--template-name list.tmpl --search-path templates \
--field items=a --field items=b --field-separator '|' jw-pkg
# -- tmpl: multi-value field, "%n" separator
run $jw_pkg_py projects create-file --format tmpl \
--template-name list.tmpl --search-path templates \
--field items=a --field items=b --field-separator '%n' jw-pkg
# -- tmpl: multi-value field, quoted values
run $jw_pkg_py projects create-file --format tmpl \
--template-name list.tmpl --search-path templates \
--field items=a --field items=b --quote --field-separator '|' jw-pkg
# -- tmpl: --field-keys adds keys that were not passed as empty fields
run $jw_pkg_py projects create-file --format tmpl \
--template-name basic.tmpl --search-path templates \
--field-keys name,path --field name=foo jw-pkg
# -- pyright: built-in template, extra paths from project metadata
run $jw_pkg_py projects create-file --format pyright \
--field base=./conf/project/pyrightconfig-base.json \
--field include=src/python jw-pkg
# -- errors
expect_fail "Can't render template without name" \
$jw_pkg_py projects create-file --format tmpl jw-pkg
expect_fail 'Failed to find template "nosuch.tmpl"' \
$jw_pkg_py projects create-file --format tmpl \
--template-name nosuch.tmpl --search-path templates jw-pkg
expect_fail "not in --field-keys: path" \
$jw_pkg_py projects create-file --format tmpl \
--template-name basic.tmpl --search-path templates \
--field-keys name --field path=x jw-pkg
expect_fail 'Unsupported separator for pyright config: "|"' \
$jw_pkg_py projects create-file --format pyright \
--field base=x --field include=y --field-separator '|' jw-pkg
expect_fail "invalid choice: 'bogus'" \
$jw_pkg_py projects create-file --format bogus jw-pkg
expect_fail "Expected KEY=VALUE" \
$jw_pkg_py projects create-file --format tmpl \
--template-name basic.tmpl --search-path templates --field noval jw-pkg
}
cmd_test

View file

@ -0,0 +1,19 @@
TOPDIR = ../../../../..
OUTPUT = test-out.txt
REFERENCE = test-expected.txt
include $(TOPDIR)/make/proj.mk
include $(TOPDIR)/make/test-jw-pkg.mk
all:
$(OUTPUT): Makefile test.sh
bash ./test.sh $(TEST_CMD_LINE) > $(OUTPUT).tmp
diff $(REFERENCE) $(OUTPUT).tmp
mv $(OUTPUT).tmp $(OUTPUT)
test: $(OUTPUT)
clean: test.integration.in-tree.clean
test.integration.in-tree.clean:
rm -f $(OUTPUT) $(OUTPUT).tmp

View file

@ -0,0 +1,31 @@
============= Running: jw-pkg.py -t ../../../../.. --log-level info projects create-pkg-config -n jw-pkg -s jw-pkg test -p /usr -v 1.0 --cflags=-I/usr/include --libflags=-L/usr/lib -ljw-pkg -r jw-core >= 1.0, jw-base -R jw-devel
prefix = /usr
exec_prefix = ${prefix}
includedir = ${prefix}/include
libdir = ${exec_prefix}/lib
Name: jw-pkg
Description: jw-pkg test
Version: 1.0
Cflags: -I/usr/include
Libs: -L/usr/lib -ljw-pkg
Requires: jw-core >= 1.0, jw-base
Requires.private: jw-devel============= Running: jw-pkg.py -t ../../../../.. --log-level info projects create-pkg-config -n jw-pkg -p /usr -v 1.0 -r foo bar>=2.0, baz
prefix = /usr
exec_prefix = ${prefix}
includedir = ${prefix}/include
libdir = ${exec_prefix}/lib
Name: jw-pkg
Description:
Version: 1.0
Requires: foo, bar >= 2.0, baz============= Running: jw-pkg.py -t ../../../../.. --log-level info projects create-pkg-config -n jw-pkg -p /usr -v 1.0 -R qux
prefix = /usr
exec_prefix = ${prefix}
includedir = ${prefix}/include
libdir = ${exec_prefix}/lib
Name: jw-pkg
Description:
Version: 1.0
Requires.private: qux

View file

@ -0,0 +1,28 @@
#!/bin/bash
# shellcheck disable=SC2048,SC2086
# Unquoted $* is intentional — the jw-pkg command line
export LC_ALL="C"
set -euo pipefail
jw_pkg_py="$*"
run()
{
local log_cmd
# shellcheck disable=SC2001
log_cmd=$(echo "$*" | sed 's|.*python3[0-9.]*\s\+\(\.\.\/\)*scripts/||')
printf '============= Running: %s\n' "$log_cmd"
"$@"
}
run $jw_pkg_py projects create-pkg-config \
-n jw-pkg -s 'jw-pkg test' -p /usr -v 1.0 \
--cflags=-I/usr/include --libflags=-L/usr/lib\ -ljw-pkg \
-r 'jw-core >= 1.0, jw-base' -R 'jw-devel'
run $jw_pkg_py projects create-pkg-config \
-n jw-pkg -p /usr -v 1.0 -r 'foo bar>=2.0, baz'
run $jw_pkg_py projects create-pkg-config \
-n jw-pkg -p /usr -v 1.0 -R 'qux'

View file

@ -0,0 +1,28 @@
TOPDIR = ../../../../..
OUTPUT = test-out.txt
REFERENCE = test-expected.txt
# Relative topdir keeps the rendered project paths relocatable; dropping the
# log position keeps the error output free of volatile line numbers. The
# fixture tree under ./proj provides the topdir and the projects root; the
# last -t wins over the global one.
TEST_CMD_ARGS = --topdir-format relative --log-flags prio,stderr \
-t ./proj/excl-never -p ./proj
include $(TOPDIR)/make/proj.mk
include $(TOPDIR)/make/test-jw-pkg.mk
all:
$(OUTPUT): Makefile test.sh \
$(wildcard proj/*) $(wildcard proj/*/make/project.conf) \
$(wildcard proj/*/VERSION)
bash ./test.sh $(TEST_CMD_LINE) > $(OUTPUT).tmp 2>&1
diff $(REFERENCE) $(OUTPUT).tmp
mv $(OUTPUT).tmp $(OUTPUT)
test: $(OUTPUT)
clean: test.integration.in-tree.clean
test.integration.in-tree.clean:
rm -f $(OUTPUT) $(OUTPUT).tmp

View file

@ -0,0 +1 @@
1.0.0-1

View file

@ -0,0 +1,10 @@
[summary]
Test fixture: plain dependency target
[description]
Fixture for pkg-requires --skip-excluded: a project without [build]
exclude.
[global]
group = "Testing"
subpackages = run

View file

@ -0,0 +1 @@
1.0.0-1

View file

@ -0,0 +1,18 @@
[summary]
Test fixture: excluded from the build on all platforms
[description]
Fixture for pkg-requires --skip-excluded: [build] exclude = all.
[global]
group = "Testing"
subpackages = run
[build]
exclude = all
[pkg.requires.os]
run = bar-foo-qux
[pkg.requires.jw]
run = dep-target-run

View file

@ -0,0 +1 @@
1.0.0-1

View file

@ -0,0 +1,19 @@
[summary]
Test fixture: [build] exclude lists a platform name
[description]
Fixture for pkg-requires --skip-excluded: [build] exclude contains a
platform name (centos), not a project name.
[global]
group = "Testing"
subpackages = run
[build]
exclude = centos
[pkg.requires.os]
run = foo-bar-baz
[pkg.requires.jw]
run = excl-all-run, dep-target-run

View file

@ -0,0 +1,8 @@
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr -t ./proj/excl-never -p ./proj projects pkg-requires --quote --skip-excluded --hide-self --syntax names-only --delimiter run excl-never
"foo-bar-baz" "dep-target-run"
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr -t ./proj/excl-never -p ./proj projects pkg-requires --quote --hide-self --syntax names-only --delimiter run excl-never
"foo-bar-baz" "excl-all-run" "dep-target-run"
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr -t ./proj/excl-never -p ./proj projects pkg-requires --quote --skip-excluded --hide-self --syntax names-only --delimiter run excl-all
============= Running: jw-pkg.py -t ../../../../.. --log-level info --topdir-format relative --log-flags prio,stderr -t ./proj/excl-never -p ./proj projects pkg-requires --quote --hide-self --syntax names-only --delimiter run excl-all
"bar-foo-qux" "dep-target-run"

View file

@ -0,0 +1,46 @@
#!/bin/bash
# shellcheck disable=SC2048,SC2086
# Unquoted $* is intentional — the jw-pkg command line
export LC_ALL="C"
set -euo pipefail
jw_pkg_py="$*"
# Print a header and run a command whose output is part of the expected
# result. Under `set -e` a non-zero exit aborts the test.
run()
{
local log_cmd
# shellcheck disable=SC2001
log_cmd=$(echo "$*" | sed 's|.*python3[0-9.]*\s\+\(\.\.\/\)*scripts/||')
printf '============= Running: %s\n' "$log_cmd"
"$@"
}
# The topdir (-t ./proj/excl-never) and the projects root (-p ./proj) are
# part of the test command line (see the Makefile); the last -t wins over
# the global one. excl-never lists the platform name "centos" in [build]
# exclude and is therefore not excluded from the build here; excl-all is
# excluded on every platform.
# -- the platform name in [build] exclude must not be treated as a project;
# -- the excluded jw dependency is not reported
run $jw_pkg_py projects pkg-requires \
--quote --skip-excluded --hide-self --syntax names-only --delimiter " " \
run excl-never
# -- without --skip-excluded, the excluded jw dependency is reported
run $jw_pkg_py projects pkg-requires \
--quote --hide-self --syntax names-only --delimiter " " \
run excl-never
# -- an excluded seed is neither considered nor output
run $jw_pkg_py projects pkg-requires \
--quote --skip-excluded --hide-self --syntax names-only --delimiter " " \
run excl-all
# -- without --skip-excluded, the excluded seed's dependencies are reported
run $jw_pkg_py projects pkg-requires \
--quote --hide-self --syntax names-only --delimiter " " \
run excl-all