Skip to content

Fix unit tests failing on macOS - #70601

Open
sudipto674 wants to merge 1 commit into
saltstack:3008.xfrom
sudipto674:fix-macos-unit-tests
Open

sudipto674 wants to merge 1 commit into
saltstack:3008.xfrom
sudipto674:fix-macos-unit-tests

Conversation

@sudipto674

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes unit tests that fail on macOS when run as a non-root user:

  • test_roots.py::test_serve_file_not_in_root checked "win" in sys.platform, which is also true for "darwin". It now uses sys.platform.startswith("win").
  • test_scripts.py fork start method pin tests are skipped on macOS, where salt.scripts deliberately does not pin fork.
  • test_pam.py compares against os.path.realpath() because /var is a symlink to /private/var on macOS.
  • test_salt_call.py::test_passing_cachedir_to_extension_modules now uses a minimal config with a temporary root_dir instead of the default /etc/salt and /var/log/salt paths. It used to fail with SystemExit: 13 and leave global logging options that made later tests (test_master, test_reactor, test_engines) fail with No permissions to access "/var/log/salt/minion".

What issues does this PR fix or reference?

Fixes #70599

Previous Behavior

These tests failed on macOS when run as a non-root user (they pass on Linux CI, where tests run as root).

New Behavior

The affected test files pass on macOS, and the /var/log/salt failures no longer occur when tests/pytests/unit/cli runs before them.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

  • Docs
  • Changelog - changelog/70599.fixed.md
  • Tests written/updated (the change is to the tests themselves)

Commits signed with GPG?

No

@sudipto674
sudipto674 requested a review from a team as a code owner October 29, 2026 03:32
@welcome

welcome Bot commented Oct 29, 2026

Copy link
Copy Markdown

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here's some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at saltproject.pdl@broadcom.com. We're glad you've joined our community and look forward to doing awesome things with you!

@sudipto674 sudipto674 added the test:full Run the full test suite label Oct 29, 2026
twangboy
twangboy previously approved these changes Oct 29, 2026
@twangboy twangboy added this to the Potassium v3009.0 milestone Oct 29, 2026
@dwoz
dwoz changed the base branch from master to 3008.x October 30, 2026 09:44
@dwoz
dwoz dismissed twangboy’s stale review October 30, 2026 09:44

The base branch was changed.

- test_roots: check sys.platform.startswith("win"); "win" in "darwin" is
  true, so macOS expected the Windows path separator.
- test_scripts: skip the fork start method pin tests on macOS, where
  salt.scripts deliberately does not pin it.
- test_pam: compare against os.path.realpath(); /var is a symlink to
  /private/var on macOS.
- test_salt_call: give SaltCall a minimal config with a temporary
  root_dir. It previously used the default /etc/salt and /var/log/salt
  paths, failing as a non-root user and leaving global logging options
  that made later tests fail with "No permissions to access
  /var/log/salt/minion".

Fixes saltstack#70599
@dwoz

dwoz commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

re-targeted this one to 3008.x.

This branch is being deployed

1 queued deployment
ci — f514bc4d Deployed Oct 30, 2026 by dwoz via Build Onedir Packages / macOS (arm64) #28177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Several unit tests fail on macOS when run as a non-root user

3 participants