tests: run test suite fully in-tree without depending on prefix#399
Open
herbygillot wants to merge 1 commit intomacports:masterfrom
Open
tests: run test suite fully in-tree without depending on prefix#399herbygillot wants to merge 1 commit intomacports:masterfrom
herbygillot wants to merge 1 commit intomacports:masterfrom
Conversation
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>
neverpanic
reviewed
Apr 2, 2026
Member
neverpanic
left a comment
There was a problem hiding this comment.
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@ |
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a test-specific tclsh wrapper (
tests/test-tclsh) that extends the vendor tclsh wrapper with allsrc/package directories onTCLLIBPATH, 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}/portand${bindir}/portindexwith direct invocations of the in-treesrc/port/port.tclandsrc/port/portindex.tclvia the test tclsh wrapper.Add
init_tmp_prefixto all test files that callmportinit, creating a throwaway prefix withmacports.conf,sources.conf, andshare/macportsdata populated from the source tree rather than the installed prefix. Setextra_env TCLLIBPATHin testmacports.conffiles so thatmportinit's environment scrub does not stripTCLLIBPATH, which threads need to resolve packages.Reorder CI workflows to run
make testbeforemake install, since the test suite no longer requires an installed prefix.See: https://trac.macports.org/ticket/56016