Skip to content

Commit

Permalink
Merge pull request #411 from madvay/systemTestsBeachHead
Browse files Browse the repository at this point in the history
Multi-project system test.
  • Loading branch information
advayDev1 committed Aug 26, 2015
2 parents 83d70c7 + e8a7f50 commit 1223b5c
Show file tree
Hide file tree
Showing 11 changed files with 281 additions and 2 deletions.
32 changes: 32 additions & 0 deletions systemTests/multiProject1/base/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2015 the authors of j2objc-gradle (see AUTHORS file)
*
* 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.
*/

apply plugin: 'java'
apply plugin: 'com.github.j2objccontrib.j2objcgradle'

repositories {
jcenter()
}

dependencies {
// Intentionally testing e2e use of a built-in j2objc library, Guava.
compile 'com.google.guava:guava:17.0'
testCompile 'junit:junit:4.12'
}

j2objcConfig {
finalConfigure()
}
37 changes: 37 additions & 0 deletions systemTests/multiProject1/base/src/main/java/com/example/Cube.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2015 the authors of j2objc-gradle (see AUTHORS file)
*
* 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.
*/

package com.example;

import com.google.common.base.Joiner;

public class Cube {

protected final int dimension;

public Cube(int dimension) {
this.dimension = dimension;
}

@Override
public String toString() {
return String.format("[Cube %d]", dimension);
}

public String exerciseGuava() {
return Joiner.on(' ').join('a', 'b', 'c');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2015 the authors of j2objc-gradle (see AUTHORS file)
*
* 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.
*/

package com.example;

import org.junit.Assert;
import org.junit.Test;

public class CubeTest {

@Test
public void testToString() {
Assert.assertEquals("[Cube 7]", new Cube(7).toString());
}

@Test
public void testExerciseGuava() {
Assert.assertEquals("a b c", new Cube(7).exerciseGuava());
}
}
36 changes: 36 additions & 0 deletions systemTests/multiProject1/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2015 the authors of j2objc-gradle (see AUTHORS file)
*
* 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.
*/

buildscript {
repositories {
jcenter()
}
dependencies {
// This is the build output of the plugin itself.
classpath fileTree(dir: '../../build/libs', include: ['*.jar'])
}
}

allprojects {
apply plugin: 'java'
test {
testLogging {
// Provide full exception info on failure, instead
// of just pointing to an HTML file.
exceptionFormat = 'full'
}
}
}
35 changes: 35 additions & 0 deletions systemTests/multiProject1/extended/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2015 the authors of j2objc-gradle (see AUTHORS file)
*
* 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.
*/

apply plugin: 'java'
apply plugin: 'com.github.j2objccontrib.j2objcgradle'

repositories {
jcenter()
}

dependencies {
compile project(':base')
// Intentionally testing e2e use of a built-in j2objc library, Guava.
compile 'com.google.guava:guava:17.0'
testCompile 'junit:junit:4.12'
}

j2objcConfig {
dependsOnJ2objcLib project(':base')

finalConfigure()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2015 the authors of j2objc-gradle (see AUTHORS file)
*
* 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.
*/

package com.example;

import java.lang.Override;

import com.google.common.base.Joiner;

public class ExtendedCube extends Cube {

public ExtendedCube(int dimension) {
super(dimension);
}

@Override
public String toString() {
return String.format("[ExtendedCube %d]", dimension);
}

@Override
public String exerciseGuava() {
return Joiner.on(';').join('a', 'b', 'c');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2015 the authors of j2objc-gradle (see AUTHORS file)
*
* 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.
*/

package com.example;

import org.junit.Assert;
import org.junit.Test;

public class ExtendedCubeTest {

@Test
public void testToString() {
Assert.assertEquals("[ExtendedCube 7]", new ExtendedCube(7).toString());
}

@Test
public void testExerciseGuava() {
Assert.assertEquals("a;b;c", new ExtendedCube(7).exerciseGuava());
}
}
1 change: 1 addition & 0 deletions systemTests/multiProject1/gradlew
1 change: 1 addition & 0 deletions systemTests/multiProject1/local.properties
16 changes: 16 additions & 0 deletions systemTests/multiProject1/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2015 the authors of j2objc-gradle (see AUTHORS file)
*
* 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.
*/
include ':base', ':extended'
21 changes: 19 additions & 2 deletions systemTests/run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,22 @@
# Fail if anything fails.
set -e

echo Running test simple1
pushd simple1 && ./gradlew wrapper && ./gradlew clean && ./gradlew build && popd
function runTest {
TEST_DIR=$1
echo Running test $TEST_DIR
set -e
pushd $TEST_DIR
./gradlew wrapper
./gradlew clean
./gradlew build
popd
}

# TODO: Might want to infer the directories that have build.gradle files in them.

# Simplest possible set-up. A single project with no dependencies.
runTest simple1

# Two gradle projects, `extended` depends on `base`. They also both test
# dependency on built-in j2objc libraries, like Guava.
runTest multiProject1

0 comments on commit 1223b5c

Please sign in to comment.