Skip to content

Commit

Permalink
Move library unit tests into their own module.
Browse files Browse the repository at this point in the history
Along with disabling error prone for unit tests,
cuts build time by ~20s down to ~1min 40s.
  • Loading branch information
sjudd committed Jan 7, 2018
1 parent 3af80f4 commit 95637cf
Show file tree
Hide file tree
Showing 168 changed files with 120 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
[submodule "library/src/androidTest/resources/exif-orientation-examples"]
path = library/src/androidTest/resources/exif-orientation-examples
url = https://github.com/recurser/exif-orientation-examples.git
[submodule "library/src/test/resources/exif-orientation-examples"]
path = library/src/test/resources/exif-orientation-examples
[submodule "library/test/src/test/resources/exif-orientation-examples"]
path = library/test/src/test/resources/exif-orientation-examples
url = https://github.com/recurser/exif-orientation-examples
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ if (JavaVersion.current().isJava8Compatible()) {

subprojects { project ->
tasks.withType(JavaCompile) {
options.fork = true
sourceCompatibility = 1.7
targetCompatibility = 1.7

Expand Down
2 changes: 1 addition & 1 deletion checkstyle_suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<suppress files=".*[/\\]library[/\\]src[/\\]test[/\\].*" checks="Javadoc.*"/>
<suppress files=".*[/\\]library[/\\]test[/\\]src[/\\]test[/\\].*" checks="Javadoc.*"/>
<suppress files=".*[/\\]annotation[/\\]compiler[/\\]test[/\\]src[/\\]test[/\\]resources[/\\].*" checks=".*"/>
<suppress files=".*[/\\]instrumentation[/\\]src[/\\].*" checks="Javadoc.*"/>
<suppress files=".*[/\\]instrumentation[/\\]src[/\\]androidTest[/\\].*" checks="Javadoc.*"/>
Expand Down
33 changes: 5 additions & 28 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,29 @@ if (!hasProperty('DISABLE_ERROR_PRONE')) {
apply plugin: "net.ltgt.errorprone"
}

tasks.withType(JavaCompile) {
options.fork = true
}

dependencies {
api project(':third_party:gif_decoder')
api project(':third_party:disklrucache')
api project(':annotation')
api "com.android.support:support-fragment:${ANDROID_SUPPORT_VERSION}"
compileOnly "com.android.support:appcompat-v7:${ANDROID_SUPPORT_VERSION}"
testImplementation project(':testutil')
testImplementation 'com.google.guava:guava-testlib:18.0'
testImplementation "com.google.truth:truth:${TRUTH_VERSION}"
testImplementation "junit:junit:${JUNIT_VERSION}"
testImplementation "org.mockito:mockito-core:${MOCKITO_VERSION}"
testImplementation "org.robolectric:robolectric:${ROBOLECTRIC_VERSION}"
testImplementation "com.squareup.okhttp3:mockwebserver:${MOCKWEBSERVER_VERSION}"
testImplementation "com.android.support:support-v4:${ANDROID_SUPPORT_VERSION}"

if (project.plugins.hasPlugin('net.ltgt.errorprone')) {
errorprone "com.google.errorprone:error_prone_core:${ERROR_PRONE_VERSION}"
}
}

android.testOptions.unitTests.all { Test testTask ->
// configure max heap size of the test JVM
testTask.maxHeapSize = TEST_JVM_MEMORY_SIZE as String
if (JavaVersion.current() <= JavaVersion.VERSION_1_7) {
// Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=2048m; support was removed in 8.0
testTask.jvmArgs "-XX:MaxPermSize=${TEST_JVM_MEMORY_SIZE}"
}

// Initializing Robolectric is expensive, two threads seem to be around the only level where any
// improvement is seen.
testTask.maxParallelForks = 2
}

android {
compileSdkVersion COMPILE_SDK_VERSION as int

defaultConfig {
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionName VERSION_NAME as String
consumerProguardFiles 'proguard-rules.txt'
}

buildTypes {
debug {
testCoverageEnabled = false
}
}

compileOptions {
Expand All @@ -61,6 +37,7 @@ android {

check.dependsOn(':library:findbugs:findbugs')
check.dependsOn(':library:pmd:pmd')
check.dependsOn(':library:test:check')

// Used in pmd and findbugs subprojects.
@SuppressWarnings("GroovyUnusedDeclaration")
Expand Down
1 change: 0 additions & 1 deletion library/src/test/resources/exif-orientation-examples
Submodule exif-orientation-examples deleted from 85c6e1
51 changes: 51 additions & 0 deletions library/test/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apply plugin: 'com.android.library'

dependencies {
testImplementation "com.android.support:appcompat-v7:${ANDROID_SUPPORT_VERSION}"
testImplementation project(':library')
testImplementation project(':testutil')
testImplementation 'com.google.guava:guava-testlib:18.0'
testImplementation "com.google.truth:truth:${TRUTH_VERSION}"
testImplementation "junit:junit:${JUNIT_VERSION}"
testImplementation "org.mockito:mockito-core:${MOCKITO_VERSION}"
testImplementation "org.robolectric:robolectric:${ROBOLECTRIC_VERSION}"
testImplementation "com.squareup.okhttp3:mockwebserver:${MOCKWEBSERVER_VERSION}"
testImplementation "com.android.support:support-v4:${ANDROID_SUPPORT_VERSION}"
}

tasks.withType(JavaCompile) {
options.fork = true
}

afterEvaluate {
lint.enabled = false
compileDebugJavaWithJavac.enabled = false
}

android.testOptions.unitTests.all { Test testTask ->
// configure max heap size of the test JVM
testTask.maxHeapSize = TEST_JVM_MEMORY_SIZE as String
if (JavaVersion.current() <= JavaVersion.VERSION_1_7) {
// Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=2048m; support was removed in 8.0
testTask.jvmArgs "-XX:MaxPermSize=${TEST_JVM_MEMORY_SIZE}"
}

// Initializing Robolectric is expensive, two threads seem to be around the only level where any
// improvement is seen.
testTask.maxParallelForks = 2
}

android {
compileSdkVersion COMPILE_SDK_VERSION as int

defaultConfig {
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionName VERSION_NAME as String
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
4 changes: 4 additions & 0 deletions library/test/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.bumptech.glide.test">
<application/>
</manifest>
File renamed without changes.
19 changes: 19 additions & 0 deletions library/test/src/test/resources/exif-orientation-examples/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2010 Dave Perrett, http://recursive-design.com/

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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
EXIF Orientation-flag example images
====================================

Example images using each of the EXIF orientation flags (1-to-8), in both landscape and portrait orientations.

[See here](http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/) for more information.

Change history
-----------

* **Version 1.0.1 (2013-03-10)** : Add MIT license and some contact details.
* **Version 1.0.0 (2012-07-28)** : 1.0 release.

Contributing
------------

Once you've made your commits:

1. [Fork](http://help.github.com/fork-a-repo/) exif-orientation-examples
2. Create a topic branch - `git checkout -b my_branch`
3. Push to your branch - `git push origin my_branch`
4. Create a [Pull Request](http://help.github.com/pull-requests/) from your branch
5. That's it!

Author
------

Dave Perrett :: [email protected] :: [@daveperrett](http://twitter.com/daveperrett)


Copyright
---------

These images are licensed under the [MIT License](http://opensource.org/licenses/MIT).

Copyright (c) 2010 Dave Perrett. See [License](https://github.com/recurser/exif-orientation-examples/blob/master/LICENSE) for details.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.1
File renamed without changes
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exec {
include ':library'
include ':library:pmd'
include ':library:findbugs'
include ':library:test'
include ':instrumentation'
include ':annotation'
include ':annotation:compiler'
Expand Down

0 comments on commit 95637cf

Please sign in to comment.