1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-25 21:57:32 +03:00

test: use XDG_STATE_HOME for %S and %L

This fixes the test failure when invoked by a user.
===
Running ./systemd-tmpfiles --user on 'f /tmp/test-systemd-tmpfiles.1foag_ur/test-content.n_9r_xhm/arg - - - - %S'
expect: '/home/watanabe/.config'
actual: '/home/watanabe/.local/state'
Traceback (most recent call last):
  File "/home/watanabe/git/systemd/test/test-systemd-tmpfiles.py", line 233, in <module>
    test_valid_specifiers(user=True)
  File "/home/watanabe/git/systemd/test/test-systemd-tmpfiles.py", line 135, in test_valid_specifiers
    test_content('f {} - - - - %S',
  File "/home/watanabe/git/systemd/test/test-systemd-tmpfiles.py", line 88, in test_content
    assert content == expected
           ^^^^^^^^^^^^^^^^^^^
AssertionError
===

This also makes the test uses fallback paths.

Follow-up for b50aadaff22f9b3ad3bbcbfd2edd661456a5b4bf.
This commit is contained in:
Yu Watanabe 2023-07-20 16:07:58 +09:00 committed by Luca Boccassi
parent 4fc925a026
commit b0efbe9b81

View File

@ -130,22 +130,23 @@ def test_valid_specifiers(*, user):
xdg_runtime_dir if user else '/run',
user=user)
xdg_config_home = os.getenv('XDG_CONFIG_HOME')
if xdg_config_home is not None or not user:
test_content('f {} - - - - %S',
xdg_config_home if user else '/var/lib',
user=user)
xdg_state_home = os.getenv('XDG_STATE_HOME')
if xdg_state_home is None and user:
xdg_state_home = os.path.join(home, ".local/state")
test_content('f {} - - - - %S',
xdg_state_home if user else '/var/lib',
user=user)
xdg_cache_home = os.getenv('XDG_CACHE_HOME')
if xdg_cache_home is not None or not user:
test_content('f {} - - - - %C',
xdg_cache_home if user else '/var/cache',
user=user)
if xdg_cache_home is None and user:
xdg_cache_home = os.path.join(home, ".cache")
test_content('f {} - - - - %C',
xdg_cache_home if user else '/var/cache',
user=user)
if xdg_config_home is not None or not user:
test_content('f {} - - - - %L',
xdg_config_home + '/log' if user else '/var/log',
user=user)
test_content('f {} - - - - %L',
os.path.join(xdg_state_home, 'log') if user else '/var/log',
user=user)
test_content('f {} - - - - %%', '%', user=user)