Compare commits

...

5 commits

Author SHA1 Message Date
Emily Toop
69ffe90e21 Move iOS testing and document generation into post test jobs 2018-08-22 15:36:52 +01:00
Emily Toop
b34b854ca2 Address review comments 2018-08-22 12:57:01 +01:00
Emily Toop
2235f28bcd Add iOS SDK build and test to rust 1.25.0 version of travis CI build 2018-08-08 18:50:21 +01:00
Emily Toop
9c549e19d1 Fix broken iOS tests 2018-08-06 17:41:06 +01:00
Emily Toop
c0d28a0448 Get iOS tests building again. 2018-08-06 17:00:38 +01:00
4 changed files with 77 additions and 46 deletions

View file

@ -5,7 +5,7 @@ os: osx
before_install:
- brew install sqlcipher --with-fts
rust:
- 1.25.0 # Must align with `build/version.rs`.
- 1.25.0
- stable
- beta
- nightly
@ -13,6 +13,15 @@ matrix:
allow_failures:
- rust: nightly
fast_finish: true
jobs:
include:
- stage: "Test iOS"
rust: 1.25.0
script: ./scripts/install-ios.sh
script: ./scripts/test-ios.sh
- stage: "Docs"
rust: 1.25.0
script: ./scripts/cargo-doc.sh
script:
- cargo test --verbose --all
- cargo test --features edn/serde_support --verbose --all
@ -24,12 +33,4 @@ script:
for manifest in $(find . -type f -name Cargo.toml); do
cargo test --manifest-path $manifest --verbose --no-default-features --features sqlcipher
done
after_success:
- |
if [[ "$TRAVIS_PULL_REQUEST" = "false" && "$TRAVIS_BRANCH" == "master" ]]; then
cargo doc &&
echo "<meta http-equiv=refresh content=0;url=mentat/index.html>" > target/doc/index.html &&
git clone https://github.com/davisp/ghp-import.git &&
./ghp-import/ghp_import.py -n -p -f -r https://"$GH_TOKEN"@github.com/"$TRAVIS_REPO_SLUG.git" target/doc
fi
cache: cargo

8
scripts/cargo-doc.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
if [[ "$TRAVIS_PULL_REQUEST" = "false" && "$TRAVIS_BRANCH" == "master" ]]; then
cargo doc &&
echo "<meta http-equiv=refresh content=0;url=mentat/index.html>" > target/doc/index.html &&
git clone https://github.com/davisp/ghp-import.git &&
./ghp-import/ghp_import.py -n -p -f -r https://"$GH_TOKEN"@github.com/"$TRAVIS_REPO_SLUG.git" target/doc
fi

23
scripts/test-ios.sh Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
# Install iOS targets with Rustup. We need to install all targets as we are building a universal library.
rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios
# The version of cargo-lipo in Crates.io doesn't contain any support for Cargo manifests in subdirectories and the build fail.
# We therefore need to use a Beta version that contains the right code.
cargo install --git https://github.com/TimNN/cargo-lipo --rev d347567ff337ee169ba46a624229a451dd6f6067
# If we don't list the devices available then, when we come to pick one during the test run, Travis doesn't
# think that there are any devices available and the build fails.
# TODO: See if there is a less time consuming way of doing this.
# instruments -s devices
# Build Mentat as a universal iOS library.
pushd ffi
cargo lipo --release
popd
# Run the iOS SDK tests using xcodebuild.
pushd sdks/swift/Mentat
xcodebuild -configuration Debug -scheme "Mentat Debug" -sdk iphonesimulator test -destination 'platform=iOS Simulator,name=iPhone X,OS=11.4'
popd

View file

@ -30,15 +30,14 @@ class MentatTests: XCTestCase {
// test that a store can be opened in memory
func testOpenInMemoryStore() {
XCTAssertNotNil(Mentat().raw)
XCTAssertNotNil(try Mentat.open().raw)
}
// test that a store can be opened in a specific location
func testOpenStoreInLocation() {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let documentsURL = paths[0]
let storeURI = documentsURL.appendingPathComponent("test.db", isDirectory: false).absoluteString
XCTAssertNotNil(Mentat(storeURI: storeURI).raw)
let documentsURL = NSURL(fileURLWithPath: NSTemporaryDirectory())
let storeURI = documentsURL.appendingPathComponent("test.db", isDirectory: false)!.absoluteString
XCTAssertNotNil(try Mentat.open(storeURI: storeURI).raw)
}
func readFile(forResource resource: String, withExtension ext: String, subdirectory: String ) throws -> String {
@ -80,7 +79,7 @@ class MentatTests: XCTestCase {
func openAndInitializeCitiesStore() -> Mentat {
guard let mentat = self.store else {
let mentat = Mentat()
let mentat = try! Mentat.open()
let _ = try! self.transactCitiesSchema(mentat: mentat)
let _ = try! self.transactSeattleData(mentat: mentat)
self.store = mentat
@ -154,7 +153,7 @@ class MentatTests: XCTestCase {
func test1TransactVocabulary() {
do {
let mentat = Mentat()
let mentat = try Mentat.open()
let vocab = try readCitiesSchema()
let report = try mentat.transact(transaction: vocab)
XCTAssertNotNil(report)
@ -166,7 +165,7 @@ class MentatTests: XCTestCase {
func test2TransactEntities() {
do {
let mentat = Mentat()
let mentat = try Mentat.open()
let vocab = try readCitiesSchema()
let _ = try mentat.transact(transaction: vocab)
let data = try readSeattleData()
@ -338,7 +337,7 @@ class MentatTests: XCTestCase {
}
func testBindLong() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?long :where [?e :foo/long ?long]]"
@ -358,7 +357,7 @@ class MentatTests: XCTestCase {
}
func testBindRef() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let stringEntid = mentat.entidForAttribute(attribute: ":foo/string")
let bEntid = report!.entid(forTempId: "b")
@ -379,7 +378,7 @@ class MentatTests: XCTestCase {
}
func testBindKwRef() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = report!.entid(forTempId: "b")
let query = "[:find ?e . :in ?ref :where [?e :foo/ref ?ref]]"
@ -399,7 +398,7 @@ class MentatTests: XCTestCase {
}
func testBindKw() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?kw :where [?e :foo/keyword ?kw]]"
@ -419,7 +418,7 @@ class MentatTests: XCTestCase {
}
func testBindDate() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")
let query = "[:find [?e ?d] :in ?now :where [?e :foo/instant ?d] [(< ?d ?now)]]"
@ -465,7 +464,7 @@ class MentatTests: XCTestCase {
}
func testBindUuid() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?uuid :where [?e :foo/uuid ?uuid]]"
@ -486,7 +485,7 @@ class MentatTests: XCTestCase {
}
func testBindBoolean() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?bool :where [?e :foo/boolean ?bool]]"
@ -506,7 +505,7 @@ class MentatTests: XCTestCase {
}
func testBindDouble() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?double :where [?e :foo/double ?double]]"
@ -526,7 +525,7 @@ class MentatTests: XCTestCase {
}
func testTypedValueAsLong() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/long ?v]]"
@ -547,7 +546,7 @@ class MentatTests: XCTestCase {
}
func testTypedValueAsRef() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?e . :where [?e :foo/long 25]]"
@ -567,7 +566,7 @@ class MentatTests: XCTestCase {
}
func testTypedValueAsKw() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/keyword ?v]]"
@ -588,7 +587,7 @@ class MentatTests: XCTestCase {
}
func testTypedValueAsBoolean() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/boolean ?v]]"
@ -609,7 +608,7 @@ class MentatTests: XCTestCase {
}
func testTypedValueAsDouble() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/double ?v]]"
@ -630,7 +629,7 @@ class MentatTests: XCTestCase {
}
func testTypedValueAsDate() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/instant ?v]]"
@ -656,7 +655,7 @@ class MentatTests: XCTestCase {
}
func testTypedValueAsString() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/string ?v]]"
@ -677,7 +676,7 @@ class MentatTests: XCTestCase {
}
func testTypedValueAsUuid() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/uuid ?v]]"
@ -699,7 +698,7 @@ class MentatTests: XCTestCase {
}
func testValueForAttributeOfEntity() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")!
var value: TypedValue? = nil;
@ -709,14 +708,14 @@ class MentatTests: XCTestCase {
}
func testEntidForAttribute() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let _ = self.populateWithTypesSchema(mentat: mentat)
let entid = mentat.entidForAttribute(attribute: ":foo/long")
assert(entid == 65540)
}
func testMultipleQueries() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let _ = self.populateWithTypesSchema(mentat: mentat)
let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]")
@ -741,7 +740,7 @@ class MentatTests: XCTestCase {
}
func testNestedQueries() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let _ = self.populateWithTypesSchema(mentat: mentat)
let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]")
let q2 = mentat.query(query: "[:find ?x :where [_ _ ?x]]")
@ -763,13 +762,13 @@ class MentatTests: XCTestCase {
}
func test3InProgressTransact() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
XCTAssertNotNil(report)
}
func testInProgressRollback() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat)
XCTAssertNotNil(report)
let aEntid = report!.entid(forTempId: "a")!
@ -787,7 +786,7 @@ class MentatTests: XCTestCase {
}
func testInProgressEntityBuilder() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = dataReport!.entid(forTempId: "b")!
let longEntid = schemaReport!.entid(forTempId: "l")!
@ -852,7 +851,7 @@ class MentatTests: XCTestCase {
}
func testEntityBuilderForEntid() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = dataReport!.entid(forTempId: "b")!
let longEntid = schemaReport!.entid(forTempId: "l")!
@ -917,7 +916,7 @@ class MentatTests: XCTestCase {
}
func testEntityBuilderForTempid() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (schemaReport, _) = self.populateWithTypesSchema(mentat: mentat)
let longEntid = schemaReport!.entid(forTempId: "l")!
// test that the values are as expected
@ -964,7 +963,7 @@ class MentatTests: XCTestCase {
}
func testInProgressBuilderTransact() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = dataReport!.entid(forTempId: "a")!
let bEntid = dataReport!.entid(forTempId: "b")!
@ -1020,7 +1019,7 @@ class MentatTests: XCTestCase {
}
func testEntityBuilderTransact() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = dataReport!.entid(forTempId: "a")!
let bEntid = dataReport!.entid(forTempId: "b")!
@ -1076,7 +1075,7 @@ class MentatTests: XCTestCase {
}
func testEntityBuilderRetract() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = dataReport!.entid(forTempId: "b")!
let stringEntid = schemaReport!.entid(forTempId: "s")!
@ -1126,7 +1125,7 @@ class MentatTests: XCTestCase {
}
func testInProgressEntityBuilderRetract() {
let mentat = Mentat()
let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = dataReport!.entid(forTempId: "b")!
let stringEntid = schemaReport!.entid(forTempId: "s")!