Commit 485b0e4d authored by Drew's avatar Drew

Swift snapshot swift-DEVELOPMENT-SNAPSHOT-2016-03-16-a

parent 7b32452f
......@@ -33,14 +33,14 @@ var focusOnTask : String? = nil
//build overlays
var overlays : [String] = []
for (i, x) in Process.arguments.enumerate() {
for (i, x) in Process.arguments.enumerated() {
if x == Options.Overlay.rawValue {
let overlay = Process.arguments[i+1]
overlays.append(overlay)
}
}
var packageFile = defaultPackageFile
for (i, x) in Process.arguments.enumerate() {
for (i, x) in Process.arguments.enumerated() {
if x == Options.CustomFile.rawValue {
packageFile = Process.arguments[i+1]
}
......
Subproject commit 80e104244c8f04a249b06c9a1836b84c5fe58915
Subproject commit 428e6672a21560013978638cf6eb0d4c572b84e7
......@@ -38,7 +38,7 @@ extension NSString {
// MARK: NSFileManager.copyItemAtPath
// https://github.com/apple/swift-corelibs-foundation/pull/248
enum CopyError: ErrorType {
enum CopyError: ErrorProtocol {
case CantOpenSourceFile(Int32)
case CantOpenDestFile(Int32)
case CantReadSourceFile(Int32)
......@@ -53,7 +53,7 @@ extension NSFileManager {
throw CopyError.CantOpenSourceFile(errno)
}
defer { precondition(close(fd_from) >= 0) }
let permission_ = (try! attributesOfItemAtPath(srcPath)[NSFilePosixPermissions] as! NSNumber)
let permission_ = (try! attributesOfItem(atPath: srcPath)[NSFilePosixPermissions] as! NSNumber)
#if os(OSX) || os(iOS)
let permission = permission_.unsignedShortValue
......@@ -66,7 +66,7 @@ extension NSFileManager {
}
defer { precondition(close(fd_to) >= 0) }
var buf = [UInt8](count: 4096, repeatedValue: 0)
var buf = [UInt8](repeating: 0, count: 4096)
while true {
let nread = read(fd_from, &buf, buf.count)
......@@ -82,9 +82,39 @@ extension NSFileManager {
if nwritten < 0 {
throw CopyError.CantWriteDestFile(errno)
}
writeSlice = writeSlice[writeSlice.startIndex.advancedBy(nwritten)..<writeSlice.endIndex]
writeSlice = writeSlice[writeSlice.startIndex.advanced(by: nwritten)..<writeSlice.endIndex]
if writeSlice.count == 0 { break }
}
}
}
}
\ No newline at end of file
}
//These parts of Swift 3 Renaming are not yet implemented on Linux
#if os(Linux)
extension NSFileManager {
func enumerator(atPath path: String) -> NSDirectoryEnumerator? {
return self.enumeratorAtPath(path)
}
func createDirectory(atPath path: String, withIntermediateDirectories createIntermediates: Bool, attributes: [String : AnyObject]? = [:]) throws {
return try self.createDirectoryAtPath(path, withIntermediateDirectories: createIntermediates, attributes: attributes)
}
func attributesOfItem(atPath path: String) throws -> [String : Any] {
return try self.attributesOfItemAtPath(path)
}
func removeItem(atPath path: String) throws {
return try self.removeItemAtPath(path)
}
func fileExists(atPath path: String) -> Bool {
return self.fileExistsAtPath(path)
}
}
extension String {
func componentsSeparated(by separator: String) -> [String] {
return self.componentsSeparatedByString(separator)
}
func write(toFile path: String, atomically useAuxiliaryFile:Bool, encoding enc: NSStringEncoding) throws {
return try self.writeToFile(path, atomically: useAuxiliaryFile, encoding: enc)
}
}
#endif
\ No newline at end of file
......@@ -48,8 +48,8 @@ func userPath() -> String {
let manager = NSFileManager.defaultManager()
let userPath = manager.currentDirectoryPath + "/user"
if !userPathCreated {
let _ = try? manager.removeItemAtPath(userPath)
try! manager.createDirectoryAtPath(userPath, withIntermediateDirectories: false, attributes: nil)
let _ = try? manager.removeItem(atPath: userPath)
try! manager.createDirectory(atPath: userPath, withIntermediateDirectories: false, attributes: nil)
userPathCreated = true
}
return userPath
......
......@@ -25,13 +25,13 @@ class XCTestRun : Tool {
}
#if os(OSX)
var workingDirectory = "/tmp/XXXXXXXXXXX"
var template = workingDirectory.cStringUsingEncoding(NSUTF8StringEncoding)!
workingDirectory = String(CString: mkdtemp(&template), encoding: NSUTF8StringEncoding)!
var template = workingDirectory.cString(usingEncoding: NSUTF8StringEncoding)!
workingDirectory = String(cString: mkdtemp(&template), encoding: NSUTF8StringEncoding)!
let manager = NSFileManager.defaultManager()
let executablePath = workingDirectory + "/XCTestRun.xctest/Contents/MacOS"
try! manager.createDirectoryAtPath(executablePath, withIntermediateDirectories: true, attributes: nil)
try! manager.copyItemAtPath(testExecutable, toPath: executablePath + "/XCTestRun")
try! manager.createDirectory(atPath: executablePath, withIntermediateDirectories: true, attributes: nil)
try! manager.copyItem(atPath: testExecutable, toPath: executablePath + "/XCTestRun")
var s = ""
s += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
s += "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
......@@ -61,7 +61,7 @@ class XCTestRun : Tool {
s += "<string>1</string>\n"
s += "</dict>\n"
s += "</plist>\n"
try! s.writeToFile(workingDirectory + "/XCTestRun.xctest/Contents/Info.plist", atomically: false, encoding: NSUTF8StringEncoding)
try! s.write(toFile: workingDirectory + "/XCTestRun.xctest/Contents/Info.plist", atomically: false, encoding: NSUTF8StringEncoding)
if system("xcrun xctest \(workingDirectory)/XCTestRun.xctest") != 0 {
fatalError("Test execution failed.")
}
......
This diff is collapsed.
......@@ -7,13 +7,13 @@ class MyTest : XCTestCase {
}
}
extension MyTest : XCTestCaseProvider {
var allTests : [(String, () throws -> Void)] {
return [
("testLoad", testLoad)
]
}
extension MyTest {
static var allTests : [(String, MyTest -> () throws -> Void)] {
return [
("testLoad", testLoad)
]
}
}
XCTMain([MyTest()])
XCTMain([testCase(MyTest.allTests)])
......@@ -20,8 +20,8 @@ class FooTests: XCTestCase {
}
}
extension FooTests: XCTestCaseProvider {
var allTests : [(String, () throws -> Void)] {
extension FooTests {
static var allTests : [(String, FooTests -> () throws -> Void)] {
return [
("testFoo", testFoo)
]
......
......@@ -13,4 +13,4 @@
// limitations under the License.
import XCTest
XCTMain([FooTests()])
\ No newline at end of file
XCTMain([testCase(FooTests.allTests)])
\ No newline at end of file
......@@ -20,8 +20,8 @@ class FooTests: XCTestCase {
}
}
extension FooTests: XCTestCaseProvider {
var allTests : [(String, () throws -> Void)] {
extension FooTests {
static var allTests : [(String, FooTests -> () throws -> Void)] {
return [
//("testFoo", testFoo) oops! Forgot this one!
]
......
......@@ -13,4 +13,4 @@
// limitations under the License.
import XCTest
XCTMain([FooTests()])
\ No newline at end of file
XCTMain([testCase(FooTests())])
\ No newline at end of file
(package
:name "xcs"
:tasks {
:build-lib {
:tool "atllbuild"
:sources ["src/**.swift"]
:output-type "static-library"
:name "Foo"
:compile-options ["-enable-testing"]
}
:build-tests {
:tool "atllbuild"
:sources ["test/**.swift"]
:output-type "executable"
:name "footests"
:dependencies ["build-lib"]
:xctestify true
:xctest-strict true
:link-with ["Foo.a"]
}
:run-tests {
:tool "xctestrun"
:test-executable ".atllbuild/products/footests"
:dependencies ["build-tests"]
}
}
)
\ No newline at end of file
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
class Foo {
func whatever() -> Int {
return 12
}
}
\ No newline at end of file
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
@testable import Foo
import XCTest
class FooTests: XCTestCase {
func testFoo() {
XCTAssert(Foo().whatever() == 12)
}
}
\ No newline at end of file
// Copyright (c) 2016 Anarchy Tools Contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import XCTest
XCTMain([FooTests()])
\ No newline at end of file
......@@ -128,14 +128,6 @@ else
else
echo "Strict failed as expected"
fi
cd $DIR/tests/fixtures/xcs_strict_2
if $ATBUILD run-tests; then
echo "Expected a failure in xcs_strict"
exit 1
else
echo "Strict failed as expected"
fi
fi
echo "*****************OVERLAY CHECKS**********************"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment