Skip to content

Commit da6f7be

Browse files
committed
ci: properly filter logcat in log
1 parent 02e871a commit da6f7be

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

test-app/tools/try_to_find_test_result_file.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,18 @@ function filterLogcatFromCutoff(logcatOutput) {
7070
}
7171

7272
async function readAndFilterLogcat() {
73+
// if we have a PID, filter by it
74+
if (appPID !== -1) {
75+
return new Promise((resolve) => {
76+
exec(`${adbPrefix} logcat -d --pid=${appPID}`, (error, stdout) => {
77+
resolve(filterLogcatFromCutoff(stdout || ""));
78+
});
79+
});
80+
}
81+
// otherwise, do a general logcat read
7382
return new Promise((resolve) => {
74-
exec(`${adbPrefix} logcat -d | grep ${appId}`, (error, stdout) => {
83+
console.log('Reading full logcat since app PID is unknown');
84+
exec(`${adbPrefix} logcat -d`, (error, stdout) => {
7585
resolve(filterLogcatFromCutoff(stdout || ""));
7686
});
7787
});
@@ -96,9 +106,19 @@ async function ensureProcessAlive() {
96106
console.error(`${appId} process died or never started!`);
97107
await exitWithLogcatDump();
98108
}
109+
await updateAppPID();
99110

100111
console.log(`${appId} process is running`);
101112
}
113+
let appPID = -1;
114+
async function updateAppPID() {
115+
if (appPID !== -1) {
116+
return appPID;
117+
}
118+
const { stdout } = await execAndStream(`${adbPrefix} shell "pidof ${appId}"`);
119+
appPID = parseInt(stdout.trim(), 10);
120+
return appPID;
121+
}
102122

103123
async function checkForErrorActivity() {
104124
const { error } = await execAndStream(

0 commit comments

Comments
 (0)