Add tests for --noprofile, --rcfile, --norc as well

This commit is contained in:
Kovid Goyal 2022-02-23 10:42:25 +05:30
parent c47f41cfc0
commit fc9645832d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -187,7 +187,7 @@ PS1="{ps1}"
def setup_env(excluded, argv, home_dir, rc='', shell='bash'): def setup_env(excluded, argv, home_dir, rc='', shell='bash'):
ans = basic_shell_env(home_dir) ans = basic_shell_env(home_dir)
setup_bash_env(ans, argv) setup_bash_env(ans, argv)
for x in {'profile', 'bash.bashrc', '.bash_profile', '.bash_login', '.profile', '.bashrc'} - excluded: for x in {'profile', 'bash.bashrc', '.bash_profile', '.bash_login', '.profile', '.bashrc', 'rcfile'} - excluded:
with open(os.path.join(home_dir, x), 'w') as f: with open(os.path.join(home_dir, x), 'w') as f:
print(f'echo {x}', file=f) print(f'echo {x}', file=f)
ans['KITTY_BASH_ETC_LOCATION'] = home_dir ans['KITTY_BASH_ETC_LOCATION'] = home_dir
@ -201,6 +201,10 @@ PS1="{ps1}"
self.assertIn(x, q) self.assertIn(x, q)
run_test('bash', 'bash.bashrc', '.bashrc') run_test('bash', 'bash.bashrc', '.bashrc')
run_test('bash --rcfile rcfile', 'bash.bashrc', 'rcfile')
run_test('bash --init-file rcfile', 'bash.bashrc', 'rcfile')
run_test('bash --norc')
run_test('bash -l', 'profile', '.bash_profile') run_test('bash -l', 'profile', '.bash_profile')
run_test('bash --noprofile -l')
run_test('bash -l', 'profile', '.bash_login', excluded=('.bash_profile',)) run_test('bash -l', 'profile', '.bash_login', excluded=('.bash_profile',))
run_test('bash -l', 'profile', '.profile', excluded=('.bash_profile', '.bash_login')) run_test('bash -l', 'profile', '.profile', excluded=('.bash_profile', '.bash_login'))