Skip to content

Commit fe58419

Browse files
committed
Do not auto-retry native builds before tests
1 parent c0079fe commit fe58419

1 file changed

Lines changed: 5 additions & 53 deletions

File tree

test/test.ts

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -181,27 +181,15 @@ class RNAndroid extends Platform.Android implements RNPlatform {
181181
return TestUtil.getProcessOutput("adb install -r " + this.getBinaryPath(projectDirectory), { cwd: androidDirectory }).then(() => { return null; });
182182
}
183183

184-
/**
185-
* Build function of the test application, the command depends on the OS
186-
*/
187-
buildFunction(androidDirectory: string): Q.Promise<void> {
188-
const gradlewCommand = process.platform === "darwin" || process.platform === "linux" ? "./gradlew" : "gradlew";
189-
return TestUtil.getProcessOutput(`${gradlewCommand} assembleRelease`, { noLogStdOut: true, cwd: androidDirectory })
190-
.then(() => { return null; });
191-
}
192-
193184
/**
194185
* Builds the binary of the project on this platform.
195186
*/
196187
buildApp(projectDirectory: string): Q.Promise<void> {
197188
// In order to run on Android without the package manager, we must create a release APK and then sign it with the debug certificate.
198189
const androidDirectory: string = path.join(projectDirectory, TestConfig.TestAppName, "android");
199-
// If the build fails for the first time, try rebuild app again
200-
try {
201-
return this.buildFunction(androidDirectory);
202-
} catch {
203-
return this.buildFunction(androidDirectory);
204-
}
190+
const gradlewCommand = process.platform === "darwin" || process.platform === "linux" ? "./gradlew" : "gradlew";
191+
return TestUtil.getProcessOutput(`${gradlewCommand} assembleRelease`, { noLogStdOut: true, cwd: androidDirectory })
192+
.then(() => { return null; });
205193
}
206194
}
207195

@@ -280,19 +268,6 @@ class RNIOS extends Platform.IOS implements RNPlatform {
280268
return TestUtil.getProcessOutput("xcrun simctl install booted " + this.getBinaryPath(projectDirectory)).then(() => { return null; });
281269
}
282270

283-
/**
284-
* Maps project directories to whether or not they have built an IOS project before.
285-
*
286-
* The first build of an IOS project does not always succeed, so we always try again when it fails.
287-
*
288-
* EXAMPLE:
289-
* {
290-
* "TEMP_DIR/test-run": true,
291-
* "TEMP_DIR/updates": false
292-
* }
293-
*/
294-
private static iosFirstBuild: any = {};
295-
296271
/**
297272
* Maps project directories to whether or not a real `xcodebuild` has completed for them yet.
298273
* Once true, subsequent scenario switches only need their JS bundle re-packaged, not a full
@@ -310,15 +285,7 @@ class RNIOS extends Platform.IOS implements RNPlatform {
310285
}
311286
return this.realBuildApp(projectDirectory)
312287
.then(() => {
313-
// realBuildApp can resolve even after a failed build (it swallows a failed
314-
// retry into a resolved null - pre-existing behavior, unchanged here). Only
315-
// mark this project as built if the .app it's supposed to have produced
316-
// actually exists, so a swallowed failure doesn't cause every subsequent
317-
// scenario switch to bundleOnly against a missing/stale binary - the next
318-
// buildApp call will instead retry a real xcodebuild.
319-
if (fs.existsSync(this.getBinaryPath(projectDirectory))) {
320-
RNIOS.hasBuiltOnce[projectDirectory] = true;
321-
}
288+
RNIOS.hasBuiltOnce[projectDirectory] = true;
322289
});
323290
}
324291

@@ -363,22 +330,7 @@ class RNIOS extends Platform.IOS implements RNPlatform {
363330
return TestUtil.getProcessOutput("xcodebuild -workspace " + path.join(iOSProject, TestConfig.TestAppName) + ".xcworkspace -scheme " + TestConfig.TestAppName +
364331
" -configuration Release -destination \"platform=iOS Simulator,id=" + targetEmulator + "\" -derivedDataPath build", { cwd: iOSProject, timeout: 10 * 60 * 1000, maxBuffer: 1024 * 1024 * 5000, noLogStdOut: true });
365332
})
366-
.then<void>(
367-
() => { return null; },
368-
(error: any) => {
369-
console.info(error);
370-
// The first time an iOS project is built, it fails because it does not finish building libReact.a before it builds the test app.
371-
// Simply build again to fix the issue.
372-
if (!RNIOS.iosFirstBuild[projectDirectory]) {
373-
const iosBuildFolder = path.join(iOSProject, "build");
374-
if (fs.existsSync(iosBuildFolder)) {
375-
del.sync([iosBuildFolder], { force: true });
376-
}
377-
RNIOS.iosFirstBuild[projectDirectory] = true;
378-
return this.realBuildApp(projectDirectory);
379-
}
380-
return null;
381-
});
333+
.then<void>(() => { return null; });
382334
}
383335
}
384336

0 commit comments

Comments
 (0)