Commit Graph

213 Commits

Author SHA1 Message Date
Herby Gillot 1084984798 tests: consolidate duplicated test setup code and config files
Extract the shared boilerplate (macports init, tmp prefix setup,
mportinit, macports_worker_init) from 27 test files into a single
test_setup.tcl sourced by all unit test suites.  Merge the three
divergent copies of macports_worker_init into one consolidated
superset.  Fixes #73828.

Eliminate the duplicate sources.conf files in port1.0/tests/ and
package1.0/tests/ by having init_tmp_prefix derive the path from
top_srcdir, leaving a single copy in macports1.0/tests/.  Fixes
#73827.

Expose the test tclsh path as macports::autoconf::test_tclsh so
tests can reference it without recomputing the path from
top_srcdir.

Replace the hardcoded /tmp/macports-tests path in the integration
test infrastructure with a unique temporary directory created via
`file tempfile`, which respects TMPDIR and avoids collisions
between parallel or repeated runs.  Move macports.conf and
sources.conf content into static template files with @TEST_ROOT@
substitution so the config structure is visible on disk rather
than generated inline.

Install a ::tcltest::cleanupTestsHook in the integration test
library so the temporary directory is removed via cleanupTests
even if a test omits its trailing explicit `cleanup` call.

Fix tests/test/arch-test/test.tcl, which invoked ${bindir}/port
via `sh -c` but never had bindir defined anywhere, to run
port.tcl directly through the test interpreter.

Replace hardcoded /tmp paths in portutil.test with $pwd-relative
paths.

Fixes: https://trac.macports.org/ticket/73828
Fixes: https://trac.macports.org/ticket/73827

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-12 14:28:40 -04:00
Clemens Lang 51e37f5506 tests/trace: Print log on error 2026-04-12 14:29:41 +02:00
Clemens Lang 0bbe4ad0ee port1.0: Fix running in installation directory
Attempting to normalize the userhome of the macports user might not work
if the user has not yet been created while running tests from within the
source tree, so don't do that unless running as root (where the test
that triggers this is skipped).

Additionally, the SIP workaround path for darwintrace needs to be
configurable, because the path in the installation directory might not
exist yet (CI may not have yet run make install). This path then also
needs to be added to the various sandboxes we configure.

This also means darwintrace.dylib needs to be picked up from the source
tree, so add another variable to test-tclsh.in (and pass that variable
through by modifying test-macports.conf) and check for its existence in
porttrace.tcl.
2026-04-12 14:29:41 +02:00
Clemens Lang dc9b17c26a tests: Fix trace test to run in source (and skip if root)
This also means we no longer need to reinplace the macports user's
username into the test file, so there's no longer a need to generate it
using configure.
2026-04-12 14:29:41 +02:00
Clemens Lang baa4aaa118 tests: Re-enable trace test on arm64, run in source tree 2026-04-12 14:29:41 +02:00
Herby Gillot 227a37b749 tests: run test suite fully in-tree without depending on prefix
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>
2026-04-11 03:39:35 +02:00
Herby Gillot 963a5c670f tests: attempt to avoid macOS 15 portindex test aborts
Strip inherited darwintrace DYLD and DARWINTRACE environment variables
from the shared non-trace test helpers before invoking portindex and
most port commands, and replace a couple of shell/env helper calls with
Tcl-native setup.

Also clean up the negative darwintrace environment tests so they do not
leave injected DYLD state behind for later tests.

This is an attempted fix for the macOS 15 CI failures where the
site-tags test aborts while portindex is running.
2026-04-11 03:21:12 +02:00
Joshua Root 5e0079a3ab site-tags test: print error 2026-02-17 09:40:17 +11:00
Joshua Root 555c041020 test library: clean up unused globals 2024-04-09 02:16:49 +10:00
Joshua Root 1e5fd69250 Mark trace test as known bug on arm64 2024-02-08 02:54:30 +11:00
Joshua Root 9f93b3ab90 fix statefile tests 2023-09-20 12:43:08 +10:00
Joshua Root ddc26554e6 Add built-in test phase for all ports
For now, there's just one test, which checks that the files in the
destroot have the archs that the port is supposed to be building for.
More can be added in future.

Running 'port test' on a port that doesn't set 'test.run yes' will no
longer error, but will run the built-in tests only. Ports that do set
test.run will run both the built-in tests and the ones defined by the
Portfile.

Closes: https://trac.macports.org/ticket/45010
2023-01-01 23:15:19 +11:00
Dimitris Apostolou 13b4fc4276 Fix typos 2022-01-02 21:36:23 +11:00
Joshua Root c0ae2dba15 fix universal test 2021-01-30 01:28:30 +11:00
Ryan Schmidt 5629dcf668 Use "use_configure no" instead of "configure {}" 2020-06-17 00:00:54 -05:00
Ryan Schmidt e4508a2bc5 Add modeline and adjust whitespace 2020-06-16 23:54:50 -05:00
Ryan Schmidt 0e3de7ca65 Add modeline and fix whitespace in test.tcl 2020-06-16 23:15:29 -05:00
Joshua Root 25922fe7f2 fix more tests on 10.6 2019-08-28 19:29:46 +10:00
Joshua Root 51fb9ee765 fix trace test on systems without /usr/include 2019-01-05 13:42:05 +11:00
Ryan Schmidt 8adbbe0b67 Fix typo: XCode -> Xcode 2018-06-05 05:05:07 -05:00
Rainer Müller 5bdcbb31d5 tests: Generate a valid Portfile in universal test 2018-03-15 17:30:55 +01:00
Rainer Müller e97d916d4c tests: Rewrite case-insensitive-deactivate 2018-03-15 17:03:32 +01:00
Rainer Müller afed61c261 tests: Make port_(un)install take a port name 2018-03-15 17:03:00 +01:00
Rainer Müller 386c4befa5 tests: Add missing return statements 2018-03-15 17:02:53 +01:00
Clemens Lang 0745d2d4ef tests: Remove non-existing constraint from test
The has_svn constraint was removed from library.tcl, but I forgot to
remove it from the test as well.
2018-03-12 17:10:40 +01:00