Skip to content

Commit abb3a88

Browse files
authored
Merge pull request #99 from google/travis-dart
Update travis.yml, add all implementations
2 parents f131a35 + d849fac commit abb3a88

File tree

3 files changed

+85
-15
lines changed

3 files changed

+85
-15
lines changed

.travis.yml

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,83 @@
1+
# Travis CI configuration.
2+
# Each implementation is listed using the matrix:include configuration.
3+
4+
sudo: false
5+
dist: trusty
16
matrix:
27
include:
8+
# C++ implementation. Lives in cpp/, tested with bazel.
9+
- language: cpp
10+
env: OLC_PATH=cpp
11+
script:
12+
- wget -O install.sh "https://github.com/bazelbuild/bazel/releases/download/0.5.3/bazel-0.5.3-installer-linux-x86_64.sh"
13+
- chmod +x install.sh
14+
- ./install.sh --user && rm -f install.sh
15+
- ~/bin/bazel test --test_output=all ${OLC_PATH}:all
16+
17+
# Dart implementation. Lives in dart/
18+
- language: dart
19+
dart: stable
20+
env: OLC_PATH=dart
21+
script:
22+
- cd dart && pub get && pub run test
23+
24+
# Go implementation. Lives in go/
25+
- language: go
26+
go: stable
27+
env: OLC_PATH=go
28+
script:
29+
- go test ./go
30+
31+
# Java implementation. Lives in java/, tested with bazel.
32+
- language: java
33+
jdk: oraclejdk8
34+
env: OLC_PATH=java
35+
script:
36+
- wget -O install.sh "https://github.com/bazelbuild/bazel/releases/download/0.5.3/bazel-0.5.3-installer-linux-x86_64.sh"
37+
- chmod +x install.sh
38+
- ./install.sh --user && rm -f install.sh
39+
- ~/bin/bazel test --test_output=all ${OLC_PATH}:all
40+
41+
# Javascript Closure library implementation. Lives in js/closure, tested with bazel.
42+
# We use language "c" because bazel will install all the dependencies we need.
43+
- language: c
44+
env: OLC_PATH=js/closure
45+
script:
46+
- wget -O install.sh "https://github.com/bazelbuild/bazel/releases/download/0.5.3/bazel-0.5.3-installer-linux-x86_64.sh"
47+
- chmod +x install.sh
48+
- ./install.sh --user && rm -f install.sh
49+
- ~/bin/bazel test --test_output=all ${OLC_PATH}:all
50+
51+
# Javascript implementation. Lives in js/.
352
- language: node_js
453
node_js:
554
- "0.10"
55+
env: OLC_PATH=js
56+
script:
57+
- cd js && npm install && npm test
58+
59+
# Python implementation. Lives in python/, tested with bazel.
60+
- language: python
61+
python: 3.4
62+
env: OLC_PATH=python
63+
script:
64+
- wget -O install.sh "https://github.com/bazelbuild/bazel/releases/download/0.5.3/bazel-0.5.3-installer-linux-x86_64.sh"
65+
- chmod +x install.sh
66+
- ./install.sh --user && rm -f install.sh
67+
- ~/bin/bazel test --test_output=all ${OLC_PATH}:all
68+
69+
# Ruby implementation. Lives in ruby/
70+
- language: ruby
71+
rvm: 2.2
72+
env: OLC_PATH=ruby
73+
script:
74+
- gem install test-unit
75+
- cd ruby && ruby test/plus_codes_test.rb
76+
77+
# Rust implementation. Lives in rust/
678
- language: rust
79+
env: OLC_PATH=rust
780
script:
881
- cd rust/
982
- cargo build --verbose --all
1083
- cargo test --verbose --all
11-
12-
# Define the list of directories to execute tests in.
13-
env:
14-
- TEST_DIR=js
15-
- TEST_DIR=go
16-
- TEST_DIR=ruby
17-
- TEST_DIR=python
18-
- TEST_DIR=rust
19-
20-
# Test script to run. This is called once for each TEST_DIR value above.
21-
script: ./run_tests.sh

java/com/google/openlocationcode/tests/ShorteningTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@ private class TestData {
2323
private final double referenceLatitude;
2424
private final double referenceLongitude;
2525
private final String shortCode;
26+
private final String testType;
2627

2728
public TestData(String line) {
2829
String[] parts = line.split(",");
29-
if (parts.length != 4) {
30+
if (parts.length != 5) {
3031
throw new IllegalArgumentException("Wrong format of testing data.");
3132
}
3233
this.code = parts[0];
3334
this.referenceLatitude = Double.valueOf(parts[1]);
3435
this.referenceLongitude = Double.valueOf(parts[2]);
3536
this.shortCode = parts[3];
37+
this.testType = parts[4];
3638
}
3739
}
3840

@@ -55,6 +57,9 @@ public void setUp() throws Exception {
5557
@Test
5658
public void testShortening() {
5759
for (TestData testData : testDataList) {
60+
if (testData.testType != "B" && testData.testType != "S") {
61+
continue;
62+
}
5863
OpenLocationCode olc = new OpenLocationCode(testData.code);
5964
OpenLocationCode shortened =
6065
olc.shorten(testData.referenceLatitude, testData.referenceLongitude);
@@ -68,6 +73,9 @@ public void testShortening() {
6873
@Test
6974
public void testRecovering() {
7075
for (TestData testData : testDataList) {
76+
if (testData.testType != "B" && testData.testType != "R") {
77+
continue;
78+
}
7179
OpenLocationCode olc = new OpenLocationCode(testData.shortCode);
7280
OpenLocationCode recovered =
7381
olc.recover(testData.referenceLatitude, testData.referenceLongitude);

python/openlocationcode_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def setUp(self):
99
self.testdata = []
1010
headermap = {0: 'code', 1: 'isValid', 2: 'isShort', 3: 'isFull'}
1111
tests_fn = 'test_data/validityTests.csv'
12-
with open(tests_fn, "r") as fin:
12+
with open(tests_fn, 'r', encoding='utf-8') as fin:
1313
for line in fin:
1414
if line.startswith('#'):
1515
continue
@@ -38,7 +38,7 @@ def setUp(self):
3838
self.testdata = []
3939
headermap = {0: 'fullcode', 1: 'lat', 2: 'lng', 3: 'shortcode', 4:'testtype'}
4040
tests_fn = 'test_data/shortCodeTests.csv'
41-
with open(tests_fn, "r") as fin:
41+
with open(tests_fn, 'r', encoding='utf-8') as fin:
4242
for line in fin:
4343
if line.startswith('#'):
4444
continue
@@ -61,7 +61,7 @@ def setUp(self):
6161
self.testdata = []
6262
headermap = {0: 'code', 1: 'lat', 2: 'lng', 3: 'latLo', 4: 'lngLo', 5: 'latHi', 6: 'longHi'}
6363
tests_fn = 'test_data/encodingTests.csv'
64-
with open(tests_fn, "r") as fin:
64+
with open(tests_fn, 'r', encoding='utf-8') as fin:
6565
for line in fin:
6666
if line.startswith('#'):
6767
continue

0 commit comments

Comments
 (0)