Skip to content

Commit 21fe062

Browse files
committed
fix(e2e): log and bound hdiff generation
1 parent cff08d0 commit 21fe062

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

Example/e2etest/scripts/prepare-local-update-artifacts.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const projectRoot = process.cwd();
3232
const platform = process.env.E2E_PLATFORM || 'ios';
3333
const artifactsRoot = path.join(projectRoot, '.e2e-artifacts');
3434
const artifactsDir = path.join(artifactsRoot, platform);
35+
const diffTimeoutMs = 5 * 60_000;
3536
const localRegistry =
3637
process.env.PUSHY_REGISTRY || process.env.RNU_API || 'http://127.0.0.1:65535';
3738

@@ -178,6 +179,7 @@ function prepareDir() {
178179
}
179180

180181
function bundleTo(entryFile: string, outputFile: string) {
182+
console.log(`Bundling ${entryFile} -> ${outputFile}`);
181183
runPushy(
182184
[
183185
'bundle',
@@ -194,6 +196,7 @@ function bundleTo(entryFile: string, outputFile: string) {
194196
],
195197
projectRoot,
196198
);
199+
verifyGeneratedFile(`bundle ${entryFile}`, outputFile);
197200
}
198201

199202
function verifyGeneratedFile(label: string, filePath: string) {
@@ -205,12 +208,25 @@ function verifyGeneratedFile(label: string, filePath: string) {
205208
);
206209
}
207210

208-
async function keepProcessAlive<T>(promise: Promise<T>) {
211+
async function keepProcessAlive<T>(
212+
label: string,
213+
promise: Promise<T>,
214+
timeoutMs = diffTimeoutMs,
215+
) {
209216
const timer = setInterval(() => {}, 1000);
217+
let timeout: ReturnType<typeof setTimeout> | undefined;
218+
const timeoutPromise = new Promise<never>((_, reject) => {
219+
timeout = setTimeout(() => {
220+
reject(new Error(`${label} timed out after ${timeoutMs}ms`));
221+
}, timeoutMs);
222+
});
210223
try {
211-
return await promise;
224+
return await Promise.race([promise, timeoutPromise]);
212225
} finally {
213226
clearInterval(timer);
227+
if (timeout) {
228+
clearTimeout(timeout);
229+
}
214230
}
215231
}
216232

@@ -220,7 +236,11 @@ async function generatePpkDiff(
220236
output: string,
221237
customDiff: (oldSource?: Buffer, newSource?: Buffer) => Buffer,
222238
) {
239+
console.log(
240+
`Running hdiff ppk: ${origin} -> ${next} (${fs.statSync(origin).size} -> ${fs.statSync(next).size} bytes)`,
241+
);
223242
await keepProcessAlive(
243+
'ppk diff',
224244
diffCommands.hdiff({
225245
args: [origin, next],
226246
options: {
@@ -239,7 +259,11 @@ async function generateAndroidPackageDiff(
239259
output: string,
240260
customDiff: (oldSource?: Buffer, newSource?: Buffer) => Buffer,
241261
) {
262+
console.log(
263+
`Running hdiffFromApk: ${apkPath} -> ${next} (${fs.statSync(apkPath).size} -> ${fs.statSync(next).size} bytes)`,
264+
);
242265
await keepProcessAlive(
266+
'package diff',
243267
diffCommands.hdiffFromApk({
244268
args: [apkPath, next],
245269
options: {

0 commit comments

Comments
 (0)