Skip to content

Commit a31bf37

Browse files
authored
Splitting into pre and post proguard tests (#36)
1 parent 02b9de6 commit a31bf37

File tree

8 files changed

+51
-16
lines changed

8 files changed

+51
-16
lines changed

ci/fireci/fireci/commands.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,22 @@ def gradle_command(task, gradle_opts):
3030
gradle.run(*task, gradle_opts=gradle_opts)
3131

3232

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

3845
cwd = os.getcwd()
3946
gradle.run(
40-
'connectedReleaseAndroidTest',
47+
'connectedCheck',
48+
'-PtestBuildType=%s' % (app_build_variant),
4149
gradle_opts='-Dmaven.repo.local={}'.format(
4250
os.path.join(cwd, 'build', 'm2repository')),
4351
workdir=os.path.join(cwd, 'test-apps'),

ci/fireci/tests/integ_tests.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_gradle_invocation(self):
6666
def test_smoke_test_when_build_fails_should_fail(self):
6767
create_artifacts(
6868
Artifact('gradlew', content=scripts.with_exit(1), mode=0o744))
69-
result = self.runner.invoke(cli, ['smoke_tests_experimental'])
69+
result = self.runner.invoke(cli, ['smoke_tests'])
7070
self.assertNotEqual(result.exit_code, 0)
7171

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

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

9191
@in_tempdir
92-
def test_smoke_test_should_invoke_gradle_with_expected_arguments(self):
92+
def test_smoke_test_no_buildType_should_invoke_gradle_with_release_build_type(
93+
self):
94+
create_artifacts(
95+
Artifact(
96+
'gradlew',
97+
content=scripts.with_expected_arguments(
98+
['./gradlew', 'publishAllToBuildDir']),
99+
mode=0o744),
100+
Artifact(
101+
'test-apps/gradlew',
102+
content=scripts.with_expected_arguments(
103+
['./gradlew', 'connectedCheck', '-PtestBuildType=release'], {
104+
'GRADLE_OPTS':
105+
'-Dmaven.repo.local={}'.format(
106+
os.path.join(os.getcwd(), 'build', 'm2repository'))
107+
}),
108+
mode=0o744),
109+
)
110+
result = self.runner.invoke(cli, ['smoke_tests'])
111+
self.assertEqual(result.exit_code, 0)
112+
113+
@in_tempdir
114+
def test_smoke_test_with_buildType_should_invoke_gradle_with_release_build_type(
115+
self):
93116
create_artifacts(
94117
Artifact(
95118
'gradlew',
@@ -99,12 +122,13 @@ def test_smoke_test_should_invoke_gradle_with_expected_arguments(self):
99122
Artifact(
100123
'test-apps/gradlew',
101124
content=scripts.with_expected_arguments(
102-
['./gradlew', 'connectedReleaseAndroidTest'], {
125+
['./gradlew', 'connectedCheck', '-PtestBuildType=debug'], {
103126
'GRADLE_OPTS':
104127
'-Dmaven.repo.local={}'.format(
105128
os.path.join(os.getcwd(), 'build', 'm2repository'))
106129
}),
107130
mode=0o744),
108131
)
109-
result = self.runner.invoke(cli, ['smoke_tests_experimental'])
132+
result = self.runner.invoke(cli,
133+
['smoke_tests', '--app-build-variant', 'debug'])
110134
self.assertEqual(result.exit_code, 0)

test-apps/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ This experimental directory contains apps that are used to smoke test Firebase A
2929
- From the /test-apps dir, run the tests
3030

3131
```
32-
./gradlew connectedReleaseAndroidTest -PfirebaseProjectId=<your_project_id> -PfirebaseToken=<your_firebase_token> -Pm2Repository=${PWD}/../build/m2repository/
32+
./gradlew connectedCheck -PtestBuildType=<release|debug> -PfirebaseProjectId=<your_project_id> -PfirebaseToken=<your_firebase_token> -Pm2Repository=${PWD}/../build/m2repository/
3333
```

test-apps/build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ buildscript {
2424
jcenter()
2525
mavenLocal()
2626
google()
27-
maven { url 'https://maven.fabric.io/public' }
2827
}
2928
dependencies {
3029
classpath 'com.android.tools.build:gradle:3.1.4'
@@ -38,6 +37,8 @@ plugins {
3837
}
3938

4039
allprojects {
40+
ext.testBuildType = project.getProperties().get("testBuildType", "debug")
41+
4142
apply plugin: 'com.github.sherter.google-java-format'
4243
googleJavaFormat {
4344
toolVersion = '1.6'
@@ -71,6 +72,9 @@ allprojects {
7172
if ( it.name == 'processReleaseGoogleServices') {
7273
it.dependsOn 'copyRootGoogleServices'
7374
}
75+
if ( it.name == 'processDebugGoogleServices') {
76+
it.dependsOn 'copyRootGoogleServices'
77+
}
7478
}
7579

7680
if(file('test_setup.sh').exists()) {
@@ -118,7 +122,7 @@ allprojects {
118122
}
119123
}
120124
tasks.whenTaskAdded {
121-
if ( it.name == 'connectedReleaseAndroidTest') {
125+
if ( it.name == 'connectedCheck') {
122126
it.dependsOn setupSmokeTest
123127
it.dependsOn rootProject.tasks.findByName("dependencyUpdates")
124128
}

test-apps/database-test-app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
apply plugin: 'com.android.application'
1818

1919
android {
20-
testBuildType "release"
20+
testBuildType = project.testBuildType
2121
compileSdkVersion 27
2222

2323
defaultConfig {

test-apps/firestore-test-app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
apply plugin: 'com.android.application'
1818

1919
android {
20-
testBuildType "release"
20+
testBuildType = project.testBuildType
2121
compileSdkVersion 27
2222

2323
defaultConfig {

test-apps/functions-test-app/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
apply plugin: 'com.android.application'
1818

1919
android {
20-
// Changes the test build type for instrumented tests to "stage".
21-
testBuildType "release"
20+
testBuildType = project.testBuildType
2221
compileSdkVersion 27
2322

2423
defaultConfig {

test-apps/storage-test-app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
apply plugin: 'com.android.application'
1818

1919
android {
20-
testBuildType "release"
20+
testBuildType = project.testBuildType
2121
compileSdkVersion 27
2222

2323
defaultConfig {

0 commit comments

Comments
 (0)