From 5d88ff2519e4952f8d22472b52c531bb5f1635fc Mon Sep 17 00:00:00 2001 From: hkalbasi Date: Fri, 6 Sep 2024 18:00:27 +0330 Subject: [PATCH] tests/emulator/poke_around: test setting user.shell --- tests/emulator/poke_around.py | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/emulator/poke_around.py b/tests/emulator/poke_around.py index 8adc3d85..8df33a2b 100644 --- a/tests/emulator/poke_around.py +++ b/tests/emulator/poke_around.py @@ -52,3 +52,46 @@ def run(d): d.ui.press('enter') wait_for(d, 'This is Zip') screenshot(d, 'zip-is-still-there') + + def change_shell_and_relogin(shell, descr): + import base64 + import time + config = ('{pkgs, ...}: {user.shell = %SHELL%; ' + + 'system.stateVersion = "24.05";}').replace('%SHELL%', shell) + config_base64 = base64.b64encode(config.encode()).decode() + d(f'input text "echo {config_base64} | base64 -d > ' + '~/.config/nixpkgs/nix-on-droid.nix"') + d.ui.press('enter') + screenshot(d, f'pre-switch-{descr}') + d(f'input text "nix-on-droid switch && echo switched {descr}"') + d.ui.press('enter') + time.sleep(1) + screenshot(d, f'in-switch-{descr}') + wait_for(d, f'switched {descr}') + screenshot(d, f'post-switch-{descr}') + d('input text "exit"') + d.ui.press('enter') + screenshot(d, f'pre-re-login-{descr}') + d.app('com.termux.nix').launch() + time.sleep(1) + screenshot(d, f'post-re-login-{descr}') + + # change shell: pkgs.fish -> fish + change_shell_and_relogin('pkgs.fish', 'bare-fish') + wait_for(d, 'Welcome to fish, the friendly interactive shell') + screenshot(d, 're-login-done-bare-fish') + + # change shell: "${pkgs.fish}", which is a directory -> fallback + change_shell_and_relogin('"${pkgs.fish}"', 'fish-directory') + wait_for(d, 'Cannot execute shell ') + wait_for(d, 'it is a directory.') + wait_for(d, + "You should point 'user.shell' to the exact binary.") + wait_for(d, 'Falling back to bash.') + wait_for(d, 'bash-5.2$') + screenshot(d, 're-login-done-shell-dir-fallback') + + # change shell: "${pkgs.fish}/bin/fish" -> fish + change_shell_and_relogin('"${pkgs.fish}/bin/fish"', 'fish-bin-fish') + wait_for(d, 'Welcome to fish, the friendly interactive shell') + screenshot(d, 're-login-done-fish-bin-fish')