Skip to content

Commit 768f57b

Browse files
Change integration test log level to "debug"
Currently the logging behaviour for "debug" level logs is set to show them at the end of the integration test, if there were any failures. This results in them not showing up at all, should the integration test prematurely exit to due a crash, failed assertion, or timeout. In practice, this often leads to a lack of relevant logs to understand why a test didn't complete. To fix this, the overall log level is changed from info to debug. This ensures debug logs are logged immediately, so a prematurely ended test won't prevent them from showing up. This also includes a small fix to the desktop_tester script to capture logs in the event of a process timeout: previously, result.stdout was used, which doesn't get populated if the process timed out. Instead, we access output from the error. Experimentation revealed that this output will sometimes be test, and sometimes binary: it's unclear what's responsible for this difference (possibly the encoding settings of the environment running the script). Thus we try to decode, and store it as-is if that fails.
1 parent 0aae949 commit 768f57b

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

scripts/gha/desktop_tester.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,27 @@ class Test(object):
9494
# them as fields so they can be accessed from the main thread.
9595
def run(self):
9696
"""Executes this testapp."""
97-
result = subprocess.run(
98-
args=[self.testapp_path],
99-
cwd=os.path.dirname(self.testapp_path), # Testapp checks CWD for config
100-
stdout=subprocess.PIPE,
101-
stderr=subprocess.STDOUT,
102-
text=True,
103-
check=False,
104-
timeout=300)
97+
result = None # Ensures this var is defined if timeout occurs.
98+
try:
99+
result = subprocess.run(
100+
args=[self.testapp_path],
101+
cwd=os.path.dirname(self.testapp_path), # Testapp uses CWD for config
102+
stdout=subprocess.PIPE,
103+
stderr=subprocess.STDOUT,
104+
text=True,
105+
check=False,
106+
timeout=300)
107+
except subprocess.TimeoutExpired as e:
108+
logging.error("Testapp timed out!")
109+
# e.output will sometimes be bytes, sometimes string. Decode if needed.
110+
try:
111+
self.logs = e.output.decode()
112+
except AttributeError: # This will happen if it's already a string.
113+
self.logs = e.output
114+
if result:
115+
self.logs = result.stdout
105116
logging.info("Finished running %s", self.testapp_path)
106117

107-
self.logs = result.stdout
108-
self.return_code = result.returncode
109-
110118

111119
if __name__ == "__main__":
112120
app.run(main)

testing/test_framework/src/firebase_test_framework.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ std::ostream& operator<<(std::ostream& os, const Variant& v) {
208208
extern "C" int common_main(int argc, char* argv[]) {
209209
::testing::InitGoogleTest(&argc, argv);
210210
firebase_test_framework::FirebaseTest::SetArgs(argc, argv);
211-
app_framework::SetLogLevel(app_framework::kInfo);
211+
app_framework::SetLogLevel(app_framework::kDebug);
212212
// Anything below the given log level will be preserved, and printed out in
213213
// the event of test failure.
214214
app_framework::SetPreserveFullLog(true);

0 commit comments

Comments
 (0)