Skip to content

Commit 12a8b11

Browse files
committed
Add test for blocks support
1 parent 751b73d commit 12a8b11

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

lit.cfg

+17-7
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,14 @@ if lit_config.params.get("have-network"):
120120

121121
# Get the package path.
122122
package_path = lit_config.params.get("package-path")
123+
if package_path is None:
124+
# If a package wasn't provided, use the current selected toolchain on Darwin.
125+
if platform.system() == "Darwin":
126+
package_path = os.path.abspath(
127+
os.path.join(subprocess.check_output(["xcrun", "--find", "swift"]).strip(), "../../../"))
123128
if package_path is None:
124129
lit_config.fatal("'--param package-path=PATH' is required")
125130
package_path = os.path.abspath(package_path)
126-
# if platform.system() == "Darwin":
127-
# package_path = os.path.join(package_path, "Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
128131
lit_config.note("testing package: %r" % (package_path,))
129132

130133
# Find the path to FileCheck. We just pick any one out of the build directory.
@@ -177,7 +180,10 @@ if not os.path.exists(swiftc_path):
177180
if not os.path.exists(filecheck_path):
178181
lit_config.fatal("filecheck does not exist!")
179182
if not os.path.exists(lldb_path):
180-
lit_config.fatal("lldb does not exist!")
183+
if platform.system() == "Darwin":
184+
lldb_path = subprocess.check_output(["xcrun", "--find", "lldb"]).strip()
185+
else:
186+
lit_config.fatal("lldb does not exist!")
181187

182188
# Define our supported substitutions.
183189
config.substitutions.append( ('%{not}', os.path.join(srcroot, "not")) )
@@ -186,13 +192,17 @@ config.substitutions.append( ('%{swift}', swift_path) )
186192
config.substitutions.append( ('%{swiftc}', swiftc_path) )
187193
config.substitutions.append( ('%{FileCheck}', filecheck_path) )
188194

189-
# Add a substitution for swiftpm build directory. This is useful for
190-
# running the integration tests locally, for e.g. by changing:
191-
# %{swift} build -> %{swiftpm_build}/swift-build
195+
# Add substitutions for swiftpm executables.
192196
swiftpm_build = lit_config.params.get("swiftpm-build")
193197
if swiftpm_build is not None:
194-
config.substitutions.append( ('%{swiftpm_build}', swiftpm_build) )
195198
lit_config.note("testing using swiftpm build directory: {}".format(swiftpm_build))
199+
config.substitutions.append( ('%{swift-build}', os.path.join(swiftpm_build, "swift-build")) )
200+
config.substitutions.append( ('%{swift-test}', os.path.join(swiftpm_build, "swift-test")) )
201+
config.substitutions.append( ('%{swift-run}', os.path.join(swiftpm_build, "swift-run")) )
202+
else:
203+
config.substitutions.append( ('%{swift-build}', swift_path + ' build') )
204+
config.substitutions.append( ('%{swift-test}', swift_path + ' test') )
205+
config.substitutions.append( ('%{swift-run}', swift_path + ' run') )
196206

197207
###
198208

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "see.h"
22

3+
int (^simpleBlock)(int) = ^(int a){
4+
return a+1;
5+
};
6+
37
int foo() {
4-
return 5;
8+
return simpleBlock(4);
59
}

test-complex-xctest-package/SwiftCMixed/Sources/swifty/swifty.swift

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import see
2+
import Dispatch
23

34
func swiftyFoo() -> Int {
45
return Int(foo())

test-complex-xctest-package/test-xctest-package.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: rm -rf %t.dir
55
// RUN: mkdir -p %t.dir
66
// RUN: cp -r %S/SwiftCMixed %t.dir/
7-
// RUN: %{swift} test --package-path %t.dir/SwiftCMixed -v 2>&1 | tee %t.build-log
7+
// RUN: %{swift-test} --package-path %t.dir/SwiftCMixed -v 2>&1 | tee %t.build-log
88
//
99
// Check the build log.
1010
//

0 commit comments

Comments
 (0)