Skip to content

Commit

Permalink
Setup travis and fixed some unit testing issues on Linux. Also remove…
Browse files Browse the repository at this point in the history
…d an obsolete file, causing the build to fail on Linux.
  • Loading branch information
dastrobu authored Apr 1, 2018
1 parent 89fe0cb commit a96f2de
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 36 deletions.
57 changes: 57 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# make sudo to enforce running on a real linux VM and not in a container on a macOS VM.
sudo: required
# do not use swift as language, since otherwise the build always runs on a macOS VM.
language: c
dist: trusty # Ubuntu 14.04 LTS
osx_image: xcode9.3beta

matrix:
include:
- os: linux
compiler: clang
# gcc currently it is not possible to compile with gcc
# - os: linux
# compiler: gcc
- os: osx
compiler: clang

before_install:
- uname -a
- |
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
# update silently
brew update >/dev/null
brew upgrade swiftlint
# check swift version
swift --version
fi
- |
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
sudo apt-get update
sudo apt-get install clang-3.6
export SWIFT_VERSION=4.1
# download swift
SWIFT_ARCHIVE=swift-$SWIFT_VERSION-RELEASE-ubuntu14.04.tar.gz
curl https://swift.org/builds/swift-$SWIFT_VERSION-release/ubuntu1404/swift-$SWIFT_VERSION-RELEASE/$SWIFT_ARCHIVE -s -o $SWIFT_ARCHIVE
tar xf $SWIFT_ARCHIVE
rm -f $SWIFT_ARCHIVE
# setup env for swift
export SWIFT_HOME=$(pwd)/swift-$SWIFT_VERSION-RELEASE-ubuntu14.04/usr/bin/
export PATH=$SWIFT_HOME:$PATH
# check swift version
swift --version
# fix linker issue: https://bugs.swift.org/browse/SR-2299
sudo ln -sf ld.gold /usr/bin/ld
fi
script:
- swift build
- swift test
- |
# lint on osx only (no need to do this on every platform)
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
swiftlint --reporter json > swiftlint.json
cat swiftlint.json
# check for warnings as well
grep "Warning" swiftlint.json > /dev/null && echo "linting failed" && exit 1;
echo "linting passed"
fi
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# geodesic

[![Swift Version](https://img.shields.io/badge/swift-4.1-blue.svg)](https://swift.org)
![Platform](https://img.shields.io/badge/platform-osx--64|linux--64-lightgrey.svg)
[![Build Travis-CI Status](https://travis-ci.org/dastrobu/geodesic.png?branch=master)](https://travis-ci.org/dastrobu/geodesic)

Solver for the inverse geodesic problem in Swift.

The inverse geodesic problem must be solved to compute the distance between two points on an oblate spheroid, or
Expand Down Expand Up @@ -46,4 +50,9 @@ is employed, but different parameters can be specified, e.g. for the
ellipsoid (a: 6378137.0, f: 1/298.257222100882711))


## Known Issues

* Compilation with gcc on Linux does not work. `swift build` fails.
No problems with clang on Linux.


32 changes: 0 additions & 32 deletions Sources/geographiclib/inverse.c

This file was deleted.

4 changes: 2 additions & 2 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import XCTest

import GeodesicTests
import geodesicTests

var tests = [XCTestCaseEntry]()
tests += GeodesicTests.allTests()
tests += geodesicTests.allTests()
XCTMain(tests)
7 changes: 5 additions & 2 deletions Tests/geodesicTests/geodesicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ final class GeodesicTests: XCTestCase {
XCTAssertEqual(distance(x, y), 111319.491, accuracy: delta)
}

#if !os(macOS)
static var allTests = [
("testShortcutForEqualPoints", testShortcutForEqualPoints),
("testPoles", testPoles),
("testDistance", testDistance),
("testGrs80", testGrs80),
("testPoles", testPoles),
("testShortcutForEqualPoints", testShortcutForEqualPoints),
]
#endif
}

0 comments on commit a96f2de

Please sign in to comment.