add tests
This commit is contained in:
parent
0fb0c771f0
commit
9312873f7d
|
@ -1 +1 @@
|
|||
DEVELOPMENT-SNAPSHOT-2016-04-12-a
|
||||
swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a
|
||||
|
|
25
.travis.yml
25
.travis.yml
|
@ -1,13 +1,24 @@
|
|||
notifications:
|
||||
slack: zewo:VjyVCCQvTOw9yrbzQysZezD1
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
- linux
|
||||
- osx
|
||||
language: generic
|
||||
sudo: required
|
||||
dist: trusty
|
||||
osx_image: xcode7.2
|
||||
osx_image: xcode7.3
|
||||
install:
|
||||
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/02090c7ede5a637b76e6df1710e83cd0bbe7dcdf/swiftenv-install.sh)"
|
||||
- bash ./setup_env.sh
|
||||
- eval "$(curl -sL https://raw.githubusercontent.com/Zewo/Zewo/5254525d9da56df29346fd76e99529c22034d61d/Scripts/install-swiftenv.sh)"
|
||||
- bash ./setup_env.sh
|
||||
script:
|
||||
- if [[ "$(uname)" == "Darwin" ]]; then swift build -Xcc -I/usr/local/include; else swift build -Xcc -I/usr/include; fi
|
||||
|
||||
- swift build --fetch # clones all dependencies
|
||||
- rm -rf Packages/*/Tests # deletes dependency's tests until duplicate Package.tests issue can be resolved in SPM. At that point, remove.
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
swift build -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib;
|
||||
swift build --configuration release -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib;
|
||||
fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
||||
swift build -Xlinker -rpath -Xlinker /usr/local/lib;
|
||||
swift build --configuration release -Xlinker -rpath -Xlinker /usr/local/lib;
|
||||
fi
|
||||
- swift test
|
||||
|
|
|
@ -2,8 +2,8 @@ import PackageDescription
|
|||
|
||||
let package = Package(
|
||||
name: "ZeroMQ",
|
||||
targets: [Target(name: "ZeroMQ", dependencies: ["CZeroMQ"])],
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/open-swift/C7.git", majorVersion: 0, minor: 5)
|
||||
.Package(url: "https://github.com/open-swift/C7.git", majorVersion: 0, minor: 5),
|
||||
.Package(url: "https://github.com/Zewo/CZeroMQ.git", majorVersion: 0, minor: 5),
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef zmw_swift_h
|
||||
#define zmw_swift_h
|
||||
|
||||
#include <zmq.h>
|
||||
|
||||
#endif
|
|
@ -1,5 +0,0 @@
|
|||
module CZeroMQ {
|
||||
header "czeromq.h"
|
||||
link "zmq"
|
||||
export *
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,10 @@
|
|||
#if os(Linux)
|
||||
|
||||
import XCTest
|
||||
@testable import ZeroMQTestSuite
|
||||
|
||||
XCTMain([
|
||||
testCase(ZeroMQTests.allTests)
|
||||
])
|
||||
|
||||
#endif
|
|
@ -1,52 +0,0 @@
|
|||
// ZMQTests.swift
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 Zewo
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
import XCTest
|
||||
import SwiftZMQ
|
||||
|
||||
class ZMQTests: XCTestCase {
|
||||
func testExample() {
|
||||
var called = false
|
||||
do {
|
||||
let context = try Context()
|
||||
|
||||
let inbound = try context.socket(.Pull)
|
||||
try inbound.bind("tcp://127.0.0.1:5555")
|
||||
|
||||
let outbound = try context.socket(.Push)
|
||||
try outbound.connect("tcp://127.0.0.1:5555")
|
||||
|
||||
try outbound.sendString("Hello World!")
|
||||
try outbound.sendString("Bye!")
|
||||
|
||||
while let data = try inbound.receiveString() where data != "Bye!" {
|
||||
called = true
|
||||
XCTAssert(data == "Hello World!")
|
||||
}
|
||||
} catch {
|
||||
XCTAssert(false)
|
||||
}
|
||||
XCTAssert(called)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
import XCTest
|
||||
@testable import ZeroMQ
|
||||
|
||||
class ZeroMQTests: XCTestCase {
|
||||
func testPushPull() {
|
||||
var called = false
|
||||
do {
|
||||
let context = try Context()
|
||||
|
||||
let inbound = try context.socket(.Pull)
|
||||
try inbound.bind("tcp://127.0.0.1:5555")
|
||||
|
||||
let outbound = try context.socket(.Push)
|
||||
try outbound.connect("tcp://127.0.0.1:5555")
|
||||
|
||||
try outbound.sendString("Hello World!")
|
||||
try outbound.sendString("Bye!")
|
||||
|
||||
while let data = try inbound.receiveString() where data != "Bye!" {
|
||||
called = true
|
||||
XCTAssert(data == "Hello World!")
|
||||
}
|
||||
} catch {
|
||||
XCTAssert(false)
|
||||
}
|
||||
XCTAssert(called)
|
||||
}
|
||||
}
|
||||
|
||||
extension ZeroMQTests {
|
||||
static var allTests: [(String, ZeroMQTests -> () throws -> Void)] {
|
||||
return [
|
||||
("testPushPull", testPushPull),
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,17 +1,15 @@
|
|||
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
brew update
|
||||
brew install zeromq --with-libsodium --HEAD
|
||||
else
|
||||
if [[ "$(uname)" == "Linux" ]]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential pkg-config
|
||||
cd /
|
||||
sudo curl -O http://download.zeromq.org/zeromq-4.1.4.tar.gz
|
||||
sudo tar xf /zeromq-4.1.4.tar.gz
|
||||
cd /zeromq-4.1.4
|
||||
sudo ./configure --without-libsodium
|
||||
sudo make
|
||||
sudo make install
|
||||
fi
|
||||
fi
|
||||
|
||||
cd /tmp/
|
||||
sudo curl -O http://download.zeromq.org/zeromq-4.1.4.tar.gz
|
||||
sudo tar xf /tmp/zeromq-4.1.4.tar.gz
|
||||
cd /tmp/zeromq-4.1.4
|
||||
sudo ./configure --without-libsodium
|
||||
sudo make
|
||||
sudo make install
|
Loading…
Reference in New Issue