@@ -46,18 +46,54 @@ fileprivate struct Content {
4646struct ProcessInfoExtensionTests {
4747
4848 @Suite
49- struct isAmazonLinux2 {
49+ struct isHost {
5050 @Test (
5151 arguments: [
52- ( contentUT: " " , expected: false ) ,
53- ( contentUT: " PRETTY_NAME= " , expected: false ) ,
54- ( contentUT: " PRETTY_NAME=foo " , expected: false ) ,
55- ( contentUT: " PRETTY_NAME=amzn " , expected: false ) ,
56- ( contentUT: " PRETTY_NAME=Amazon Linux 2 " , expected: false ) ,
57- ( contentUT: " PRETTY_NAME=Amazon Linux 2023.6.20250107 " , expected: false ) ,
58- ( contentUT: " PRETTY_NAME=amzn " , expected: false ) ,
59- ( contentUT: " PRETTY_NAME= \" Amazon Linux 2 \" " , expected: true ) ,
60- ( contentUT: " PRETTY_NAME= \" Amazon Linux 2 (something else) \" " , expected: false ) ,
52+ (
53+ contentUT: " " ,
54+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
55+ expected: false ,
56+ ) ,
57+ (
58+ contentUT: " PRETTY_NAME= " ,
59+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
60+ expected: false ,
61+ ) ,
62+ (
63+ contentUT: " PRETTY_NAME=foo " ,
64+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
65+ expected: false ,
66+ ) ,
67+ (
68+ contentUT: " PRETTY_NAME=amzn " ,
69+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
70+ expected: false ,
71+ ) ,
72+ (
73+ contentUT: " PRETTY_NAME=Amazon Linux 2 " ,
74+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
75+ expected: false ,
76+ ) ,
77+ (
78+ contentUT: " PRETTY_NAME=Amazon Linux 2023.6.20250107 " ,
79+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
80+ expected: false ,
81+ ) ,
82+ (
83+ contentUT: " PRETTY_NAME=amzn " ,
84+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
85+ expected: false ,
86+ ) ,
87+ (
88+ contentUT: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
89+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
90+ expected: true ,
91+ ) ,
92+ (
93+ contentUT: " PRETTY_NAME= \" Amazon Linux 2 (something else) \" " ,
94+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
95+ expected: false ,
96+ ) ,
6197 (
6298 contentUT: """
6399 NAME= " Amazon Linux "
@@ -71,6 +107,7 @@ struct ProcessInfoExtensionTests {
71107 HOME_URL= " https://amazonlinux.com/ "
72108 SUPPORT_END= " 2026-06-30 "
73109 """ ,
110+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
74111 expected: true
75112 ) ,
76113 (
@@ -86,6 +123,7 @@ struct ProcessInfoExtensionTests {
86123 HOME_URL= " https://amazonlinux.com/ "
87124 SUPPORT_END= " 2026-06-30 "
88125 """ ,
126+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
89127 expected: false
90128 ) ,
91129 (
@@ -101,6 +139,7 @@ struct ProcessInfoExtensionTests {
101139 HOME_URL= " https://amazonlinux.com/ "
102140 SUPPORT_END= " 2026-06-30 "
103141 """ ,
142+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
104143 expected: false
105144 ) ,
106145 (
@@ -116,6 +155,7 @@ struct ProcessInfoExtensionTests {
116155 HOME_URL= " https://amazonlinux.com/ "
117156 SUPPORT_END= " 2026-06-30 "
118157 """ ,
158+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
119159 expected: false
120160 ) ,
121161 (
@@ -137,30 +177,33 @@ struct ProcessInfoExtensionTests {
137177 VENDOR_URL= " https://aws.amazon.com/ "
138178 SUPPORT_END= " 2028-03-15 "
139179 """ ,
180+ hostToMatch: " PRETTY_NAME= \" Amazon Linux 2 \" " ,
140181 expected: false ,
141182 )
142183 ] , prefixAndSuffixData,
143184 )
144185 fileprivate func isAmazonLinux2ReturnsExpectedValue(
145- data: ( contentUT: String , expected: Bool ) ,
186+ data: ( contentUT: String , hostToMatch : String , expected: Bool ) ,
146187 content: Content ,
147188 ) async throws {
148189 let content = content. getContent ( data. contentUT)
149190
150- let actual = ProcessInfo . isHostAmazonLinux2 ( content)
191+ let actual = ProcessInfo . isHost ( osName : data . hostToMatch , content)
151192
152193 #expect( actual == data. expected, " Content is: ' \( content) ' " )
153194 }
154195
155196 @Test (
156- " isHostAmazonLinux2 returns false when not executed on Linux" ,
197+ " isHost* returns false when not executed on Linux" ,
157198 . skipHostOS( . linux) ,
158199 . tags( Tag . TestSize. medium) ,
159200 )
160- func isAmazonLinux2ReturnsFalseWhenNotRunOnLinux( ) {
161- let actual = ProcessInfo . isHostAmazonLinux2 ( )
201+ func concreteIsHostReturnsFalseWhenNotRunOnLinux( ) {
202+ let actualAL2 = ProcessInfo . isHostAmazonLinux2 ( )
203+ #expect( actualAL2 == false )
162204
163- #expect( actual == false )
205+ let actualRHEL9 = ProcessInfo . isHostRHEL9 ( )
206+ #expect( actualRHEL9 == false )
164207 }
165208 }
166- }
209+ }
0 commit comments