@@ -151,60 +151,29 @@ def test_parse(self) -> None:
151151 with self .subTest ():
152152 self .assertEqual (cfg .parse (iter (cfg .lexer (data ))), expected )
153153
154- def test_ir_to_meson (self ) -> None :
155- build = builder .Builder ('' )
156- HOST_MACHINE = build .identifier ('host_machine' )
157-
154+ def test_eval_ir (self ) -> None :
155+ d = {
156+ 'target_os' : 'unix' ,
157+ 'unix' : '' ,
158+ }
158159 cases = [
159- ('target_os = "windows"' ,
160- build .equal (build .method ('system' , HOST_MACHINE ),
161- build .string ('windows' ))),
162- ('target_arch = "x86"' ,
163- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
164- build .string ('x86' ))),
165- ('target_family = "unix"' ,
166- build .equal (build .method ('system' , HOST_MACHINE ),
167- build .string ('unix' ))),
168- ('not(target_arch = "x86")' ,
169- build .not_ (build .equal (
170- build .method ('cpu_family' , HOST_MACHINE ),
171- build .string ('x86' )))),
172- ('any(target_arch = "x86", target_arch = "x86_64")' ,
173- build .or_ (
174- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
175- build .string ('x86' )),
176- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
177- build .string ('x86_64' )))),
178- ('any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")' ,
179- build .or_ (
180- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
181- build .string ('x86' )),
182- build .or_ (
183- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
184- build .string ('x86_64' )),
185- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
186- build .string ('aarch64' ))))),
187- ('all(target_arch = "x86", target_arch = "x86_64")' ,
188- build .and_ (
189- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
190- build .string ('x86' )),
191- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
192- build .string ('x86_64' )))),
193- ('all(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")' ,
194- build .and_ (
195- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
196- build .string ('x86' )),
197- build .and_ (
198- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
199- build .string ('x86_64' )),
200- build .equal (build .method ('cpu_family' , HOST_MACHINE ),
201- build .string ('aarch64' ))))),
202- ('all()' , build .bool (True )),
203- ('any()' , build .bool (False )),
160+ ('target_os = "windows"' , False ),
161+ ('target_os = "unix"' , True ),
162+ ('doesnotexist = "unix"' , False ),
163+ ('not(target_os = "windows")' , True ),
164+ ('any(target_os = "windows", target_arch = "x86_64")' , False ),
165+ ('any(target_os = "windows", target_os = "unix")' , True ),
166+ ('all(target_os = "windows", target_os = "unix")' , False ),
167+ ('all(not(target_os = "windows"), target_os = "unix")' , True ),
168+ ('any(unix, windows)' , True ),
169+ ('all()' , True ),
170+ ('any()' , False ),
171+ ('cfg(unix)' , True ),
172+ ('cfg(windows)' , False ),
204173 ]
205174 for data , expected in cases :
206175 with self .subTest ():
207- value = cfg .ir_to_meson ( cfg . parse ( iter ( cfg . lexer ( data ))), build )
176+ value = cfg .eval_cfg ( data , d )
208177 self .assertEqual (value , expected )
209178
210179class CargoLockTest (unittest .TestCase ):
0 commit comments