Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: NPE on dumpShards #1612

Merged
merged 6 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions integration_tests/src/test/kotlin/integration/DumpShardsIT.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package integration

import FlankCommand
import com.google.common.truth.Truth
import flank.common.isWindows
import org.junit.Assume
import org.junit.Test
import run

class DumpShardsIT {
private val name = this::class.java.simpleName

@Test
fun `dump shards - android`() {
val name = "$name-android"
val result = FlankCommand(
flankPath = FLANK_JAR_PATH,
ymlPath = "$CONFIGS_PATH/dump_shards_android.yml",
params = androidRunCommands + "--dump-shards"
).run(
workingDirectory = "./",
testSuite = name
)

assertExitCode(result, 0)

val resOutput = result.output.removeUnicode()
Truth.assertThat(resOutput).containsMatch(findInCompare(name))
assertNoOutcomeSummary(resOutput)
pawelpasterz marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
fun `dump shards - ios`() {
Assume.assumeFalse(isWindows)
val name = "$name-ios"
val result = FlankCommand(
flankPath = FLANK_JAR_PATH,
ymlPath = "$CONFIGS_PATH/dump_shards_ios.yml",
params = iosRunCommands + "--dump-shards"
).run(
workingDirectory = "./",
testSuite = name
)

assertExitCode(result, 0)

val resOutput = result.output.removeUnicode()
Truth.assertThat(resOutput).containsMatch(findInCompare(name))
assertNoOutcomeSummary(resOutput)
pawelpasterz marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gcloud:
pawelpasterz marked this conversation as resolved.
Show resolved Hide resolved
app: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk
test: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/apk/app-single-success-debug-androidTest.apk
pawelpasterz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gcloud:
pawelpasterz marked this conversation as resolved.
Show resolved Hide resolved
test: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/ios/EarlGreyExample/EarlGreyExample.zip
xctestrun-file: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/ios/EarlGreyExample/EarlGreyExampleSwiftTests.xctestrun

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Saved 1 shards to android_shards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Saved 1 shards to ios_shards.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,22 @@ class AndroidRunCommand : CommonRunCommand(), Runnable {

AndroidArgs.load(Paths.get(configPath), cli = this).apply {
setupLogLevel()
logLn(this)

outputReport.configure(toOutputReportConfiguration())
outputReport.log(this)
setCrashReportTag(
DEVICE_SYSTEM to "android",
TEST_TYPE to type?.name.orEmpty()
)
sendConfiguration()
}.validate().run {
}.validate().also { args ->
runBlocking {
if (dumpShards) dumpShards()
else newTestRun()
if (dumpShards)
args.dumpShards()
else {
logLn(args)
args.newTestRun()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ class IosRunCommand : CommonRunCommand(), Runnable {

IosArgs.load(Paths.get(configPath), cli = this).apply {
setupLogLevel()
logLn(this)
outputReport.configure(toOutputReportConfiguration())
outputReport.log(this)
setCrashReportTag(
DEVICE_SYSTEM to "ios",
TEST_TYPE to type?.name.orEmpty()
)
sendConfiguration()
if (dumpShards.not()) logLn(this)
}.validate().run {
if (dumpShards) dumpShards()
else runBlocking { newTestRun() }
Expand Down
6 changes: 5 additions & 1 deletion test_runner/src/main/kotlin/ftl/run/DumpShards.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ fun saveShardChunks(
)
logLn("${FtlConstants.indent}Saved $size shards to $shardFilePath", OutputLogLevel.DETAILED)
}
private fun String.createDirectories() = File(this).parent.toFile().mkdirs()

private fun String.createDirectories() {
if (this !in listOf(ANDROID_SHARD_FILE, IOS_SHARD_FILE))
File(this).parent.toFile().mkdirs()
}

private fun getGson(obfuscatedOutput: Boolean) =
if (obfuscatedOutput) obfuscatePrettyPrinter else prettyPrint
Expand Down