From b5f727f9454e04514ab48f7ff85f316b5fda79f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey=20Vilas?= Date: Tue, 1 Mar 2022 16:31:26 +0100 Subject: [PATCH] RetryTestRule: don't modify in scripts, use buildConfigField instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modifying code in scripts is bad Signed-off-by: Álvaro Brey Vilas --- .drone.yml | 2 -- build.gradle | 3 +++ src/androidTest/java/com/nextcloud/client/RetryTestRule.kt | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 83adf7b6fb..8ad21d5c00 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,7 +21,6 @@ steps: - emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 & - sed -i s'#false#true#'g src/main/res/values/setup.xml - sed -i s"#server#server#" gradle.properties - - sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt - ./gradlew assembleGplay - ./gradlew assembleGplayDebug - scripts/wait_for_emulator.sh @@ -85,7 +84,6 @@ steps: - scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0 - emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 & - sed -i s'#false#true#'g src/main/res/values/setup.xml - - sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt - scripts/runCombinedTest.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER services: diff --git a/build.gradle b/build.gradle index d3c8790ffb..3bec9a68bb 100644 --- a/build.gradle +++ b/build.gradle @@ -111,6 +111,8 @@ android { minSdkVersion 23 targetSdkVersion 30 + buildConfigField 'boolean', 'CI', ciBuild.toString() + // arguments to be passed to functional tests testInstrumentationRunner "com.nextcloud.client.ScreenshotTestRunner" testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}" @@ -235,6 +237,7 @@ android { htmlOutput file("$project.buildDir/reports/lint/lint.html") htmlReport true } + } dependencies { diff --git a/src/androidTest/java/com/nextcloud/client/RetryTestRule.kt b/src/androidTest/java/com/nextcloud/client/RetryTestRule.kt index aa3ecf152b..7b8c3f13bd 100644 --- a/src/androidTest/java/com/nextcloud/client/RetryTestRule.kt +++ b/src/androidTest/java/com/nextcloud/client/RetryTestRule.kt @@ -23,6 +23,7 @@ package com.nextcloud.client import android.util.Log +import com.owncloud.android.BuildConfig import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement @@ -30,10 +31,13 @@ import org.junit.runners.model.Statement /** * C&p from https://stackoverflow.com/questions/45635833/how-can-i-use-flakytest-annotation-now on 18.03.2020 */ -class RetryTestRule(val retryCount: Int = 1) : TestRule { +class RetryTestRule(val retryCount: Int = defaultRetryValue) : TestRule { companion object { private val TAG = RetryTestRule::class.java.simpleName + + @Suppress("MagicNumber") + private val defaultRetryValue: Int = if (BuildConfig.CI) 5 else 1 } override fun apply(base: Statement, description: Description): Statement {