Skip to content

tests: run test suite fully in-tree without depending on prefix#399

Open
herbygillot wants to merge 1 commit intomacports:masterfrom
herbygillot:in-tree-tests
Open

tests: run test suite fully in-tree without depending on prefix#399
herbygillot wants to merge 1 commit intomacports:masterfrom
herbygillot:in-tree-tests

Conversation

@herbygillot
Copy link
Copy Markdown
Member

Add a test-specific tclsh wrapper (tests/test-tclsh) that extends the vendor tclsh wrapper with all src/ package directories on TCLLIBPATH, allowing the test suite to find in-tree packages without anything installed at the configured prefix.

Switch all test Makefiles from $(TCLSH) to $(TEST_TCLSH) so unit and integration tests use the in-tree interpreter. Replace all references to ${bindir}/port and ${bindir}/portindex with direct invocations of the in-tree src/port/port.tcl and src/port/portindex.tcl via the test tclsh wrapper.

Add init_tmp_prefix to all test files that call mportinit, creating a throwaway prefix with macports.conf, sources.conf, and share/macports data populated from the source tree rather than the installed prefix. Set extra_env TCLLIBPATH in test macports.conf files so that mportinit's environment scrub does not strip TCLLIBPATH, which threads need to resolve packages.

Reorder CI workflows to run make test before make install, since the test suite no longer requires an installed prefix.

See: https://trac.macports.org/ticket/56016

Add a test-specific tclsh wrapper (`tests/test-tclsh`) that extends the
vendor tclsh wrapper with all `src/` package directories on `TCLLIBPATH`,
allowing the test suite to find in-tree packages without anything
installed at the configured prefix.

Switch all test Makefiles from `$(TCLSH)` to `$(TEST_TCLSH)` so unit and
integration tests use the in-tree interpreter. Replace all references
to `${bindir}/port` and `${bindir}/portindex` with direct invocations of
the in-tree `src/port/port.tcl` and `src/port/portindex.tcl` via the test
tclsh wrapper.

Add `init_tmp_prefix` to all test files that call `mportinit`, creating a
throwaway prefix with `macports.conf`, `sources.conf`, and `share/macports`
data populated from the source tree rather than the installed prefix.
Set `extra_env TCLLIBPATH` in test `macports.conf` files so that
`mportinit`'s environment scrub does not strip `TCLLIBPATH`, which threads
need to resolve packages.

Reorder CI workflows to run `make test` before `make install`, since the
test suite no longer requires an installed prefix.

See: https://trac.macports.org/ticket/56016

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@herbygillot herbygillot requested a review from jmroot March 21, 2026 17:03
Copy link
Copy Markdown
Member

@neverpanic neverpanic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! One minor comment that should be easy to fix, and one discussion that we could postpone to after merging this PR.


file link -symbolic /tmp/macports-tests/opt/local/share/macports $datadir/macports
# Populate share/macports from the source tree instead of the prefix
set top @abs_top_srcdir@
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set top @abs_top_srcdir@
set top "@abs_top_srcdir@"

Seems dangerous to rely on this not containing any characters Tcl would interpret.

file link -symbolic /tmp/macports-tests/opt/local/share/macports $datadir/macports
# Populate share/macports from the source tree instead of the prefix
set top @abs_top_srcdir@
file mkdir /tmp/macports-tests/opt/local/share/macports/install
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize you didn't start with this, but it feels like using a static path in /tmp is probably not a great solution here, since it can introduce side effects from parallel build trees of MacPorts.

How hard would it be to generate a temporary directory and clean it up after the test run?

Also, would this even work if $prefix isn't set to /opt/local?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants