Commit 1cd4001
Fix test isolation (#520)
* test: set HOME to fake home to prevent accidental writes to real HOME
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>
* test: rewrite test_media_root.sh to use /tmp instead of hardcoded paths
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>
* test: use hard-link probe instead of stat for cross-device detection
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>
* test: skip test_media_root.sh if /tmp is not a top-level mount
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>
* test: use /proc/mounts instead of df+awk to check /tmp mount
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>
* test: add XDG sandboxing and cleanup trap
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>
* test: suppress SC2329 on cleanup trap function
shellcheck cannot see that cleanup() is called indirectly via trap.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent ebf2c74 commit 1cd4001
2 files changed
+74
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
41 | 52 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 53 | + | |
47 | 54 | | |
48 | 55 | | |
49 | 56 | | |
| 57 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
33 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | | - | |
| 56 | + | |
51 | 57 | | |
52 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
53 | 61 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
58 | 79 | | |
59 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
60 | 84 | | |
61 | | - | |
62 | | - | |
| 85 | + | |
63 | 86 | | |
64 | 87 | | |
0 commit comments