Files
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
..