@@ -365,6 +365,8 @@ config.abi_symbol_checker = make_path(config.swift_utils, 'swift-abi-symbol-chec
365
365
config .link = lit .util .which ('link' , config .environment .get ('PATH' , '' )) or \
366
366
lit .util .which ('lld-link' , config .environment .get ('PATH' , '' ))
367
367
368
+ config .color_output = lit_config .params .get ('color_output' , None ) is not None
369
+
368
370
# Find the resource directory. Assume it's near the swift compiler if not set.
369
371
test_resource_dir = lit_config .params .get ('test_resource_dir' )
370
372
config .resource_dir_opt = ""
@@ -1953,6 +1955,10 @@ config.substitutions.append(('%cache-tool', config.swift_cache_tool))
1953
1955
config .target_swift_frontend += " -typo-correction-limit 10 "
1954
1956
subst_target_swift_frontend_mock_sdk += " -typo-correction-limit 10 "
1955
1957
1958
+ # Enable colors if we have them.
1959
+ if config .color_output :
1960
+ config .target_swift_frontend += " -color-diagnostics"
1961
+
1956
1962
config .substitutions .append (('%module-target-triple' ,
1957
1963
target_specific_module_triple ))
1958
1964
config .substitutions .append (('%module-target-future' , target_future ))
@@ -2728,7 +2734,7 @@ if hasattr(config, 'target_link_sdk_future_version'):
2728
2734
config .substitutions .append (('%target-link-sdk-future-version' ,
2729
2735
config .target_link_sdk_future_version ))
2730
2736
2731
- run_filecheck = '%s %s --allow-unused-prefixes --sanitize BUILD_DIR=%s --sanitize SOURCE_DIR=%s --use-filecheck %s %s' % (
2737
+ run_filecheck = '%s %s --allow-unused-prefixes --sanitize BUILD_DIR=%s --sanitize SOURCE_DIR=%s --use-filecheck %s %s %s ' % (
2732
2738
shell_quote (sys .executable ),
2733
2739
shell_quote (config .PathSanitizingFileCheck ),
2734
2740
# LLVM Lit performs realpath with the config path, so all paths are relative
@@ -2740,6 +2746,7 @@ run_filecheck = '%s %s --allow-unused-prefixes --sanitize BUILD_DIR=%s --sanitiz
2740
2746
shell_quote (lit .util .abs_path_preserve_drive (swift_obj_root ).replace ("\\ " , "/" )),
2741
2747
shell_quote (lit .util .abs_path_preserve_drive (config .swift_src_root ).replace ("\\ " , "/" )),
2742
2748
shell_quote (config .filecheck ),
2749
+ '--color' if config .color_output else '' ,
2743
2750
'--enable-windows-compatibility' if kIsWindows else '' )
2744
2751
2745
2752
config .substitutions .append (('%FileCheck' , run_filecheck ))
0 commit comments