|
4 | 4 | # 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/ |
5 | 5 |
|
6 | 6 | importcontextlib |
| 7 | +fromdataclassesimportdataclass |
7 | 8 | fromioimportBytesIO |
8 | 9 | importlogging |
9 | 10 | importos |
|
17 | 18 |
|
18 | 19 | importddt |
19 | 20 | importpytest |
20 | | -fromsumtypesimportconstructor,sumtype |
21 | 21 |
|
22 | 22 | fromgitimport ( |
23 | 23 | BlobFilter, |
@@ -66,34 +66,48 @@ def _get_windows_ansi_encoding(): |
66 | 66 | returnf"cp{value}" |
67 | 67 |
|
68 | 68 |
|
69 | | -@sumtype |
70 | 69 | classWinBashStatus: |
71 | | -"""Status of bash.exefor native Windows. Affectswhich commit hook tests can pass. |
| 70 | +"""Namespace ofnative-Windowsbash.exestatuses. Affectswhat hook tests can pass. |
72 | 71 |
|
73 | 72 | Call check() to check the status. (CheckError and WinError should not typically be |
74 | 73 | used to trigger skip or xfail, because they represent unexpected situations.) |
75 | 74 | """ |
76 | 75 |
|
77 | | -Inapplicable=constructor() |
78 | | -"""This system is not native Windows: either not Windows at all, or Cygwin.""" |
| 76 | +@dataclass |
| 77 | +classInapplicable: |
| 78 | +"""This system is not native Windows: either not Windows at all, or Cygwin.""" |
79 | 79 |
|
80 | | -Absent=constructor() |
81 | | -"""No command for bash.exe is found on the system.""" |
| 80 | +@dataclass |
| 81 | +classAbsent: |
| 82 | +"""No command for bash.exe is found on the system.""" |
82 | 83 |
|
83 | | -Native=constructor() |
84 | | -"""Running bash.exe operates outside any WSL distribution (as with Git Bash).""" |
| 84 | +@dataclass |
| 85 | +classNative: |
| 86 | +"""Running bash.exe operates outside any WSL distribution (as with Git Bash).""" |
85 | 87 |
|
86 | | -Wsl=constructor() |
87 | | -"""Running bash.exe calls bash in a WSL distribution.""" |
| 88 | +@dataclass |
| 89 | +classWsl: |
| 90 | +"""Running bash.exe calls bash in a WSL distribution.""" |
88 | 91 |
|
89 | | -WslNoDistro=constructor("process","message") |
90 | | -"""Running bash.exe tries to run bash on a WSL distribution, but none exists.""" |
| 92 | +@dataclass |
| 93 | +classWslNoDistro: |
| 94 | +"""Running bash.exe tries to run bash on a WSL distribution, but none exists.""" |
91 | 95 |
|
92 | | -CheckError=constructor("process","message") |
93 | | -"""Running bash.exe fails in an unexpected error or gives unexpected output.""" |
| 96 | +process:"subprocess.CompletedProcess[bytes]" |
| 97 | +message:str |
94 | 98 |
|
95 | | -WinError=constructor("exception") |
96 | | -"""bash.exe may exist but can't run. CreateProcessW fails unexpectedly.""" |
| 99 | +@dataclass |
| 100 | +classCheckError: |
| 101 | +"""Running bash.exe fails in an unexpected error or gives unexpected output.""" |
| 102 | + |
| 103 | +process:"subprocess.CompletedProcess[bytes]" |
| 104 | +message:str |
| 105 | + |
| 106 | +@dataclass |
| 107 | +classWinError: |
| 108 | +"""bash.exe may exist but can't run. CreateProcessW fails unexpectedly.""" |
| 109 | + |
| 110 | +exception:OSError |
97 | 111 |
|
98 | 112 | @classmethod |
99 | 113 | defcheck(cls): |
|