Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Nov 16, 2018
1 parent aacf6bd commit 6211c0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 43 deletions.
4 changes: 2 additions & 2 deletions test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class AndroidArgs(
override val resultsHistoryName = gcloud.resultsHistoryName

private val androidGcloud = androidGcloudYml.gcloud
val appApk = cli.app ?: androidGcloud.app
val testApk = cli.test ?: androidGcloud.test
var appApk = cli.app ?: androidGcloud.app
var testApk = cli.test ?: androidGcloud.test
val autoGoogleLogin = androidGcloud.autoGoogleLogin

// We use not() on noUseOrchestrator because if the flag is on, useOrchestrator needs to be false
Expand Down
10 changes: 4 additions & 6 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ class AndroidArgsTest {
@Test
fun androidArgs() {
val androidArgs = AndroidArgs.load(androidNonDefault)
val expectedAppApk = appApk
val expectedTestApk = testApk

with(androidArgs) {
// GcloudYml
Expand All @@ -130,8 +128,8 @@ class AndroidArgsTest {
assert(resultsHistoryName ?: "", "android-history")

// AndroidGcloudYml
assert(appApk, expectedAppApk)
assert(testApk, expectedTestApk)
assert(appApk, appApkAbsolutePath)
assert(testApk, testApkAbsolutePath)
assert(autoGoogleLogin, false)
assert(useOrchestrator, false)
assert(environmentVariables, linkedMapOf("clearPackageData" to "true", "randomEnvVar" to "false"))
Expand Down Expand Up @@ -297,7 +295,7 @@ AndroidArgs
cli
)

assertThat(androidArgs.appApk).isEqualTo(testApk)
assertThat(androidArgs.appApk).isEqualTo(testApkAbsolutePath)
assertThat(androidArgs.cli).isEqualTo(cli)
}

Expand All @@ -315,7 +313,7 @@ AndroidArgs
cli
)

assertThat(androidArgs.testApk).isEqualTo(appApk)
assertThat(androidArgs.testApk).isEqualTo(appApkAbsolutePath)
assertThat(androidArgs.cli).isEqualTo(cli)
}

Expand Down
43 changes: 8 additions & 35 deletions test_runner/src/test/kotlin/ftl/args/ArgsHelperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ import ftl.args.ArgsHelper.validateTestMethods
import ftl.args.yml.GcloudYml
import ftl.args.yml.IosGcloudYml
import ftl.test.util.FlankTestRunner
import ftl.test.util.TestHelper.absolutePath
import org.junit.Rule
import org.junit.Test
import org.junit.contrib.java.lang.system.EnvironmentVariables
import org.junit.contrib.java.lang.system.SystemErrRule
import org.junit.rules.ExpectedException
import org.junit.runner.RunWith
import java.io.File
import java.io.IOException
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.SimpleFileVisitor
import java.nio.file.attribute.BasicFileAttributes

@RunWith(FlankTestRunner::class)
class ArgsHelperTest {
Expand Down Expand Up @@ -179,8 +173,10 @@ class ArgsHelperTest {
val testApkRelativePath = "../test_app/apks/app-debug-androidTest.apk"
val testApkBlobPath = "../test_app/**/app-debug-*.apk"

assertThat(File(testApkRelativePath).absolutePath)
.isEqualTo(ArgsHelper.evaluateFilePath(testApkBlobPath))
val actual = ArgsHelper.evaluateFilePath(testApkBlobPath)
val expected = testApkRelativePath.absolutePath()

assertThat(actual).isEqualTo(expected)
}

private fun makeTmpFile(filePath: String): String {
Expand All @@ -195,29 +191,6 @@ class ArgsHelperTest {
return file.absolutePath
}

private fun String.absolutePath(): String {
return File(this).absolutePath
}

@Test
fun tmpTest() {
Files.walkFileTree(Paths.get("/tmp"), object : SimpleFileVisitor<Path>() {
@Throws(IOException::class)
override fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult {
// hits '/tmp' once and doesn't iterate through the files
return FileVisitResult.CONTINUE
}

override fun visitFileFailed(file: Path?, exc: IOException?): FileVisitResult {
return FileVisitResult.CONTINUE
}

override fun preVisitDirectory(dir: Path?, attrs: BasicFileAttributes?): FileVisitResult {
return FileVisitResult.CONTINUE
}
})
}

@Test
fun evaluateTildeInFilePath() {
val expected = makeTmpFile("/tmp/random.xctestrun")
Expand All @@ -232,10 +205,10 @@ class ArgsHelperTest {
fun evaluateEnvVarInFilePath() {
environmentVariables.set("TEST_APK_DIR", "test_app/apks")
val testApkPath = "../\$TEST_APK_DIR/app-debug-androidTest.apk"
val expectedPath = "../test_app/apks/app-debug-androidTest.apk".absolutePath()
val actual = ArgsHelper.evaluateFilePath(testApkPath)
val expected = "../test_app/apks/app-debug-androidTest.apk".absolutePath()

assertThat(expectedPath)
.isEqualTo(ArgsHelper.evaluateFilePath(testApkPath))
assertThat(actual).isEqualTo(expected)
}

@Test(expected = java.nio.file.NoSuchFileException::class)
Expand Down

0 comments on commit 6211c0f

Please sign in to comment.