Merge pull request #25 from aciidb0mb3r/elim-need-for-pkg

Add test for blocks support
diff --git a/lit.cfg b/lit.cfg
index 5c2c512..4851623 100644
--- a/lit.cfg
+++ b/lit.cfg
@@ -121,10 +121,13 @@
 # Get the package path.
 package_path = lit_config.params.get("package-path")
 if package_path is None:
+    # If a package wasn't provided, use the current selected toolchain on Darwin.
+    if platform.system() == "Darwin":
+        package_path = os.path.abspath(
+            os.path.join(subprocess.check_output(["xcrun", "--find", "swift"]).strip(), "../../../"))
+if package_path is None:
     lit_config.fatal("'--param package-path=PATH' is required")
 package_path = os.path.abspath(package_path)
-# if platform.system() == "Darwin":
-#     package_path = os.path.join(package_path, "Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain")
 lit_config.note("testing package: %r" % (package_path,))
 
 # Find the path to FileCheck. We just pick any one out of the build directory.
@@ -177,7 +180,10 @@
 if not os.path.exists(filecheck_path):
     lit_config.fatal("filecheck does not exist!")
 if not os.path.exists(lldb_path):
-    lit_config.fatal("lldb does not exist!")
+    if platform.system() == "Darwin":
+        lldb_path = subprocess.check_output(["xcrun", "--find", "lldb"]).strip()
+    else:
+        lit_config.fatal("lldb does not exist!")
 
 # Define our supported substitutions.
 config.substitutions.append( ('%{not}', os.path.join(srcroot, "not")) )
@@ -186,13 +192,17 @@
 config.substitutions.append( ('%{swiftc}', swiftc_path) )
 config.substitutions.append( ('%{FileCheck}', filecheck_path) )
 
-# Add a substitution for swiftpm build directory. This is useful for
-# running the integration tests locally, for e.g. by changing:
-# %{swift} build -> %{swiftpm_build}/swift-build
+# Add substitutions for swiftpm executables.
 swiftpm_build = lit_config.params.get("swiftpm-build")
 if swiftpm_build is not None:
-    config.substitutions.append( ('%{swiftpm_build}', swiftpm_build) )
     lit_config.note("testing using swiftpm build directory: {}".format(swiftpm_build))
+    config.substitutions.append( ('%{swift-build}',  os.path.join(swiftpm_build, "swift-build")) )
+    config.substitutions.append( ('%{swift-test}',  os.path.join(swiftpm_build, "swift-test")) )
+    config.substitutions.append( ('%{swift-run}',  os.path.join(swiftpm_build, "swift-run")) )
+else:
+    config.substitutions.append( ('%{swift-build}', swift_path + ' build') )
+    config.substitutions.append( ('%{swift-test}', swift_path + ' test') )
+    config.substitutions.append( ('%{swift-run}', swift_path + ' run') )
 
 ###
 
diff --git a/test-complex-xctest-package/SwiftCMixed/Sources/see/see.c b/test-complex-xctest-package/SwiftCMixed/Sources/see/see.c
index 56a6706..29dfbda 100644
--- a/test-complex-xctest-package/SwiftCMixed/Sources/see/see.c
+++ b/test-complex-xctest-package/SwiftCMixed/Sources/see/see.c
@@ -1,5 +1,9 @@
 #include "see.h"
 
+int (^simpleBlock)(int) = ^(int a){
+    return a+1;
+};
+
 int foo() {
-    return 5;
+    return simpleBlock(4);
 }
diff --git a/test-complex-xctest-package/SwiftCMixed/Sources/swifty/swifty.swift b/test-complex-xctest-package/SwiftCMixed/Sources/swifty/swifty.swift
index 8abf1ec..c5ff442 100644
--- a/test-complex-xctest-package/SwiftCMixed/Sources/swifty/swifty.swift
+++ b/test-complex-xctest-package/SwiftCMixed/Sources/swifty/swifty.swift
@@ -1,4 +1,5 @@
 import see
+import Dispatch
 
 func swiftyFoo() -> Int {
     return Int(foo())
diff --git a/test-complex-xctest-package/test-xctest-package.txt b/test-complex-xctest-package/test-xctest-package.txt
index 006acf3..c050f86 100644
--- a/test-complex-xctest-package/test-xctest-package.txt
+++ b/test-complex-xctest-package/test-xctest-package.txt
@@ -4,7 +4,7 @@
 // RUN: rm -rf %t.dir
 // RUN: mkdir -p %t.dir
 // RUN: cp -r %S/SwiftCMixed %t.dir/
-// RUN: %{swift} test --package-path %t.dir/SwiftCMixed -v 2>&1 | tee %t.build-log
+// RUN: %{swift-test} --package-path %t.dir/SwiftCMixed -v 2>&1 | tee %t.build-log
 //
 // Check the build log.
 //