@@ -3,69 +3,93 @@ import 'package:test/test.dart';
33
44void main () {
55 group ('SystemShell' , () {
6- group ('fromCurrentShell ' , () {
6+ group ('current ' , () {
77 test ('instantiated without env' , () {
88 expect (
99 SystemShell .current,
1010 returnsNormally,
1111 );
1212 });
1313
14- test ('identifies zsh' , () {
15- final result = SystemShell .current (
16- environmentOverride: {
17- 'SHELL' : '/foo/bar/zsh' ,
18- },
19- );
20-
21- expect (result, SystemShell .zsh);
22- });
23-
24- test ('identifies bash shell' , () {
25- final result = SystemShell .current (
26- environmentOverride: {
27- 'SHELL' : '/foo/bar/bash' ,
28- },
29- );
14+ group ('Heuristics' , () {
15+ test ('identifies zsh' , () {
16+ final result = SystemShell .current (
17+ environmentOverride: {
18+ 'ZSH_NAME' : 'zsh' ,
19+ },
20+ );
3021
31- expect (result, SystemShell .bash);
22+ expect (result, SystemShell .zsh);
23+ });
3224
33- final resultWindows = SystemShell .current (
34- environmentOverride: {
35- 'SHELL' : r'c:\foo\bar\bash.exe' ,
36- },
37- );
25+ test ('identifies bash' , () {
26+ final result = SystemShell .current (
27+ environmentOverride: {
28+ 'BASH' : '/bin/bash' ,
29+ },
30+ );
3831
39- expect (resultWindows, SystemShell .bash);
32+ expect (result, SystemShell .bash);
33+ });
4034 });
4135
42- group ('identifies no shell ' , () {
43- test ('for no shell env ' , () {
36+ group (r'When checking $SHELL ' , () {
37+ test ('identifies zsh ' , () {
4438 final result = SystemShell .current (
45- environmentOverride: {},
39+ environmentOverride: {
40+ 'SHELL' : '/foo/bar/zsh' ,
41+ },
4642 );
4743
48- expect (result, null );
44+ expect (result, SystemShell .zsh );
4945 });
5046
51- test ('for empty shell env ' , () {
47+ test ('identifies bash shell' , () {
5248 final result = SystemShell .current (
5349 environmentOverride: {
54- 'SHELL' : '' ,
50+ 'SHELL' : '/foo/bar/bash ' ,
5551 },
5652 );
5753
58- expect (result, null );
59- });
54+ expect (result, SystemShell .bash);
6055
61- test ('for extraneous shell' , () {
62- final result = SystemShell .current (
56+ final resultWindows = SystemShell .current (
6357 environmentOverride: {
64- 'SHELL' : '/usr/bin/someshell ' ,
58+ 'SHELL' : r'c:\foo\bar\bash.exe ' ,
6559 },
6660 );
6761
68- expect (result, null );
62+ expect (resultWindows, SystemShell .bash);
63+ });
64+
65+ group ('identifies no shell' , () {
66+ test ('for no shell env' , () {
67+ final result = SystemShell .current (
68+ environmentOverride: {},
69+ );
70+
71+ expect (result, null );
72+ });
73+
74+ test ('for empty shell env' , () {
75+ final result = SystemShell .current (
76+ environmentOverride: {
77+ 'SHELL' : '' ,
78+ },
79+ );
80+
81+ expect (result, null );
82+ });
83+
84+ test ('for extraneous shell' , () {
85+ final result = SystemShell .current (
86+ environmentOverride: {
87+ 'SHELL' : '/usr/bin/someshell' ,
88+ },
89+ );
90+
91+ expect (result, null );
92+ });
6993 });
7094 });
7195 });
0 commit comments