Skip to content

Commit 9bfe8f0

Browse files
committed
Run CodeGeneration tests in CI
With the migration of build-script.py to Swift, we accidentally dropped running the CodeGeneration tests. Re-enable them and fix two test failures.
1 parent a381b0d commit 9bfe8f0

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ class ValidateSyntaxNodes: XCTestCase {
515515
ValidationFailure(node: .differentiabilityArguments, message: "could conform to trait 'Parenthesized' but does not"),
516516
ValidationFailure(node: .editorPlaceholderDecl, message: "could conform to trait 'MissingNode' but does not"),
517517
ValidationFailure(node: .editorPlaceholderExpr, message: "could conform to trait 'MissingNode' but does not"),
518+
ValidationFailure(node: .editorPlaceholderPattern, message: "could conform to trait 'MissingNode' but does not"),
519+
ValidationFailure(node: .editorPlaceholderType, message: "could conform to trait 'MissingNode' but does not"),
518520
ValidationFailure(node: .enumCaseElement, message: "could conform to trait 'NamedDecl' but does not"),
519521
ValidationFailure(node: .genericParameter, message: "could conform to trait 'NamedDecl' but does not"),
520522
ValidationFailure(node: .precedenceGroupDecl, message: "could conform to trait 'Braced' but does not"),

SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Test.swift

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ struct Test: ParsableCommand, BuildCommand {
2424
var arguments: BuildArguments
2525

2626
func run() throws {
27-
try buildExample(exampleName: "ExamplePlugin")
28-
2927
try runTests()
28+
try runCodeGenerationTests()
3029

3130
logSection("All tests passed")
3231
}
@@ -71,6 +70,30 @@ struct Test: ParsableCommand, BuildCommand {
7170
)
7271
}
7372

73+
private func runCodeGenerationTests() throws {
74+
logSection("Running CodeGeneration Tests")
75+
var swiftpmCallArguments: [String] = []
76+
77+
if arguments.verbose {
78+
swiftpmCallArguments += ["--verbose"]
79+
}
80+
81+
let additionalEnvironment: [String: String] = [
82+
"SWIFT_BUILD_SCRIPT_ENVIRONMENT": "1",
83+
"SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION": "1",
84+
"SWIFTPARSER_ENABLE_ALTERNATE_TOKEN_INTROSPECTION": "1",
85+
]
86+
87+
try invokeSwiftPM(
88+
action: "test",
89+
packageDir: Paths.codeGenerationDir,
90+
additionalArguments: swiftpmCallArguments,
91+
additionalEnvironment: additionalEnvironment,
92+
captureStdout: false,
93+
captureStderr: false
94+
)
95+
}
96+
7497
private func findSwiftpmBinPath(packageDir: URL) throws -> String {
7598
return try invokeSwiftPM(
7699
action: "build",

SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/common/BuildCommand.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ extension BuildCommand {
2727
try build(packageDir: packageDir, name: targetName, isProduct: false)
2828
}
2929

30-
func buildExample(exampleName: String) throws {
31-
logSection("Building example " + exampleName)
32-
try build(packageDir: Paths.examplesDir, name: exampleName, isProduct: true)
33-
}
34-
3530
@discardableResult
3631
func invokeSwiftPM(
3732
action: String,

0 commit comments

Comments
 (0)