Skip to content

Commit 9e42591

Browse files
committed
- Verify incremental native build - Verify clean build rebuild native project - Assert build times (with safe tolerance)
1 parent 09ab683 commit 9e42591

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

tests/build/android/build_android_tests.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Tests for building projects with the Android platform
33
"""
4+
import datetime
45
import os
56
import unittest
67
from zipfile import ZipFile
@@ -88,7 +89,15 @@ def test_001_build_android(self):
8889
File.copy(src=src, dest=dest_1)
8990
File.copy(src=src, dest=dest_2)
9091

91-
Tns.build_android(attributes={"--path": self.app_name})
92+
# Verify incremental native build
93+
before_build = datetime.datetime.now()
94+
output = Tns.build_android(attributes={"--path": self.app_name})
95+
after_build = datetime.datetime.now()
96+
assert "Gradle build..." in output, "Gradle build not called."
97+
assert output.count("Gradle build...") is 1, "Only one gradle build is triggered."
98+
assert (after_build - before_build).total_seconds() < 20, "Incremental build takes more then 20 sec."
99+
100+
# Verify platform specific files
92101
assert File.pattern_exists(self.platforms_android, "*.aar")
93102
assert not File.pattern_exists(self.platforms_android, "*.plist")
94103
assert not File.pattern_exists(self.platforms_android, "*.android.js")
@@ -102,6 +111,24 @@ def test_001_build_android(self):
102111
assert not File.pattern_exists(self.app_name + "/temp", "*.android.*")
103112
assert not File.pattern_exists(self.app_name + "/temp", "*.ios.*")
104113

114+
# Verify clean build force native project rebuild
115+
before_build = datetime.datetime.now()
116+
output = Tns.build_android(attributes={"--path": self.app_name})
117+
after_build = datetime.datetime.now()
118+
assert "Gradle build..." in output, "Gradle build not called."
119+
assert output.count("Gradle build...") is 1, "Only one gradle build is triggered."
120+
assert (after_build - before_build).total_seconds() < 15, "Incremental build takes more then 15 sec."
121+
122+
# Verify incremental native build
123+
before_build = datetime.datetime.now()
124+
output = Tns.build_android(attributes={"--path": self.app_name, "--clean": ""})
125+
after_build = datetime.datetime.now()
126+
build_time = (after_build - before_build).total_seconds()
127+
assert "Gradle build..." in output, "Gradle build not called."
128+
assert output.count("Gradle build...") is 2, "Only one gradle build is triggered."
129+
assert build_time > 15, "Clean build takes less then 15 sec."
130+
assert build_time < 90, "Clean build takes more than 90 sec."
131+
105132
def test_002_build_android_release(self):
106133
Tns.build_android(attributes={"--path": self.app_name,
107134
"--keyStorePath": ANDROID_KEYSTORE_PATH,

0 commit comments

Comments
 (0)