Skip to content

Commit 19c3276

Browse files
Update with macro validation skippability (#30)
Update with macro validation
1 parent 728ae91 commit 19c3276

8 files changed

Lines changed: 141 additions & 10 deletions

File tree

Sources/fxios/Commands/Build.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ struct Build: ParsableCommand {
6868
@Option(name: .long, help: "Custom derived data path.")
6969
var derivedData: String?
7070

71+
@Flag(
72+
name: [.customLong("doNotSkipMacroValidation"), .customLong("do-not-skip-macro-validation")],
73+
help: "Do not pass -skipMacroValidation to xcodebuild."
74+
)
75+
var doNotSkipMacroValidation = false
76+
77+
var skipMacroValidation: Bool { !doNotSkipMacroValidation }
78+
7179
// MARK: - Workflow Options
7280

7381
@Flag(name: .long, help: "Skip resolving Swift Package dependencies.")
@@ -204,15 +212,17 @@ struct Build: ParsableCommand {
204212
projectPath: projectPath,
205213
scheme: product.scheme,
206214
configuration: config,
207-
derivedDataPath: derivedData
215+
derivedDataPath: derivedData,
216+
skipMacroValidation: skipMacroValidation
208217
)
209218
} else if let sim = simulator {
210219
return CommandHelpers.buildXcodebuildArgs(
211220
projectPath: projectPath,
212221
scheme: product.scheme,
213222
configuration: config,
214223
simulator: sim,
215-
derivedDataPath: derivedData
224+
derivedDataPath: derivedData,
225+
skipMacroValidation: skipMacroValidation
216226
)
217227
}
218228

Sources/fxios/Commands/Run.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ struct Run: ParsableCommand {
6161
@Option(name: .long, help: "Custom derived data path.")
6262
var derivedData: String?
6363

64+
@Flag(
65+
name: [.customLong("doNotSkipMacroValidation"), .customLong("do-not-skip-macro-validation")],
66+
help: "Do not pass -skipMacroValidation to xcodebuild."
67+
)
68+
var doNotSkipMacroValidation = false
69+
70+
var skipMacroValidation: Bool { !doNotSkipMacroValidation }
71+
6472
// MARK: - Workflow Options
6573

6674
@Flag(name: .long, help: "Skip resolving Swift Package dependencies.")
@@ -183,7 +191,8 @@ struct Run: ParsableCommand {
183191
scheme: product.scheme,
184192
configuration: config,
185193
simulator: simulator,
186-
derivedDataPath: derivedData
194+
derivedDataPath: derivedData,
195+
skipMacroValidation: skipMacroValidation
187196
)
188197

189198
// Add build action
@@ -274,7 +283,8 @@ struct Run: ParsableCommand {
274283
scheme: product.scheme,
275284
configuration: config,
276285
simulator: simulator,
277-
derivedDataPath: derivedData
286+
derivedDataPath: derivedData,
287+
skipMacroValidation: skipMacroValidation
278288
)
279289
buildArgs.append("build")
280290

Sources/fxios/Commands/Test.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ struct Test: ParsableCommand {
6161
@Option(name: .long, help: "Custom derived data path.")
6262
var derivedData: String?
6363

64+
@Flag(
65+
name: [.customLong("doNotSkipMacroValidation"), .customLong("do-not-skip-macro-validation")],
66+
help: "Do not pass -skipMacroValidation to xcodebuild."
67+
)
68+
var doNotSkipMacroValidation = false
69+
70+
var skipMacroValidation: Bool { !doNotSkipMacroValidation }
71+
6472
// MARK: - Test Options
6573

6674
@Option(name: .long, help: "Maximum test retries on failure (default: 0).")
@@ -161,7 +169,8 @@ struct Test: ParsableCommand {
161169
scheme: product.scheme,
162170
configuration: product.testingConfiguration,
163171
simulator: simulator,
164-
derivedDataPath: derivedData
172+
derivedDataPath: derivedData,
173+
skipMacroValidation: skipMacroValidation
165174
)
166175
args.append("build-for-testing")
167176

@@ -191,7 +200,8 @@ struct Test: ParsableCommand {
191200
scheme: product.scheme,
192201
configuration: product.testingConfiguration,
193202
simulator: simulator,
194-
derivedDataPath: derivedData
203+
derivedDataPath: derivedData,
204+
skipMacroValidation: skipMacroValidation
195205
)
196206

197207
// Add test plan if available
@@ -232,7 +242,8 @@ struct Test: ParsableCommand {
232242
scheme: product.scheme,
233243
configuration: product.testingConfiguration,
234244
simulator: simulator,
235-
derivedDataPath: derivedData
245+
derivedDataPath: derivedData,
246+
skipMacroValidation: skipMacroValidation
236247
)
237248
buildArgs.append("build-for-testing")
238249

@@ -247,7 +258,8 @@ struct Test: ParsableCommand {
247258
scheme: product.scheme,
248259
configuration: product.testingConfiguration,
249260
simulator: simulator,
250-
derivedDataPath: derivedData
261+
derivedDataPath: derivedData,
262+
skipMacroValidation: skipMacroValidation
251263
)
252264

253265
// Add test plan if available

Sources/fxios/Core/CommandHelpers.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ enum CommandHelpers {
255255
scheme: String,
256256
configuration: String,
257257
simulator: SimulatorSelection,
258-
derivedDataPath: String?
258+
derivedDataPath: String?,
259+
skipMacroValidation: Bool = true
259260
) -> [String] {
260261
var args: [String] = []
261262

@@ -274,6 +275,10 @@ enum CommandHelpers {
274275
args += ["-derivedDataPath", derivedData]
275276
}
276277

278+
if skipMacroValidation {
279+
args += ["-skipMacroValidation"]
280+
}
281+
277282
// Common build settings
278283
args += ["COMPILER_INDEX_STORE_ENABLE=NO"]
279284

@@ -290,7 +295,8 @@ enum CommandHelpers {
290295
projectPath: URL,
291296
scheme: String,
292297
configuration: String,
293-
derivedDataPath: String?
298+
derivedDataPath: String?,
299+
skipMacroValidation: Bool = true
294300
) -> [String] {
295301
var args: [String] = []
296302

@@ -308,6 +314,10 @@ enum CommandHelpers {
308314
args += ["-derivedDataPath", derivedData]
309315
}
310316

317+
if skipMacroValidation {
318+
args += ["-skipMacroValidation"]
319+
}
320+
311321
// Common build settings
312322
args += ["COMPILER_INDEX_STORE_ENABLE=NO"]
313323

Tests/fxiosTests/BuildTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ struct BuildTests {
146146
#expect(command.derivedData == "/tmp/DD")
147147
}
148148

149+
@Test("Can parse doNotSkipMacroValidation flag")
150+
func parseDoNotSkipMacroValidation() throws {
151+
let command = try Build.parse(["--doNotSkipMacroValidation"])
152+
#expect(command.doNotSkipMacroValidation == true)
153+
#expect(command.skipMacroValidation == false)
154+
}
155+
149156
@Test("Can parse skip-resolve flag")
150157
func parseSkipResolve() throws {
151158
let command = try Build.parse(["--skip-resolve"])
@@ -186,6 +193,8 @@ struct BuildTests {
186193
#expect(command.os == nil)
187194
#expect(command.configuration == nil)
188195
#expect(command.derivedData == nil)
196+
#expect(command.doNotSkipMacroValidation == false)
197+
#expect(command.skipMacroValidation == true)
189198
#expect(command.skipResolve == false)
190199
#expect(command.clean == false)
191200
#expect(command.quiet == false)

Tests/fxiosTests/CommandHelpersTests.swift

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,39 @@ struct CommandHelpersTests {
264264
#expect(args.contains("COMPILER_INDEX_STORE_ENABLE=NO"))
265265
}
266266

267+
@Test("buildXcodebuildArgs skips macro validation by default")
268+
func buildArgsSkipMacroValidationByDefault() {
269+
let projectPath = URL(fileURLWithPath: "/path/to/Client.xcodeproj")
270+
let simulator = createMockSimulatorSelection()
271+
272+
let args = CommandHelpers.buildXcodebuildArgs(
273+
projectPath: projectPath,
274+
scheme: "Fennec",
275+
configuration: "Fennec",
276+
simulator: simulator,
277+
derivedDataPath: nil
278+
)
279+
280+
#expect(args.contains("-skipMacroValidation"))
281+
}
282+
283+
@Test("buildXcodebuildArgs can omit macro validation skip")
284+
func buildArgsCanOmitMacroValidationSkip() {
285+
let projectPath = URL(fileURLWithPath: "/path/to/Client.xcodeproj")
286+
let simulator = createMockSimulatorSelection()
287+
288+
let args = CommandHelpers.buildXcodebuildArgs(
289+
projectPath: projectPath,
290+
scheme: "Fennec",
291+
configuration: "Fennec",
292+
simulator: simulator,
293+
derivedDataPath: nil,
294+
skipMacroValidation: false
295+
)
296+
297+
#expect(!args.contains("-skipMacroValidation"))
298+
}
299+
267300
// MARK: - buildXcodebuildArgsForDevice Tests
268301

269302
@Test("buildXcodebuildArgsForDevice includes project path")
@@ -357,6 +390,35 @@ struct CommandHelpersTests {
357390
#expect(args.contains("/tmp/DerivedData"))
358391
}
359392

393+
@Test("buildXcodebuildArgsForDevice skips macro validation by default")
394+
func buildDeviceArgsSkipMacroValidationByDefault() {
395+
let projectPath = URL(fileURLWithPath: "/path/to/Client.xcodeproj")
396+
397+
let args = CommandHelpers.buildXcodebuildArgsForDevice(
398+
projectPath: projectPath,
399+
scheme: "Fennec",
400+
configuration: "Fennec",
401+
derivedDataPath: nil
402+
)
403+
404+
#expect(args.contains("-skipMacroValidation"))
405+
}
406+
407+
@Test("buildXcodebuildArgsForDevice can omit macro validation skip")
408+
func buildDeviceArgsCanOmitMacroValidationSkip() {
409+
let projectPath = URL(fileURLWithPath: "/path/to/Client.xcodeproj")
410+
411+
let args = CommandHelpers.buildXcodebuildArgsForDevice(
412+
projectPath: projectPath,
413+
scheme: "Fennec",
414+
configuration: "Fennec",
415+
derivedDataPath: nil,
416+
skipMacroValidation: false
417+
)
418+
419+
#expect(!args.contains("-skipMacroValidation"))
420+
}
421+
360422
// MARK: - ListSims Command Tests
361423

362424
@Test("ListSims command has correct configuration")

Tests/fxiosTests/RunTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ struct RunTests {
6767
#expect(command.derivedData == "/tmp/DD")
6868
}
6969

70+
@Test("Can parse doNotSkipMacroValidation flag")
71+
func parseDoNotSkipMacroValidation() throws {
72+
let command = try Run.parse(["--doNotSkipMacroValidation"])
73+
#expect(command.doNotSkipMacroValidation == true)
74+
#expect(command.skipMacroValidation == false)
75+
}
76+
7077
@Test("Can parse skip-resolve flag")
7178
func parseSkipResolve() throws {
7279
let command = try Run.parse(["--skip-resolve"])
@@ -105,6 +112,8 @@ struct RunTests {
105112
#expect(command.os == nil)
106113
#expect(command.configuration == nil)
107114
#expect(command.derivedData == nil)
115+
#expect(command.doNotSkipMacroValidation == false)
116+
#expect(command.skipMacroValidation == true)
108117
#expect(command.skipResolve == false)
109118
#expect(command.clean == false)
110119
#expect(command.quiet == false)

Tests/fxiosTests/TestTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ struct TestCommandTests {
224224
#expect(command.derivedData == "/tmp/DD")
225225
}
226226

227+
@Test("Can parse doNotSkipMacroValidation flag")
228+
func parseDoNotSkipMacroValidation() throws {
229+
let command = try Test.parse(["--doNotSkipMacroValidation"])
230+
#expect(command.doNotSkipMacroValidation == true)
231+
#expect(command.skipMacroValidation == false)
232+
}
233+
227234
@Test("Can parse retries option")
228235
func parseRetries() throws {
229236
let command = try Test.parse(["--retries", "3"])
@@ -258,6 +265,8 @@ struct TestCommandTests {
258265
#expect(command.os == nil)
259266
#expect(command.buildFirst == false)
260267
#expect(command.derivedData == nil)
268+
#expect(command.doNotSkipMacroValidation == false)
269+
#expect(command.skipMacroValidation == true)
261270
#expect(command.retries == 0)
262271
#expect(command.quiet == false)
263272
#expect(command.expose == false)

0 commit comments

Comments
 (0)