@@ -45,43 +45,6 @@ fileprivate struct MacroEvaluationTests {
4545
4646 let buildParameters = SWBBuildParameters ( )
4747
48- // Evaluate using a scope.
49- do {
50- // Get the project macro scope.
51- let scope = try await session. createMacroEvaluationScope ( level: . project( testProject. guid) , buildParameters: buildParameters)
52-
53- expectEqual ( try await scope. evaluateMacroAsString ( " PROJECT " ) , " aProject " )
54- #expect( try await !scope. evaluateMacroAsBool ( " PROJECT " ) )
55- expectEqual ( try await scope. evaluateMacroAsStringList ( " PROJECT " ) , [ " aProject " ] )
56- expectEqual ( try await scope. evaluateMacroAsString ( " TARGET_NAME " ) , " " )
57- #expect( try await !scope. evaluateMacroAsBool ( " TARGET_NAME " ) )
58- expectEqual ( try await scope. evaluateMacroAsStringList ( " TARGET_NAME " ) , [ " " ] )
59- expectEqual ( try await scope. evaluateMacroAsStringList ( " HEADER_SEARCH_PATHS " ) , [ ] )
60- #expect( try await !scope. evaluateMacroAsBool ( " HEADER_SEARCH_PATHS " ) )
61- expectEqual ( try await scope. evaluateMacroAsString ( " HEADER_SEARCH_PATHS " ) , " " )
62- #expect( try await scope. evaluateMacroAsBool ( " INFOPLIST_EXPAND_BUILD_SETTINGS " ) )
63- expectEqual ( try await scope. evaluateMacroAsStringList ( " INFOPLIST_EXPAND_BUILD_SETTINGS " ) , [ " YES " ] )
64- expectEqual ( try await scope. evaluateMacroAsString ( " INFOPLIST_EXPAND_BUILD_SETTINGS " ) , " YES " )
65- await #expect( throws: ( any Error ) . self) {
66- try await scope. evaluateMacroAsBool ( " DOES_NOT_EXIST " )
67- }
68- await #expect( throws: ( any Error ) . self) {
69- try await scope. evaluateMacroAsString ( " DOES_NOT_EXIST " )
70- }
71- await #expect( throws: ( any Error ) . self) {
72- try await scope. evaluateMacroAsStringList ( " DOES_NOT_EXIST " )
73- }
74- }
75-
76- do {
77- // Get the target macro scope.
78- let scope = try await session. createMacroEvaluationScope ( level: . target( testTarget. guid) , buildParameters: buildParameters)
79-
80- expectEqual ( try await scope. evaluateMacroAsString ( " TARGET_NAME " ) , " ExternalTarget " )
81- #expect( try await !scope. evaluateMacroAsBool ( " TARGET_NAME " ) )
82- expectEqual ( try await scope. evaluateMacroAsStringList ( " TARGET_NAME " ) , [ " ExternalTarget " ] )
83- }
84-
8548 // Evaluate directly against the model objects.
8649 do {
8750 let level = SWBMacroEvaluationLevel . project ( testProject. guid)
@@ -240,45 +203,6 @@ fileprivate struct MacroEvaluationTests {
240203 parameters. action = " build "
241204 parameters. configurationName = " Config1 "
242205
243- // Evaluate using a scope.
244- let scope = try await session. createMacroEvaluationScope ( level: . target( " T1 " ) , buildParameters: parameters)
245-
246- // Evaluate some macros as strings.
247- await #expect( throws: ( any Error ) . self) {
248- try await scope. evaluateMacroAsString ( " UNDEFINED_MACRO " , overrides: nil )
249- }
250- expectEqual ( try await scope. evaluateMacroAsString ( " USER " , overrides: nil ) , userInfo. userName)
251- expectEqual ( try await scope. evaluateMacroAsString ( " PRODUCT_NAME " , overrides: nil ) , " MyApp " )
252- expectEqual ( try await scope. evaluateMacroAsString ( " TARGET_NAME " , overrides: nil ) , " Target1 " )
253- expectEqual ( try await scope. evaluateMacroAsString ( " CONFIGURATION " , overrides: nil ) , " Config1 " )
254- expectEqual ( try await scope. evaluateMacroAsString ( " IS_TRUE " , overrides: nil ) , " YES " )
255- expectEqual ( try await scope. evaluateMacroAsString ( " IS_FALSE " , overrides: nil ) , " NO " )
256- expectEqual ( try await scope. evaluateMacroAsString ( " OTHER_CFLAGS " , overrides: nil ) , " -DPROJECT -DTARGET " )
257- // Evaluate some macros as booleans.
258- #expect( try await scope. evaluateMacroAsBool ( " IS_TRUE " ) )
259- #expect( try await !scope. evaluateMacroAsBool ( " IS_FALSE " ) )
260- await #expect( throws: ( any Error ) . self) {
261- try await scope. evaluateMacroAsBool ( " UNDEFINED_MACRO " )
262- }
263- #expect( try await !scope. evaluateMacroAsBool ( " PRODUCT_NAME " ) )
264-
265- // Evaluate some macros as string lists.
266- expectEqual ( try await scope. evaluateMacroAsStringList ( " OTHER_CFLAGS " ) , [ " -DPROJECT " , " -DTARGET " ] )
267- // Evaluate some macro expressions as strings.
268- expectEqual ( try await scope. evaluateMacroExpressionAsString ( " The name of the product is $(FULL_PRODUCT_NAME) " ) , " The name of the product is MyApp.app " )
269-
270- #expect( ( try await scope. evaluateMacroExpressionAsString ( " $(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH) " ) ) . hasSuffix ( " build/Config1/MyApp.app/Contents/MacOS/MyApp " ) )
271-
272- // Evaluate some macro expressions as string lists.
273- expectEqual ( try await scope. evaluateMacroExpressionAsStringList ( " $(FULL_PRODUCT_NAME) " ) , [ " MyApp.app " ] )
274- expectEqual ( try await scope. evaluateMacroExpressionArrayAsStringList ( [ " $(A) " , " $(B) " ] ) , [ " A " , " B " ] )
275- // Evaluate an array of macro expressions as individual strings.
276- expectEqual ( try await scope. evaluateMacroExpressionArrayAsStringList ( [ " $(A) " , " $(B) " , " $(IS_TRUE) " ] ) , [ " A " , " B " , " YES " ] )
277- // Test using overrides.
278- expectEqual ( try await scope. evaluateMacroAsString ( " FLEXIBLE " ) , " A B C " )
279- expectEqual ( try await scope. evaluateMacroAsString ( " FLEXIBLE " , overrides: [ " A " : " D " ] ) , " D B C " )
280- expectEqual ( try await scope. evaluateMacroAsString ( " FLEXIBLE " , overrides: [ " B " : " $(PRODUCT_NAME) " ] ) , " A MyApp C " )
281- expectEqual ( try await scope. evaluateMacroExpressionAsStringList ( " $(FLEXIBLE) " , overrides: [ " C " : " X Y " ] ) , [ " A " , " B " , " X " , " Y " ] )
282206 // Evaluate directly against the target.
283207 let level = SWBMacroEvaluationLevel . target ( " T1 " )
284208
0 commit comments