Skip to content

Fix test isolation#520

Merged
andy5995 merged 7 commits intomasterfrom
fix-test-isolation
Mar 26, 2026
Merged

Fix test isolation#520
andy5995 merged 7 commits intomasterfrom
fix-test-isolation

Conversation

@andy5995
Copy link
Copy Markdown
Member

Fixes #519

andy5995 and others added 2 commits March 25, 2026 20:50
If RMW_FAKE_HOME is ever unset mid-script, rmw falls back to $HOME.
Override HOME in the meson test environment so that fallback still lands
in the sandbox rather than the real home directory.

test_media_root.sh is excluded from the HOME override since it
intentionally unsets RMW_FAKE_HOME to exercise real-home behavior;
it skips automatically on machines without the expected mount point.

Closes #519

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The old test only ran on Andy's workstation (hardcoded /mnt/918375c2
mount point and /home/andy paths). The new approach:

- Compares the device ID of /tmp with $HOME using stat
- Skips if they are on the same device (test condition not met)
- Otherwise uses /tmp as the simulated removable media root
- Creates a temporary rmw config and waste folder under /tmp
- Verifies the trashinfo Path is relative per FreeDesktop Trash spec
- Cleans up after itself

This makes the test portable and runnable on any system where /tmp is
on a separate device (e.g. tmpfs on Linux CI runners).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@andy5995 andy5995 added this to the v0.9.5 milestone Mar 26, 2026
andy5995 and others added 5 commits March 25, 2026 23:12
stat flag syntax differs between GNU (-c) and BSD/macOS (-f), making
the previous approach unreliable. Hard links only succeed within the
same filesystem, so attempting ln across /tmp and $HOME gives a
portable, unambiguous cross-device check on Linux, macOS, and FreeBSD.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Containers and macOS often have /tmp on the root filesystem, in which
case rmw correctly writes an absolute path (not a topdir relative path).
Use 'df -P' to check the mount point; skip silently if /tmp is not its
own top-level mount rather than failing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
awk is not available in all CI containers. /proc/mounts is a standard
Linux procfs file with no external tool dependencies; grep on its second
field reliably detects whether /tmp is its own top-level mount point.
On macOS/BSD where /proc/mounts does not exist the grep exits non-zero
and the test skips silently.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Set XDG_DATA_HOME and XDG_CONFIG_HOME in the meson test environment so
rmw cannot accidentally read/write the real user's XDG dirs during tests.
Add a trap in test_media_root.sh to clean up /tmp dirs on failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
shellcheck cannot see that cleanup() is called indirectly via trap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@andy5995 andy5995 merged commit 1cd4001 into master Mar 26, 2026
15 checks passed
@andy5995 andy5995 deleted the fix-test-isolation branch March 26, 2026 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: RMW_FAKE_HOME unset could silently operate on real HOME

1 participant