Skip to content

Commit 4cd9999

Browse files
andy5995claude
andcommitted
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>
1 parent ebf2c74 commit 4cd9999

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

test/meson.build

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ test_cases = ['strings_rmw', 'utils', 'restore']
1313

1414
scripts = [
1515
'test_basic.sh',
16-
'test_media_root.sh',
1716
'test_purging.sh',
1817
'test_restore.sh',
1918
]
@@ -35,15 +34,33 @@ foreach case : test_cases
3534
test('test_' + case, exe)
3635
endforeach
3736

37+
# Set HOME to the fake home so rmw falls back safely if RMW_FAKE_HOME is ever
38+
# unset mid-script, preventing accidental writes to the real home directory.
39+
test_env = [
40+
'MESON_SOURCE_ROOT=' + meson.project_source_root(),
41+
'RMW_FAKE_HOME=' + RMW_FAKE_HOME,
42+
'HOME=' + RMW_FAKE_HOME,
43+
'MESON_BUILD_ROOT=' + meson.project_build_root(),
44+
]
45+
3846
foreach s : scripts
3947
test(
4048
s,
4149
files(s),
42-
env: [
43-
'MESON_SOURCE_ROOT=' + meson.project_source_root(),
44-
'RMW_FAKE_HOME=' + RMW_FAKE_HOME,
45-
'MESON_BUILD_ROOT=' + meson.project_build_root(),
46-
],
50+
env: test_env,
4751
depends: main_bin,
4852
)
4953
endforeach
54+
55+
# test_media_root.sh intentionally unsets RMW_FAKE_HOME and operates under the
56+
# real HOME (it skips automatically on machines without the expected mount point).
57+
test(
58+
'test_media_root.sh',
59+
files('test_media_root.sh'),
60+
env: [
61+
'MESON_SOURCE_ROOT=' + meson.project_source_root(),
62+
'RMW_FAKE_HOME=' + RMW_FAKE_HOME,
63+
'MESON_BUILD_ROOT=' + meson.project_build_root(),
64+
],
65+
depends: main_bin,
66+
)

0 commit comments

Comments
 (0)