@@ -40,6 +40,29 @@ void main() {
4040 expect (result? .configuration, zshConfiguration);
4141 });
4242
43+ test ('identifies bash shell' , () {
44+ final logger = MockLogger ();
45+ final result = ShellCompletionInstallation .fromCurrentShell (
46+ logger: logger,
47+ isWindowsOverride: false ,
48+ environmentOverride: {
49+ 'SHELL' : '/foo/bar/bash' ,
50+ },
51+ );
52+
53+ expect (result? .configuration, bashConfiguration);
54+
55+ final resultWindows = ShellCompletionInstallation .fromCurrentShell (
56+ logger: logger,
57+ isWindowsOverride: true ,
58+ environmentOverride: {
59+ 'SHELL' : r'c:\foo\bar\bash.exe' ,
60+ },
61+ );
62+
63+ expect (resultWindows? .configuration, bashConfiguration);
64+ });
65+
4366 group ('identifies no shell' , () {
4467 test ('for no shell env' , () {
4568 final result = ShellCompletionInstallation .fromCurrentShell (
@@ -401,11 +424,50 @@ void main() {
401424
402425''' );
403426
404- expect (configDir.listSync ().map ((e) => path.basename (e.path)), [
405- 'not_good.zsh' ,
406- 'very_good.zsh' ,
407- 'zsh-config.zsh' ,
408- ]);
427+ expect (
428+ configDir.listSync ().map ((e) => path.basename (e.path)),
429+ unorderedEquals ([
430+ 'not_good.zsh' ,
431+ 'very_good.zsh' ,
432+ 'zsh-config.zsh' ,
433+ ]),
434+ );
435+
436+ final bashInstallation = ShellCompletionInstallation (
437+ logger: logger,
438+ isWindows: false ,
439+ environment: {
440+ 'HOME' : tempDir.path,
441+ },
442+ configuration: bashConfiguration,
443+ );
444+
445+ final bashProfile = File (path.join (tempDir.path, '.bash_profile' ))
446+ ..createSync ();
447+
448+ bashInstallation
449+ ..install ('very_good' )
450+ ..install ('not_good' );
451+
452+ // ignore: leading_newlines_in_multiline_strings
453+ expect (bashProfile.readAsStringSync (), '''## [Completion]
454+ ## Completion scripts setup. Remove the following line to uninstall
455+ [ -f ${configDir .path }/bash-config.bash ] && . ${configDir .path }/bash-config.bash || true
456+ ## [/Completion]
457+
458+ ''' );
459+
460+ expect (
461+ configDir.listSync ().map ((e) => path.basename (e.path)),
462+ unorderedEquals ([
463+ 'not_good.bash' ,
464+ 'not_good.zsh' ,
465+ 'very_good.bash' ,
466+ 'very_good.zsh' ,
467+ 'zsh-config.zsh' ,
468+ 'bash-config.bash'
469+ ]),
470+ );
409471 },
410472 );
411473 });
0 commit comments