Skip to content

Commit 7085322

Browse files
authored
Merge pull request #1835 from ahoppen/ahoppen/validation-failures
Run ValidateSyntaxNodes tests in CI
2 parents 93813f3 + edd3685 commit 7085322

File tree

2 files changed

+42
-33
lines changed

2 files changed

+42
-33
lines changed

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ class ValidateSyntaxNodes: XCTestCase {
183183
node: .conventionWitnessMethodAttributeArguments,
184184
message: "child 'WitnessMethodLabel' has a single keyword as its only token choice and should thus be named 'Witness_methodKeyword'"
185185
),
186+
ValidationFailure(
187+
node: .deinitEffectSpecifiers,
188+
message: "child 'AsyncSpecifier' has a single keyword as its only token choice and should thus be named 'AsyncKeyword'"
189+
),
186190
ValidationFailure(
187191
node: .derivativeRegistrationAttributeArguments,
188192
message: "child 'OfLabel' has a single keyword as its only token choice and should thus be named 'OfKeyword'"
@@ -199,10 +203,6 @@ class ValidateSyntaxNodes: XCTestCase {
199203
node: .genericParameter,
200204
message: "child 'Each' has a single keyword as its only token choice and should thus be named 'EachKeyword'"
201205
),
202-
ValidationFailure(
203-
node: .importDecl,
204-
message: "child 'ImportTok' has a single keyword as its only token choice and should thus be named 'ImportKeyword'"
205-
),
206206
ValidationFailure(node: .isExpr, message: "child 'IsTok' has a single keyword as its only token choice and should thus be named 'IsKeyword'"),
207207
ValidationFailure(
208208
node: .originallyDefinedInArguments,
@@ -243,9 +243,6 @@ class ValidateSyntaxNodes: XCTestCase {
243243
ValidationFailure(node: .unresolvedAsExpr, message: "child 'AsTok' has a single keyword as its only token choice and should thus be named 'AsKeyword'"),
244244
ValidationFailure(node: .unresolvedIsExpr, message: "child 'IsTok' has a single keyword as its only token choice and should thus be named 'IsKeyword'"),
245245

246-
// MARK:
247-
ValidationFailure(node: .arrayExpr, message: "child 'LeftSquare' has a token as its only token choice and should thus be named 'LeftSquareBracket'"),
248-
ValidationFailure(node: .arrayExpr, message: "child 'RightSquare' has a token as its only token choice and should thus be named 'RightSquareBracket'"),
249246
ValidationFailure(node: .arrowExpr, message: "child 'ArrowToken' has a token as its only token choice and should thus be named 'Arrow'"),
250247
ValidationFailure(node: .assignmentExpr, message: "child 'AssignToken' has a token as its only token choice and should thus be named 'Equal'"),
251248
ValidationFailure(node: .attribute, message: "child 'AtSignToken' has a token as its only token choice and should thus be named 'AtSign'"),
@@ -256,26 +253,10 @@ class ValidateSyntaxNodes: XCTestCase {
256253
message: "child 'OperatorToken' has a token as its only token choice and should thus be named 'BinaryOperator'"
257254
),
258255
ValidationFailure(node: .closureCaptureItem, message: "child 'AssignToken' has a token as its only token choice and should thus be named 'Equal'"),
259-
ValidationFailure(
260-
node: .closureCaptureSignature,
261-
message: "child 'LeftSquare' has a token as its only token choice and should thus be named 'LeftSquareBracket'"
262-
),
263-
ValidationFailure(
264-
node: .closureCaptureSignature,
265-
message: "child 'RightSquare' has a token as its only token choice and should thus be named 'RightSquareBracket'"
266-
),
267256
ValidationFailure(
268257
node: .designatedTypeElement,
269258
message: "child 'LeadingComma' has a comma keyword as its only token choice and should thus be named 'Comma' or 'TrailingComma'"
270259
),
271-
ValidationFailure(
272-
node: .dictionaryExpr,
273-
message: "child 'LeftSquare' has a token as its only token choice and should thus be named 'LeftSquareBracket'"
274-
),
275-
ValidationFailure(
276-
node: .dictionaryExpr,
277-
message: "child 'RightSquare' has a token as its only token choice and should thus be named 'RightSquareBracket'"
278-
),
279260
ValidationFailure(
280261
node: .differentiableAttributeArguments,
281262
message: "child 'DiffKindComma' has a comma keyword as its only token choice and should thus be named 'Comma' or 'TrailingComma'"
@@ -313,11 +294,11 @@ class ValidateSyntaxNodes: XCTestCase {
313294
ValidationFailure(node: .integerLiteralExpr, message: "child 'Digits' has a token as its only token choice and should thus be named 'IntegerLiteral'"),
314295
ValidationFailure(
315296
node: .keyPathSubscriptComponent,
316-
message: "child 'LeftBracket' has a token as its only token choice and should thus be named 'LeftSquareBracket'"
297+
message: "child 'LeftBracket' has a token as its only token choice and should thus be named 'LeftSquare'"
317298
),
318299
ValidationFailure(
319300
node: .keyPathSubscriptComponent,
320-
message: "child 'RightBracket' has a token as its only token choice and should thus be named 'RightSquareBracket'"
301+
message: "child 'RightBracket' has a token as its only token choice and should thus be named 'RightSquare'"
321302
),
322303
ValidationFailure(node: .labeledStmt, message: "child 'LabelColon' has a token as its only token choice and should thus be named 'Colon'"),
323304
ValidationFailure(node: .layoutRequirement, message: "child 'Size' has a token as its only token choice and should thus be named 'IntegerLiteral'"),
@@ -395,11 +376,11 @@ class ValidateSyntaxNodes: XCTestCase {
395376
ValidationFailure(node: .stringSegment, message: "child 'Content' has a token as its only token choice and should thus be named 'StringSegment'"),
396377
ValidationFailure(
397378
node: .subscriptExpr,
398-
message: "child 'LeftBracket' has a token as its only token choice and should thus be named 'LeftSquareBracket'"
379+
message: "child 'LeftBracket' has a token as its only token choice and should thus be named 'LeftSquare'"
399380
),
400381
ValidationFailure(
401382
node: .subscriptExpr,
402-
message: "child 'RightBracket' has a token as its only token choice and should thus be named 'RightSquareBracket'"
383+
message: "child 'RightBracket' has a token as its only token choice and should thus be named 'RightSquare'"
403384
),
404385
ValidationFailure(
405386
node: .suppressedType,
@@ -501,10 +482,6 @@ class ValidateSyntaxNodes: XCTestCase {
501482
node: .precedenceGroupAssociativity,
502483
message: "child 'Value' only has keywords as its token choices and should thus and with 'Keyword'"
503484
),
504-
ValidationFailure(
505-
node: .precedenceGroupRelation,
506-
message: "child 'HigherThanOrLowerThan' only has keywords as its token choices and should thus and with 'Keyword'"
507-
),
508485
]
509486
)
510487
}

build-script.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,29 @@ def check_generated_files_match(self_generated_dir: str,
283283
check_call(command)
284284

285285

286+
def run_code_generation_tests(
287+
toolchain: str,
288+
verbose: bool
289+
) -> None:
290+
print("** Running CodeGeneration tests **")
291+
292+
swift_exec = os.path.join(toolchain, "bin", "swift")
293+
294+
swiftpm_call = [
295+
swift_exec, 'test',
296+
"--package-path", CODE_GENERATION_DIR
297+
]
298+
299+
if verbose:
300+
swiftpm_call.extend(["--verbose"])
301+
302+
env = dict(os.environ)
303+
env["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] = "1"
304+
env["SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION"] = "1"
305+
env["SWIFTCI_USE_LOCAL_DEPS"] = "1"
306+
check_call(swiftpm_call, env=env, verbose=verbose)
307+
308+
286309
def run_tests(
287310
toolchain: str,
288311
build_dir: Optional[str],
@@ -306,6 +329,8 @@ def run_tests(
306329
)
307330

308331
run_xctests(
332+
package_dir=PACKAGE_DIR,
333+
test_product="swift-syntaxPackageTests",
309334
toolchain=toolchain,
310335
build_dir=build_dir,
311336
multiroot_data_file=multiroot_data_file,
@@ -315,6 +340,11 @@ def run_tests(
315340
verbose=verbose,
316341
)
317342

343+
run_code_generation_tests(
344+
toolchain=toolchain,
345+
verbose=verbose,
346+
)
347+
318348
# -----------------------------------------------------------------------------
319349
# Lit Tests
320350

@@ -398,6 +428,8 @@ def run_lit_tests(toolchain: str, build_dir: Optional[str], release: bool,
398428

399429

400430
def run_xctests(
431+
package_dir: str,
432+
test_product: str,
401433
toolchain: str,
402434
build_dir: Optional[str],
403435
multiroot_data_file: Optional[str],
@@ -410,7 +442,7 @@ def run_xctests(
410442
swiftpm_call = get_swiftpm_invocation(
411443
toolchain=toolchain,
412444
action="test",
413-
package_dir=PACKAGE_DIR,
445+
package_dir=package_dir,
414446
build_dir=build_dir,
415447
multiroot_data_file=multiroot_data_file,
416448
release=release,
@@ -419,7 +451,7 @@ def run_xctests(
419451
if verbose:
420452
swiftpm_call.extend(["--verbose"])
421453

422-
swiftpm_call.extend(["--test-product", "swift-syntaxPackageTests"])
454+
swiftpm_call.extend(["--test-product", test_product])
423455

424456
env = dict(os.environ)
425457
env["SWIFT_BUILD_SCRIPT_ENVIRONMENT"] = "1"

0 commit comments

Comments
 (0)