6
6
import subprocess
7
7
import sys
8
8
import tempfile
9
- from concurrent .futures import ThreadPoolExecutor
10
9
from typing import Dict , List , Optional
11
10
12
11
@@ -141,6 +140,7 @@ def run_code_generation(
141
140
142
141
env = dict (os .environ )
143
142
env ["SWIFT_BUILD_SCRIPT_ENVIRONMENT" ] = "1"
143
+ env ["SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION" ] = "1"
144
144
check_call (swiftpm_call , env = env , verbose = verbose )
145
145
146
146
@@ -174,6 +174,7 @@ class Builder(object):
174
174
build_dir : Optional [str ]
175
175
multiroot_data_file : Optional [str ]
176
176
release : bool
177
+ enable_rawsyntax_validation : bool
177
178
disable_sandbox : bool
178
179
179
180
def __init__ (
@@ -182,12 +183,14 @@ def __init__(
182
183
build_dir : Optional [str ],
183
184
multiroot_data_file : Optional [str ],
184
185
release : bool ,
186
+ enable_rawsyntax_validation : bool ,
185
187
verbose : bool ,
186
188
disable_sandbox : bool = False ,
187
189
) -> None :
188
190
self .build_dir = build_dir
189
191
self .multiroot_data_file = multiroot_data_file
190
192
self .release = release
193
+ self .enable_rawsyntax_validation = enable_rawsyntax_validation
191
194
self .disable_sandbox = disable_sandbox
192
195
self .verbose = verbose
193
196
self .toolchain = toolchain
@@ -221,6 +224,8 @@ def __build(self, package_dir: str, product_name: str) -> None:
221
224
222
225
env = dict (os .environ )
223
226
env ["SWIFT_BUILD_SCRIPT_ENVIRONMENT" ] = "1"
227
+ if self .enable_rawsyntax_validation :
228
+ env ["SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION" ] = "1"
224
229
# Tell other projects in the unified build to use local dependencies
225
230
env ["SWIFTCI_USE_LOCAL_DEPS" ] = "1"
226
231
env ["SWIFT_SYNTAX_PARSER_LIB_SEARCH_PATH" ] = \
@@ -274,7 +279,8 @@ def check_generated_files_match(self_generated_dir: str,
274
279
275
280
def run_tests (
276
281
toolchain : str , build_dir : Optional [str ], multiroot_data_file : Optional [str ],
277
- release : bool , filecheck_exec : Optional [str ], skip_lit_tests : bool , verbose : bool
282
+ release : bool , enable_rawsyntax_validation : bool , filecheck_exec : Optional [str ],
283
+ skip_lit_tests : bool , verbose : bool
278
284
) -> None :
279
285
print ("** Running SwiftSyntax Tests **" )
280
286
@@ -292,6 +298,7 @@ def run_tests(
292
298
build_dir = build_dir ,
293
299
multiroot_data_file = multiroot_data_file ,
294
300
release = release ,
301
+ enable_rawsyntax_validation = enable_rawsyntax_validation ,
295
302
verbose = verbose ,
296
303
)
297
304
@@ -396,6 +403,7 @@ def run_lit_tests(toolchain: str, build_dir: Optional[str], release: bool,
396
403
397
404
def run_xctests (toolchain : str , build_dir : Optional [str ],
398
405
multiroot_data_file : Optional [str ], release : bool ,
406
+ enable_rawsyntax_validation : bool ,
399
407
verbose : bool ) -> None :
400
408
print ("** Running XCTests **" )
401
409
swiftpm_call = get_swiftpm_invocation (
@@ -414,6 +422,8 @@ def run_xctests(toolchain: str, build_dir: Optional[str],
414
422
415
423
env = dict (os .environ )
416
424
env ["SWIFT_BUILD_SCRIPT_ENVIRONMENT" ] = "1"
425
+ if enable_rawsyntax_validation :
426
+ env ["SWIFTSYNTAX_ENABLE_RAWSYNTAX_VALIDATION" ] = "1"
417
427
# Tell other projects in the unified build to use local dependencies
418
428
env ["SWIFTCI_USE_LOCAL_DEPS" ] = "1"
419
429
env ["SWIFT_SYNTAX_PARSER_LIB_SEARCH_PATH" ] = \
@@ -461,10 +471,11 @@ def verify_source_code_command(args: argparse.Namespace) -> None:
461
471
def build_command (args : argparse .Namespace ) -> None :
462
472
try :
463
473
builder = Builder (
464
- toolchain = realpath (args .toolchain ),
474
+ toolchain = realpath (args .toolchain ), # pyright: ignore
465
475
build_dir = realpath (args .build_dir ),
466
476
multiroot_data_file = args .multiroot_data_file ,
467
477
release = args .release ,
478
+ enable_rawsyntax_validation = args .enable_rawsyntax_validation ,
468
479
verbose = args .verbose ,
469
480
disable_sandbox = args .disable_sandbox ,
470
481
)
@@ -484,10 +495,11 @@ def build_command(args: argparse.Namespace) -> None:
484
495
def test_command (args : argparse .Namespace ) -> None :
485
496
try :
486
497
builder = Builder (
487
- toolchain = realpath (args .toolchain ),
498
+ toolchain = realpath (args .toolchain ), # pyright: ignore
488
499
build_dir = realpath (args .build_dir ),
489
500
multiroot_data_file = args .multiroot_data_file ,
490
501
release = args .release ,
502
+ enable_rawsyntax_validation = args .enable_rawsyntax_validation ,
491
503
verbose = args .verbose ,
492
504
disable_sandbox = args .disable_sandbox ,
493
505
)
@@ -496,10 +508,11 @@ def test_command(args: argparse.Namespace) -> None:
496
508
builder .buildExample ("ExamplePlugin" )
497
509
498
510
run_tests (
499
- toolchain = realpath (args .toolchain ),
511
+ toolchain = realpath (args .toolchain ), # pyright: ignore
500
512
build_dir = realpath (args .build_dir ),
501
513
multiroot_data_file = args .multiroot_data_file ,
502
514
release = args .release ,
515
+ enable_rawsyntax_validation = args .enable_rawsyntax_validation ,
503
516
filecheck_exec = realpath (args .filecheck_exec ),
504
517
skip_lit_tests = args .skip_lit_tests ,
505
518
verbose = args .verbose ,
@@ -552,6 +565,16 @@ def add_default_build_arguments(parser: argparse.ArgumentParser) -> None:
552
565
""" ,
553
566
)
554
567
568
+ parser .add_argument (
569
+ "--enable-rawsyntax-validation" ,
570
+ action = "store_true" ,
571
+ help = """
572
+ When constructing RawSyntax nodes validate that their layout matches that
573
+ defined in `CodeGeneration` and that TokenSyntax nodes have a `tokenKind`
574
+ matching the ones specified in `CodeGeneration`.
575
+ """
576
+ )
577
+
555
578
parser .add_argument (
556
579
"--toolchain" ,
557
580
required = True ,
0 commit comments