forked from swiftlang/swift-syntax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlit.cfg
91 lines (75 loc) · 3.19 KB
/
lit.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# ------- test/lit.cfg - Configuration for the 'lit' test runner -*- python -*-
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# -----------------------------------------------------------------------------
import lit
import platform
import tempfile
def inferSwiftBinaryImpl(binaryName, envVarName):
# If the user set the variable in the environment, definitely use that.
execPath = os.getenv(envVarName)
if execPath:
return execPath
# Otherwise, see if we were passed the path to the binary using a param.
execPath = lit_config.params.get(envVarName)
if execPath:
return execPath
# Find in the toolchain.
execPath = lit_config.params.get('TOOLCHAIN') + '/bin/' + binaryName
if os.path.exists(execPath):
return execPath
# Lastly, look in the path.
return lit.util.which(binaryName, config.environment["PATH"])
# Discover the Swift binaries to use.
def inferSwiftBinary(binaryName):
envVarName = binaryName.upper().replace("-", "_")
execPath = inferSwiftBinaryImpl(binaryName, envVarName)
if execPath:
if not lit_config.quiet:
lit_config.note("using %s: %s" % (binaryName, execPath))
else:
msg = "couldn't find '%s' program, try setting %s in your environment"
lit_config.warning(msg % (binaryName, envVarName))
# Just substitute the plain executable name, so the run line remains
# reasonable.
execPath = binaryName
return execPath
config.name = "SwiftSyntax"
config.suffixes = [".swift"]
config.test_format = lit.formats.ShTest(execute_external=True)
config.test_exec_root = tempfile.gettempdir()
config.examples_bin_path = lit_config.params.get("EXAMPLES_BIN_PATH")
config.filecheck = inferSwiftBinary("FileCheck")
config.incr_transfer_round_trip = inferSwiftBinary("incr_transfer_round_trip.py")
config.lit_test_helper = inferSwiftBinary("lit-test-helper")
config.swift = inferSwiftBinary("swift")
config.swiftc = inferSwiftBinary("swiftc")
config.swift_frontend = inferSwiftBinary("swift-frontend")
# Use features like this in lit:
# // REQUIRES: platform=<platform>
# where <platform> is Linux or Darwin
# Add a platform feature.
config.available_features.add("platform=" + platform.system())
config.substitutions.append(("%examples_bin_path", config.examples_bin_path))
config.substitutions.append(
("%empty-directory\(([^)]+)\)", 'rm -rf "\\1" && mkdir -p "\\1"')
)
config.substitutions.append(("%FileCheck", config.filecheck))
config.substitutions.append(
(
"%validate-incrparse",
"%s --temp-dir %%t --swiftsyntax-lit-test-helper %s"
% (config.incr_transfer_round_trip, config.lit_test_helper),
)
)
config.substitutions.append(("%lit-test-helper", config.lit_test_helper))
config.substitutions.append(("%swiftc", config.swiftc))
config.substitutions.append(("%swift", config.swift))
config.substitutions.append(("%swift-frontend", config.swift_frontend))