Skip to content

Commit

Permalink
Merge pull request #21 from agoda-com/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
tagantroy authored Jan 2, 2018
2 parents 889ce58 + 223b660 commit 0455a15
Show file tree
Hide file tree
Showing 97 changed files with 1,636 additions and 1,159 deletions.
26 changes: 26 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,29 @@ task jacocoMergedReport(type: JacocoReport, dependsOn: jacocoMergeExecutions) {
xml.enabled true
}
}
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
24 changes: 24 additions & 0 deletions chimprunner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

apply plugin: 'java-library'
apply plugin: 'kotlin'
apply plugin: 'application'
apply from: '../build-scripts/gradle-mvn-push.gradle'

Expand All @@ -32,6 +33,7 @@ dependencies {
testImplementation(
"org.jmock:jmock:$JMOCK_VERSION",
"org.jmock:jmock-junit4:$JMOCK_VERSION")
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

jar {
Expand All @@ -53,3 +55,25 @@ run {
args project.args.split('\\s+')
}
}
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;

import static java.lang.String.format;

Expand Down Expand Up @@ -57,7 +58,7 @@ private void runTest(Device device, TestCaseEvent testCaseEvent) throws TestFail
String testClassName = testCaseEvent.getTestClass();
String testMethodName = testCaseEvent.getTestMethod();
androidTestRunner.setMethodName(testClassName, testMethodName);
androidTestRunner.setMaxtimeToOutputResponse(Defaults.ADB_MAX_TIME_TO_OUTPUT_RESPONSE);
androidTestRunner.setMaxTimeToOutputResponse(Defaults.ADB_MAX_TIME_TO_OUTPUT_RESPONSE, TimeUnit.MILLISECONDS);
try {
PerformanceTestListener performanceTestListener = new LoggingPerformanceTestListener(testCaseEvent, results);
performanceTestListener.startOverall();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import static com.shazam.chimprunner.injector.ConfigurationInjector.configuration;
import static com.shazam.chimprunner.injector.io.DexFileExtractorInjector.dexFileExtractor;
import static com.shazam.chimprunner.injector.model.TestCaseEventFactoryInjector.testCaseEventFactory;
import static com.shazam.chimprunner.injector.stat.TestStatLoaderInjector.testStatsLoader;
import static com.shazam.chimprunner.injector.suite.TestClassMatcherInjector.testClassMatcher;

public class TestSuiteLoaderInjector {
Expand Down
26 changes: 26 additions & 0 deletions fork-client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
apply plugin: 'java-library'
apply plugin: 'kotlin'
apply from: '../build-scripts/gradle-mvn-push.gradle'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
26 changes: 25 additions & 1 deletion fork-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

apply plugin: 'java-library'
apply plugin: 'kotlin'
apply from: '../build-scripts/gradle-mvn-push.gradle'

//noinspection GroovyUnusedAssignment
Expand All @@ -20,7 +21,7 @@ dependencies {
api project(':fork-client')
api project(':fork-stat-common')
api "com.google.code.findbugs:jsr305:3.0.1"
api "com.android.tools.ddms:ddmlib:25.1.0"
api "com.android.tools.ddms:ddmlib:26.0.1"
api "commons-io:commons-io:2.5"
api "org.apache.commons:commons-lang3:3.4"
api "com.github.spullara.mustache.java:compiler:0.8.0"
Expand All @@ -40,6 +41,7 @@ dependencies {
testImplementation("junit:junit:$JUNIT_VERSION") {
exclude module:'hamcrest-core'
}
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

jar {
Expand All @@ -52,3 +54,25 @@ jar {
'Built-Gradle': gradle.gradleVersion
}
}
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
import org.jf.dexlib.DexFile;

import java.io.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
import java.util.zip.*;

import static com.shazam.fork.io.Files.convertFileToDexFile;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.io.IOUtils.closeQuietly;
import static org.apache.commons.io.IOUtils.copyLarge;
Expand All @@ -35,10 +36,9 @@ public ClassesDexFileExtractor(File outputDirectory) {
public Collection<DexFile> getDexFiles(File apkFile) {
dumpDexFilesFromApk(apkFile, outputDirectory);
File[] dexFiles = outputDirectory.listFiles((dir, name) -> name.startsWith("classes") && name.endsWith(".dex"));
return asList(dexFiles)
.stream()
return Arrays.stream(dexFiles)
.map(convertFileToDexFile())
.filter(f -> f != null)
.filter(Objects::nonNull)
.collect(toList());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.shazam.fork.stat;

import com.agoda.fork.stat.StatLoader;
import com.agoda.fork.stat.StatLoaderProvider;
import com.agoda.fork.stat.TestHistory;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.shazam.fork.io.DexFileExtractor;
import com.shazam.fork.model.TestCaseEvent;
import com.shazam.fork.model.TestCaseEventFactory;
import com.shazam.fork.stat.TestStatsLoader;
import org.jf.dexlib.*;
import org.jf.dexlib.EncodedValue.AnnotationEncodedSubValue;
import org.jf.dexlib.EncodedValue.ArrayEncodedValue;
Expand All @@ -30,7 +29,6 @@
import static java.util.Arrays.stream;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;

public class TestSuiteLoader {
private static final String TEST_ANNOTATION = "Lorg/junit/Test;";
Expand Down Expand Up @@ -192,27 +190,22 @@ private int indexOfName(AnnotationEncodedSubValue p, String key) {

private boolean isClassIgnored(AnnotationDirectoryItem annotationDirectoryItem) {
AnnotationSetItem classAnnotations = annotationDirectoryItem.getClassAnnotations();
if (classAnnotations == null) {
return false;
}
return containsAnnotation(IGNORE_ANNOTATION, classAnnotations.getAnnotations());
return classAnnotations != null && containsAnnotation(IGNORE_ANNOTATION, classAnnotations.getAnnotations());
}


private boolean included(AnnotationItem... annotations) {
if (includedAnnotations.isEmpty()) {
return true;
}
return includedAnnotations.stream()
.anyMatch(included -> containsAnnotation(included, annotations));
return includedAnnotations.isEmpty() ||
containsAnnotation(annotations, includedAnnotations.stream());
}

private boolean containsAnnotation(AnnotationItem[] annotations, Stream<String> stream) {
return stream.anyMatch(included -> containsAnnotation(included, annotations));
}

private boolean excluded(AnnotationItem... annotations) {
if (excludedAnnotations.isEmpty()) {
return false;
}
return excludedAnnotations.stream()
.anyMatch(excluded -> containsAnnotation(excluded, annotations));
return !excludedAnnotations.isEmpty()
&& containsAnnotation(annotations, excludedAnnotations.stream());
}

private boolean containsAnnotation(String comparisonAnnotation, AnnotationItem... annotations) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.shazam.fork.suite;

import com.agoda.fork.stat.TestMetric;
import com.shazam.fork.model.TestCaseEvent;
import com.shazam.fork.model.TestCaseEventFactory;
import com.shazam.fork.stat.StatServiceLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ForkPlugin implements Plugin<Project> {
excludedAnnotation = config.excludedAnnotation
includedAnnotation = config.includedAnnotation
sortingStrategy = config.sortingStrategy
batchStrategy = config.batchStrategy

applicationApk = new File(baseVariantOutput.packageApplication.outputDirectory.path + "/" + baseVariantOutput.outputFileName)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package com.shazam.fork.gradle

import com.shazam.fork.BatchStrategy
import com.shazam.fork.Configuration
import com.shazam.fork.Fork
import com.shazam.fork.PoolingStrategy
Expand Down Expand Up @@ -82,6 +83,8 @@ class ForkRunTask extends DefaultTask implements VerificationTask {

SortingStrategy sortingStrategy

BatchStrategy batchStrategy

@TaskAction
void runFork() {
LOG.info("Run instrumentation tests $instrumentationApk for app $applicationApk")
Expand Down Expand Up @@ -109,6 +112,7 @@ class ForkRunTask extends DefaultTask implements VerificationTask {
.withExcludedAnnotation(excludedAnnotation)
.withIncludedAnnotation(includedAnnotation)
.withSortingStrategy(sortingStrategy)
.withBatchStrategy(batchStrategy)
.build();

boolean success = new Fork(configuration).run()
Expand Down
22 changes: 22 additions & 0 deletions fork-reporter-jenkins-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@
*/

apply plugin: 'java-gradle-plugin'
apply plugin: 'kotlin'
apply from: '../build-scripts/gradle-mvn-push.gradle'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

repositories {
maven { url "http://repo.jenkins-ci.org/public/" }
mavenCentral()
}

dependencies {
implementation project(':fork-reporter')
implementation "com.offbytwo.jenkins:jenkins-client:0.3.4"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

jar {
Expand All @@ -33,3 +36,22 @@ jar {
'Built-Gradle': gradle.gradleVersion
}
}
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ String downloadJenkinsFiles() {

jobWithDetails
.getBuilds()
.stream()
.forEach(build -> getDetailsFromBuild(build).stream()
.filter(this::isForkSummaryArtifact)
.forEach(artifact -> downloadArtifact(build, artifact)));
Expand Down Expand Up @@ -209,8 +208,7 @@ private URI getArtifactUri(Build build, Artifact artifact) {
try {
URI uri = new URI(build.getUrl());
String artifactPath = uri.getPath() + "artifact/" + artifact.getRelativePath();
URI artifactUri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), artifactPath, "", "");
return artifactUri;
return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), artifactPath, "", "");
} catch (URISyntaxException e) {
throw new GradleException("Error when trying to construct artifact URL for: " + build.getUrl(), e);
}
Expand Down
Loading

0 comments on commit 0455a15

Please sign in to comment.