Skip to content

Commit

Permalink
Splitting into pre and post proguard tests (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinraghav committed Sep 25, 2018
1 parent 02b9de6 commit a31bf37
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 16 deletions.
12 changes: 10 additions & 2 deletions ci/fireci/fireci/commands.py
Expand Up @@ -30,14 +30,22 @@ def gradle_command(task, gradle_opts):
gradle.run(*task, gradle_opts=gradle_opts)


@click.option(
'--app-build-variant',
type=click.Choice(['debug', 'release']),
default='release',
help=
'App build variant to use while running the smoke Tests. One of release|debug'
)
@ci_command()
def smoke_tests_experimental():
def smoke_tests(app_build_variant):
"""Builds all SDKs in release mode and then tests test-apps against them."""
gradle.run('publishAllToBuildDir')

cwd = os.getcwd()
gradle.run(
'connectedReleaseAndroidTest',
'connectedCheck',
'-PtestBuildType=%s' % (app_build_variant),
gradle_opts='-Dmaven.repo.local={}'.format(
os.path.join(cwd, 'build', 'm2repository')),
workdir=os.path.join(cwd, 'test-apps'),
Expand Down
36 changes: 30 additions & 6 deletions ci/fireci/tests/integ_tests.py
Expand Up @@ -66,7 +66,7 @@ def test_gradle_invocation(self):
def test_smoke_test_when_build_fails_should_fail(self):
create_artifacts(
Artifact('gradlew', content=scripts.with_exit(1), mode=0o744))
result = self.runner.invoke(cli, ['smoke_tests_experimental'])
result = self.runner.invoke(cli, ['smoke_tests'])
self.assertNotEqual(result.exit_code, 0)

@in_tempdir
Expand All @@ -75,7 +75,7 @@ def test_smoke_test_when_build_succeeds_and_tests_fails_should_fail(self):
Artifact('gradlew', content=scripts.with_exit(0), mode=0o744),
Artifact('test-apps/gradlew', content=scripts.with_exit(1), mode=0o744),
)
result = self.runner.invoke(cli, ['smoke_tests_experimental'])
result = self.runner.invoke(cli, ['smoke_tests'])
self.assertNotEqual(result.exit_code, 0)

@in_tempdir
Expand All @@ -85,11 +85,34 @@ def test_smoke_test_when_build_succeeds_and_tests_succeed_should_succeed(
Artifact('gradlew', content=scripts.with_exit(0), mode=0o744),
Artifact('test-apps/gradlew', content=scripts.with_exit(0), mode=0o744),
)
result = self.runner.invoke(cli, ['smoke_tests_experimental'])
result = self.runner.invoke(cli, ['smoke_tests'])
self.assertEqual(result.exit_code, 0)

@in_tempdir
def test_smoke_test_should_invoke_gradle_with_expected_arguments(self):
def test_smoke_test_no_buildType_should_invoke_gradle_with_release_build_type(
self):
create_artifacts(
Artifact(
'gradlew',
content=scripts.with_expected_arguments(
['./gradlew', 'publishAllToBuildDir']),
mode=0o744),
Artifact(
'test-apps/gradlew',
content=scripts.with_expected_arguments(
['./gradlew', 'connectedCheck', '-PtestBuildType=release'], {
'GRADLE_OPTS':
'-Dmaven.repo.local={}'.format(
os.path.join(os.getcwd(), 'build', 'm2repository'))
}),
mode=0o744),
)
result = self.runner.invoke(cli, ['smoke_tests'])
self.assertEqual(result.exit_code, 0)

@in_tempdir
def test_smoke_test_with_buildType_should_invoke_gradle_with_release_build_type(
self):
create_artifacts(
Artifact(
'gradlew',
Expand All @@ -99,12 +122,13 @@ def test_smoke_test_should_invoke_gradle_with_expected_arguments(self):
Artifact(
'test-apps/gradlew',
content=scripts.with_expected_arguments(
['./gradlew', 'connectedReleaseAndroidTest'], {
['./gradlew', 'connectedCheck', '-PtestBuildType=debug'], {
'GRADLE_OPTS':
'-Dmaven.repo.local={}'.format(
os.path.join(os.getcwd(), 'build', 'm2repository'))
}),
mode=0o744),
)
result = self.runner.invoke(cli, ['smoke_tests_experimental'])
result = self.runner.invoke(cli,
['smoke_tests', '--app-build-variant', 'debug'])
self.assertEqual(result.exit_code, 0)
2 changes: 1 addition & 1 deletion test-apps/README.md
Expand Up @@ -29,5 +29,5 @@ This experimental directory contains apps that are used to smoke test Firebase A
- From the /test-apps dir, run the tests

```
./gradlew connectedReleaseAndroidTest -PfirebaseProjectId=<your_project_id> -PfirebaseToken=<your_firebase_token> -Pm2Repository=${PWD}/../build/m2repository/
./gradlew connectedCheck -PtestBuildType=<release|debug> -PfirebaseProjectId=<your_project_id> -PfirebaseToken=<your_firebase_token> -Pm2Repository=${PWD}/../build/m2repository/
```
8 changes: 6 additions & 2 deletions test-apps/build.gradle
Expand Up @@ -24,7 +24,6 @@ buildscript {
jcenter()
mavenLocal()
google()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
Expand All @@ -38,6 +37,8 @@ plugins {
}

allprojects {
ext.testBuildType = project.getProperties().get("testBuildType", "debug")

apply plugin: 'com.github.sherter.google-java-format'
googleJavaFormat {
toolVersion = '1.6'
Expand Down Expand Up @@ -71,6 +72,9 @@ allprojects {
if ( it.name == 'processReleaseGoogleServices') {
it.dependsOn 'copyRootGoogleServices'
}
if ( it.name == 'processDebugGoogleServices') {
it.dependsOn 'copyRootGoogleServices'
}
}

if(file('test_setup.sh').exists()) {
Expand Down Expand Up @@ -118,7 +122,7 @@ allprojects {
}
}
tasks.whenTaskAdded {
if ( it.name == 'connectedReleaseAndroidTest') {
if ( it.name == 'connectedCheck') {
it.dependsOn setupSmokeTest
it.dependsOn rootProject.tasks.findByName("dependencyUpdates")
}
Expand Down
2 changes: 1 addition & 1 deletion test-apps/database-test-app/build.gradle
Expand Up @@ -17,7 +17,7 @@
apply plugin: 'com.android.application'

android {
testBuildType "release"
testBuildType = project.testBuildType
compileSdkVersion 27

defaultConfig {
Expand Down
2 changes: 1 addition & 1 deletion test-apps/firestore-test-app/build.gradle
Expand Up @@ -17,7 +17,7 @@
apply plugin: 'com.android.application'

android {
testBuildType "release"
testBuildType = project.testBuildType
compileSdkVersion 27

defaultConfig {
Expand Down
3 changes: 1 addition & 2 deletions test-apps/functions-test-app/build.gradle
Expand Up @@ -17,8 +17,7 @@
apply plugin: 'com.android.application'

android {
// Changes the test build type for instrumented tests to "stage".
testBuildType "release"
testBuildType = project.testBuildType
compileSdkVersion 27

defaultConfig {
Expand Down
2 changes: 1 addition & 1 deletion test-apps/storage-test-app/build.gradle
Expand Up @@ -17,7 +17,7 @@
apply plugin: 'com.android.application'

android {
testBuildType "release"
testBuildType = project.testBuildType
compileSdkVersion 27

defaultConfig {
Expand Down

0 comments on commit a31bf37

Please sign in to comment.