Skip to content

Commit 5d88ff2

Browse files
HKalbasit184256
authored andcommitted
tests/emulator/poke_around: test setting user.shell
1 parent 21629b4 commit 5d88ff2

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/emulator/poke_around.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,46 @@ def run(d):
5252
d.ui.press('enter')
5353
wait_for(d, 'This is Zip')
5454
screenshot(d, 'zip-is-still-there')
55+
56+
def change_shell_and_relogin(shell, descr):
57+
import base64
58+
import time
59+
config = ('{pkgs, ...}: {user.shell = %SHELL%; ' +
60+
'system.stateVersion = "24.05";}').replace('%SHELL%', shell)
61+
config_base64 = base64.b64encode(config.encode()).decode()
62+
d(f'input text "echo {config_base64} | base64 -d > '
63+
'~/.config/nixpkgs/nix-on-droid.nix"')
64+
d.ui.press('enter')
65+
screenshot(d, f'pre-switch-{descr}')
66+
d(f'input text "nix-on-droid switch && echo switched {descr}"')
67+
d.ui.press('enter')
68+
time.sleep(1)
69+
screenshot(d, f'in-switch-{descr}')
70+
wait_for(d, f'switched {descr}')
71+
screenshot(d, f'post-switch-{descr}')
72+
d('input text "exit"')
73+
d.ui.press('enter')
74+
screenshot(d, f'pre-re-login-{descr}')
75+
d.app('com.termux.nix').launch()
76+
time.sleep(1)
77+
screenshot(d, f'post-re-login-{descr}')
78+
79+
# change shell: pkgs.fish -> fish
80+
change_shell_and_relogin('pkgs.fish', 'bare-fish')
81+
wait_for(d, 'Welcome to fish, the friendly interactive shell')
82+
screenshot(d, 're-login-done-bare-fish')
83+
84+
# change shell: "${pkgs.fish}", which is a directory -> fallback
85+
change_shell_and_relogin('"${pkgs.fish}"', 'fish-directory')
86+
wait_for(d, 'Cannot execute shell ')
87+
wait_for(d, 'it is a directory.')
88+
wait_for(d,
89+
"You should point 'user.shell' to the exact binary.")
90+
wait_for(d, 'Falling back to bash.')
91+
wait_for(d, 'bash-5.2$')
92+
screenshot(d, 're-login-done-shell-dir-fallback')
93+
94+
# change shell: "${pkgs.fish}/bin/fish" -> fish
95+
change_shell_and_relogin('"${pkgs.fish}/bin/fish"', 'fish-bin-fish')
96+
wait_for(d, 'Welcome to fish, the friendly interactive shell')
97+
screenshot(d, 're-login-done-fish-bin-fish')

0 commit comments

Comments
 (0)