Эх сурвалжийг харах

Merge pull request #9910 from nextcloud/chore/retry-rule-no-sed

RetryTestRule: don't modify in scripts, use buildConfigField instead
Álvaro Brey 3 жил өмнө
parent
commit
c480d91b4c

+ 0 - 2
.drone.yml

@@ -21,7 +21,6 @@ steps:
       - emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
       - sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'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'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'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:

+ 3 - 0
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 {

+ 5 - 1
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 {